immutabler 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/immutabler/dsl/mapping.rb +1 -1
- data/lib/immutabler/template/body_template.rb +42 -6
- data/lib/immutabler/template/builder.rb +2 -2
- data/lib/immutabler/template/header_template.rb +3 -3
- data/lib/immutabler/type_mapper.rb +1 -1
- data/lib/immutabler/version.rb +1 -1
- data/templates/body_template.hbs +4 -24
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abc6f4fb7cc071157e338539a05eed7f701a634a
|
4
|
+
data.tar.gz: 001d0b3734fcee8d27f72f4083bb536a9b0395e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4c3e855a7325dc52b4913be8f4c93f87e52cc3f2758b634a03cf7230231278933cabbec7d76fb149dbef51b45658c5c2e52e68261b19528beae15ef6c280cdb
|
7
|
+
data.tar.gz: 3f2e278f589cf15b4ffc61a1a1d78a08b290ce0d916b2549531cb3be24b9cdcd6095cfbe4160bc0b7b4d8b438fe0431d31bfff4fa4cb2da143be6ce68f52b19e
|
@@ -8,7 +8,7 @@ module Immutabler
|
|
8
8
|
@destination_name = destination_name
|
9
9
|
@type = options[:type]
|
10
10
|
@is_array = options.fetch(:array, false)
|
11
|
-
@is_dict
|
11
|
+
@is_dict = options.fetch(:dict, false)
|
12
12
|
@custom_transformer = options[:with]
|
13
13
|
@dict_mappings = []
|
14
14
|
end
|
@@ -14,9 +14,7 @@ module Immutabler
|
|
14
14
|
body = "@{\n"
|
15
15
|
|
16
16
|
if arg
|
17
|
-
body << arg.map{|m|
|
18
|
-
"@\"#{m.destination_name}\" : @\"#{m.origin_name}\""
|
19
|
-
}.join(",\n")
|
17
|
+
body << arg.map { |m| "@\"#{m.destination_name}\" : @\"#{m.origin_name}\"" }.join(",\n")
|
20
18
|
end
|
21
19
|
|
22
20
|
body << "\n};"
|
@@ -26,9 +24,7 @@ module Immutabler
|
|
26
24
|
body = "@{\n"
|
27
25
|
|
28
26
|
if arg
|
29
|
-
body << arg.map{|m|
|
30
|
-
"@\"#{m.origin_name}\" : @(#{m.destination_name})"
|
31
|
-
}.join(",\n")
|
27
|
+
body << arg.map { |m| "@\"#{m.origin_name}\" : @(#{m.destination_name})" }.join(",\n")
|
32
28
|
end
|
33
29
|
|
34
30
|
body << "\n};"
|
@@ -50,6 +46,46 @@ module Immutabler
|
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
49
|
+
helper(:decodeProperty) do |context, arg, block|
|
50
|
+
case arg.type
|
51
|
+
when 'BOOL'
|
52
|
+
" _#{arg.name} = [coder decodeBoolForKey:@\"_#{arg.name}\"];"
|
53
|
+
when 'NSInteger'
|
54
|
+
" if (sizeof(_#{arg.name}) < 8) {\n \
|
55
|
+
_#{arg.name} = [coder decodeInt32ForKey:@\"_#{arg.name}\"];\n\
|
56
|
+
}\n\
|
57
|
+
else {\n\
|
58
|
+
_#{arg.name} = [coder decodeInt64ForKey:@\"_#{arg.name}\"]; \n\
|
59
|
+
}"
|
60
|
+
when 'CGFloat'
|
61
|
+
" _#{arg.name} = [coder decodeFloatForKey:@\"_#{arg.name}\"];"
|
62
|
+
when 'double'
|
63
|
+
" _#{arg.name} = [coder decodeDoubleForKey:@\"_#{arg.name}\"];"
|
64
|
+
else
|
65
|
+
" _#{arg.name} = [coder decodeObjectForKey:@\"_#{arg.name}\"];"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
helper(:encodeProperty) do |context, arg, block|
|
70
|
+
case arg.type
|
71
|
+
when 'BOOL'
|
72
|
+
" [coder encodeBool:self.#{arg.name} forKey:@\"_#{arg.name}\"];"
|
73
|
+
when 'NSInteger'
|
74
|
+
" if (sizeof(_#{arg.name}) < 8) {\n \
|
75
|
+
[coder encodeInt32:self.#{arg.name} forKey:@\"_#{arg.name}\"];\n\
|
76
|
+
}\n\
|
77
|
+
else {\n\
|
78
|
+
[coder encodeInt64:self.#{arg.name} forKey:@\"_#{arg.name}\"]; \n\
|
79
|
+
}"
|
80
|
+
when 'CGFloat'
|
81
|
+
" [coder encodeFloat:self.#{arg.name} forKey:@\"_#{arg.name}\"];"
|
82
|
+
when 'double'
|
83
|
+
" [coder encodeDouble:self.#{arg.name} forKey:@\"_#{arg.name}\"];"
|
84
|
+
else
|
85
|
+
" [coder encodeObject:self.#{arg.name} forKey:@\"_#{arg.name}\"];"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
53
89
|
helper(:base_immutable_interface) do |context, arg, block|
|
54
90
|
if arg[:base_immutable]
|
55
91
|
[
|
@@ -26,7 +26,7 @@ module Immutabler
|
|
26
26
|
props: build_props(model.props),
|
27
27
|
any_mappings: model.mappings.any?,
|
28
28
|
array_mappings: model.mappings.select(&:array?),
|
29
|
-
dict_mappings:
|
29
|
+
dict_mappings: build_dict_mappings(model.mappings),
|
30
30
|
custom_mappers: build_custom_mappers(model.mappings),
|
31
31
|
mappings: build_mappings(model.mappings)
|
32
32
|
}
|
@@ -53,7 +53,7 @@ module Immutabler
|
|
53
53
|
mappings.select(&:dict?).map do |mapping|
|
54
54
|
attributes = mapping.dict_mappings.map do |dict_mapping|
|
55
55
|
{
|
56
|
-
origin_name:
|
56
|
+
origin_name: dict_mapping[:origin_name],
|
57
57
|
destination_name: dict_mapping[:destination_name]
|
58
58
|
}
|
59
59
|
end
|
@@ -26,10 +26,10 @@ module Immutabler
|
|
26
26
|
options = block[:hash]
|
27
27
|
access_type = options[:readOnly] ? 'readonly' : 'readwrite'
|
28
28
|
asterisk = prop[:is_ref] && !prop[:is_id] ? '*' : ''
|
29
|
-
asterisk_and_prefix =
|
29
|
+
asterisk_and_prefix = "#{asterisk}#{prop[:name_prefix]}"
|
30
30
|
memory_management = prop[:is_ref] ? prop[:ref_type] : 'assign';
|
31
31
|
prop_arguments = "@property(nonatomic, #{memory_management}, #{access_type})"
|
32
|
-
prop_field = "#{prop[:type]} #{asterisk_and_prefix}#{prop[:name]}"
|
32
|
+
prop_field = "#{prop[:type]} #{asterisk_and_prefix}#{prop[:name]}"
|
33
33
|
"#{prop_arguments} #{prop_field};"
|
34
34
|
end.join("\n")
|
35
35
|
end
|
@@ -45,7 +45,7 @@ module Immutabler
|
|
45
45
|
|
46
46
|
def build_enums(enums)
|
47
47
|
enums.map do |enum|
|
48
|
-
attributes = enum.attributes.map { |attr| {
|
48
|
+
attributes = enum.attributes.map { |attr| {name: attr.name} }
|
49
49
|
|
50
50
|
{
|
51
51
|
name: enum.name,
|
data/lib/immutabler/version.rb
CHANGED
data/templates/body_template.hbs
CHANGED
@@ -139,18 +139,8 @@
|
|
139
139
|
{{#init_with_coder .}}
|
140
140
|
{{/init_with_coder}}
|
141
141
|
if (self) {
|
142
|
-
{{#props}}
|
143
|
-
{{#
|
144
|
-
_{{name}} = [coder decodeObjectForKey:@"_{{name}}"];
|
145
|
-
{{/is_ref}}
|
146
|
-
{{^is_ref}}
|
147
|
-
if (sizeof(_{{name}}) < 8) {
|
148
|
-
_{{name}} = [coder decodeInt32ForKey:@"_{{name}}"];
|
149
|
-
}
|
150
|
-
else {
|
151
|
-
_{{name}} = [coder decodeInt64ForKey:@"_{{name}}"];
|
152
|
-
}
|
153
|
-
{{/is_ref}}
|
142
|
+
{{#props}}
|
143
|
+
{{#decodeProperty this}}{{/decodeProperty}}
|
154
144
|
{{/props}}
|
155
145
|
__modelVersion = [coder decodeIntegerForKey:@"__modelVersion"];
|
156
146
|
}
|
@@ -159,18 +149,8 @@
|
|
159
149
|
}
|
160
150
|
|
161
151
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
162
|
-
{{#props}}
|
163
|
-
{{#
|
164
|
-
[coder encodeObject:self.{{name}} forKey:@"_{{name}}"];
|
165
|
-
{{/is_ref}}
|
166
|
-
{{^is_ref}}
|
167
|
-
if (sizeof(_{{name}}) < 8) {
|
168
|
-
[coder encodeInt32:self.{{name}} forKey:@"_{{name}}"];
|
169
|
-
}
|
170
|
-
else {
|
171
|
-
[coder encodeInt64:self.{{name}} forKey:@"_{{name}}"];
|
172
|
-
}
|
173
|
-
{{/is_ref}}
|
152
|
+
{{#props}}
|
153
|
+
{{#encodeProperty this}}{{/encodeProperty}}
|
174
154
|
{{/props}}
|
175
155
|
[coder encodeInteger:__modelVersion forKey:@"__modelVersion"];
|
176
156
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immutabler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serhij Korochanskyj
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: handlebars
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.0.14
|
132
|
+
rubygems_version: 2.0.14.1
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Generator of Objective-C immutable models
|