gyro 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gyro/parser/xcdatamodel/attribute.rb +5 -5
- data/lib/gyro/parser/xcdatamodel/entity.rb +6 -6
- data/lib/gyro/parser/xcdatamodel/relationship.rb +6 -6
- data/lib/gyro/parser/xcdatamodel/xcdatamodel.rb +5 -3
- data/lib/gyro/parser/xcdatamodel.rb +1 -1
- data/lib/gyro/version.rb +1 -1
- data/lib/templates/decodable/README.md +4 -2
- data/lib/templates/object-mapper/README.md +4 -2
- data/lib/templates/swift3/README.md +1 -0
- data/lib/templates/swift3/entity.liquid +1 -0
- data/lib/templates/swift3-variant/README.md +1 -0
- data/lib/templates/swift3-variant/entity.liquid +1 -0
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a514835bd0ec32d1c3d435dacb35f57fcd5c67d3
|
4
|
+
data.tar.gz: 3f295908353f89859d307f4757afd277ef2ce141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd5b55d23f50e1fd66e7bdddf75acbee534471c9d15434824ee1c43f970d10458ea799e6a517e1cdb9e8dea63043f8cdc3cb31c7bfbf8975fc97034f7ccaf25
|
7
|
+
data.tar.gz: a47c9b8e4c73e2b34368371a4d08901faec7fcd4e2bce118f1e70adf03ff8d712bdf31504160063ae1bc7b5714d278d06c6ce04d842b94902851bb2a6956030a
|
data/README.md
CHANGED
@@ -76,7 +76,7 @@ _To define a User Info key in Xcode's xcdatamodel editor, select the entity or a
|
|
76
76
|
|
77
77
|
With the help of these "user infos", you will be able to give Gyro extra information about your model classes. For example, you can tell which attribute is the primary key, the attributes to ignore, the JSON mappings, …
|
78
78
|
|
79
|
-
**For more information about "user infos", you can see the dedicated documentation [here](
|
79
|
+
**For more information about "user infos", you can see the dedicated documentation [here](UserInfoKeys.md).**
|
80
80
|
|
81
81
|
## License
|
82
82
|
|
@@ -29,11 +29,11 @@ module Gyro
|
|
29
29
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
30
30
|
def initialize(attribute_xml, entity_name)
|
31
31
|
@entity_name = entity_name
|
32
|
-
@name = attribute_xml.
|
33
|
-
@optional = attribute_xml.
|
34
|
-
@indexed = attribute_xml.
|
35
|
-
@default = attribute_xml.
|
36
|
-
@type = attribute_xml.
|
32
|
+
@name = attribute_xml.attributes['name'].to_s
|
33
|
+
@optional = attribute_xml.attributes['optional'].to_s == 'YES'
|
34
|
+
@indexed = attribute_xml.attributes['indexed'].to_s == 'YES'
|
35
|
+
@default = attribute_xml.attributes['defaultValueString'].to_s
|
36
|
+
@type = attribute_xml.attributes['attributeType'].to_s.downcase.tr(' ', '_').to_sym
|
37
37
|
@realm_ignored = !Gyro::Parser::XCDataModel.user_info(attribute_xml, 'realmIgnored').empty?
|
38
38
|
@realm_read_only = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'realmReadOnly')
|
39
39
|
@enum_type = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'enumType')
|
@@ -23,9 +23,9 @@ module Gyro
|
|
23
23
|
|
24
24
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
25
25
|
def initialize(entity_xml)
|
26
|
-
@name = entity_xml.
|
27
|
-
@parent = entity_xml.
|
28
|
-
@abstract = entity_xml.
|
26
|
+
@name = entity_xml.attributes['name'].to_s
|
27
|
+
@parent = entity_xml.attributes['parentEntity'].to_s
|
28
|
+
@abstract = entity_xml.attributes['isAbstract'].to_s == 'YES'
|
29
29
|
@clean = false
|
30
30
|
@identity_attribute = Gyro::Parser::XCDataModel.user_info(entity_xml, 'identityAttribute')
|
31
31
|
@comment = Gyro::Parser::XCDataModel.user_info(entity_xml, 'comment')
|
@@ -130,7 +130,7 @@ module Gyro
|
|
130
130
|
|
131
131
|
def transformers
|
132
132
|
transformers = Set.new
|
133
|
-
@attributes.
|
133
|
+
@attributes.each_value do |_, attribute|
|
134
134
|
transformers.add attribute.transformer unless attribute.transformer.empty?
|
135
135
|
end
|
136
136
|
transformers
|
@@ -175,7 +175,7 @@ module Gyro
|
|
175
175
|
end
|
176
176
|
|
177
177
|
def load_attributes(entity_xml)
|
178
|
-
entity_xml.
|
178
|
+
entity_xml.each_element('attribute') do |node|
|
179
179
|
attribute = Attribute.new(node, @name)
|
180
180
|
if attribute.type != 'Transformable'
|
181
181
|
@attributes[attribute.name] = attribute
|
@@ -184,7 +184,7 @@ module Gyro
|
|
184
184
|
end
|
185
185
|
|
186
186
|
def load_relationships(entity_xml)
|
187
|
-
entity_xml.
|
187
|
+
entity_xml.each_element('relationship') do |node|
|
188
188
|
relationship = Relationship.new(node, @name)
|
189
189
|
@relationships[relationship.name] = relationship
|
190
190
|
end
|
@@ -28,11 +28,11 @@ module Gyro
|
|
28
28
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
29
29
|
def initialize(relationship_xml, entity_name)
|
30
30
|
@entity_name = entity_name
|
31
|
-
@name = relationship_xml.
|
32
|
-
@optional = relationship_xml.
|
33
|
-
@deletion_rule = relationship_xml.
|
34
|
-
@inverse_name = relationship_xml.
|
35
|
-
@inverse_type = relationship_xml.
|
31
|
+
@name = relationship_xml.attributes['name'].to_s
|
32
|
+
@optional = relationship_xml.attributes['optional'].to_s == 'YES'
|
33
|
+
@deletion_rule = relationship_xml.attributes['deletionRule'].to_s
|
34
|
+
@inverse_name = relationship_xml.attributes['inverseName'].to_s
|
35
|
+
@inverse_type = relationship_xml.attributes['destinationEntity'].to_s
|
36
36
|
@json_key_path = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'JSONKeyPath')
|
37
37
|
@realm_ignored = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'realmIgnored').empty? ? false : true
|
38
38
|
@support_annotation = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'supportAnnotation')
|
@@ -61,7 +61,7 @@ module Gyro
|
|
61
61
|
private ################################################################
|
62
62
|
|
63
63
|
def load_type(relationship_xml)
|
64
|
-
max_count = relationship_xml.
|
64
|
+
max_count = relationship_xml.attributes['maxCount'].to_s
|
65
65
|
@type = !max_count.nil? && (max_count == '1') ? :to_one : :to_many
|
66
66
|
end
|
67
67
|
|
@@ -12,6 +12,8 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
include REXML
|
16
|
+
|
15
17
|
module Gyro
|
16
18
|
module Parser
|
17
19
|
# Parser for CoreData's xcdatamodel files
|
@@ -25,7 +27,7 @@ module Gyro
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.user_info(xml, key)
|
28
|
-
|
30
|
+
XPath.first(xml, "userInfo/entry[@key='#{key}']/@value").to_s
|
29
31
|
end
|
30
32
|
|
31
33
|
# Represents the whole xcdatamodel file struture, once parsed
|
@@ -38,7 +40,7 @@ module Gyro
|
|
38
40
|
Gyro::Log.fail!('Unable to find contents of xcdatamodel', stacktrace: true) unless File.exist?(contents_file)
|
39
41
|
@entities = {}
|
40
42
|
file = File.open(contents_file)
|
41
|
-
document_xml =
|
43
|
+
document_xml = Document.new(file)
|
42
44
|
file.close
|
43
45
|
load_entities(document_xml)
|
44
46
|
end
|
@@ -54,7 +56,7 @@ module Gyro
|
|
54
56
|
private
|
55
57
|
|
56
58
|
def load_entities(document_xml)
|
57
|
-
document_xml.
|
59
|
+
document_xml.root.each_element('//entity') do |node|
|
58
60
|
entity = Entity.new(node)
|
59
61
|
@entities[entity.name] = entity
|
60
62
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require '
|
15
|
+
require 'rexml/document'
|
16
16
|
|
17
17
|
require 'gyro/parser/xcdatamodel/xcdatamodel'
|
18
18
|
require 'gyro/parser/xcdatamodel/attribute'
|
data/lib/gyro/version.rb
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
| Invocation example | `gyro -m <model> -t decodable …` |
|
7
7
|
| Language | Swift 3 |
|
8
8
|
|
9
|
-
This template generate
|
9
|
+
This template generate code to be used with [Anviking's Decodable Swift library](https://github.com/Anviking/Decodable) (not to be confused with Swift 4's Decodable)
|
10
|
+
|
11
|
+
It generates a `Decodable` extension for each object of your data model.
|
10
12
|
|
11
13
|
# Generated Code
|
12
14
|
|
@@ -31,4 +33,4 @@ extension Shop: Decodable {
|
|
31
33
|
return shop
|
32
34
|
}
|
33
35
|
}
|
34
|
-
```
|
36
|
+
```
|
@@ -6,7 +6,9 @@
|
|
6
6
|
| Invocation example | `gyro -m <model> -t object-mapper …` |
|
7
7
|
| Language | Swift 3 |
|
8
8
|
|
9
|
-
This template
|
9
|
+
This template is useful if you use [ObjectMapper](https://github.com/Hearst-DD/ObjectMapper) to handle the JSON parsing of your model objects. It generates an `ObjectMapper` extension for each object of your data model.
|
10
|
+
|
11
|
+
_Note: When using this template to handle your JSON parsing for Swift, you'll have to use the `swift3-variant` template (instead of using the `swift3` template) to generate your main code for Realm Object classes (as it generates `var` and optional properties which are needed by `ObjectMapper`)_
|
10
12
|
|
11
13
|
# Generated Code
|
12
14
|
|
@@ -37,4 +39,4 @@ extension Shop: Mappable {
|
|
37
39
|
self.attrInteger64 <- (map["attrInteger64"], MPIntegerTransformer())
|
38
40
|
}
|
39
41
|
}
|
40
|
-
```
|
42
|
+
```
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gyro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NijiDigital
|
@@ -16,42 +16,28 @@ dependencies:
|
|
16
16
|
name: liquid
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '3.0'
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: nokogiri
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - "~>"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 1.6.8
|
36
|
-
type: :runtime
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - "~>"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 1.6.8
|
43
29
|
- !ruby/object:Gem::Dependency
|
44
30
|
name: rspec
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
46
32
|
requirements:
|
47
|
-
- -
|
33
|
+
- - ~>
|
48
34
|
- !ruby/object:Gem::Version
|
49
35
|
version: '3.5'
|
50
36
|
type: :development
|
51
37
|
prerelease: false
|
52
38
|
version_requirements: !ruby/object:Gem::Requirement
|
53
39
|
requirements:
|
54
|
-
- -
|
40
|
+
- - ~>
|
55
41
|
- !ruby/object:Gem::Version
|
56
42
|
version: '3.5'
|
57
43
|
description: |2
|
@@ -163,17 +149,17 @@ require_paths:
|
|
163
149
|
- lib
|
164
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
165
151
|
requirements:
|
166
|
-
- -
|
152
|
+
- - '>='
|
167
153
|
- !ruby/object:Gem::Version
|
168
154
|
version: 2.0.0
|
169
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
|
-
- -
|
157
|
+
- - '>='
|
172
158
|
- !ruby/object:Gem::Version
|
173
159
|
version: '0'
|
174
160
|
requirements: []
|
175
161
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.4.7
|
177
163
|
signing_key:
|
178
164
|
specification_version: 4
|
179
165
|
summary: Generate Realm.io models for Swift, Java & ObjC from xcdatamodel
|