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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1db016a0a566471d730df382014b89f0d0dc1d9b
4
- data.tar.gz: 8ac5c0522b051b9f61382f2c6332c5c1a3884efd
3
+ metadata.gz: a514835bd0ec32d1c3d435dacb35f57fcd5c67d3
4
+ data.tar.gz: 3f295908353f89859d307f4757afd277ef2ce141
5
5
  SHA512:
6
- metadata.gz: 24a479c020eadc633a9114ab6ce3d111961677a851fec2f34fcded5425bc6ff037bcac1184411dcc55b8e91674d41d68698cab4e5770b7d93640d881b3017a92
7
- data.tar.gz: 891fcb7c000c6c044a5aaccf875a5bf73e320613c72e3bf055f63dbcbf75a6c321bfe820efbeb6782af33f00b031afe79eefdc32ddb446cdebf070b2e8561199
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](USER-INFO.md).**
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.xpath('@name').to_s
33
- @optional = attribute_xml.xpath('@optional').to_s == 'YES'
34
- @indexed = attribute_xml.xpath('@indexed').to_s == 'YES'
35
- @default = attribute_xml.xpath('@defaultValueString').to_s
36
- @type = attribute_xml.xpath('@attributeType').to_s.downcase.tr(' ', '_').to_sym
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.xpath('@name').to_s
27
- @parent = entity_xml.xpath('@parentEntity').to_s
28
- @abstract = entity_xml.xpath('@isAbstract').to_s == 'YES' ? true : false
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.each do |_, attribute|
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.xpath('attribute').each do |node|
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.xpath('relationship').each do |node|
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.xpath('@name').to_s
32
- @optional = relationship_xml.xpath('@optional').to_s == 'YES' ? true : false
33
- @deletion_rule = relationship_xml.xpath('@deletionRule').to_s
34
- @inverse_name = relationship_xml.xpath('@inverseName').to_s
35
- @inverse_type = relationship_xml.xpath('@destinationEntity').to_s
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.xpath('@maxCount').to_s
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
- xml.xpath("userInfo/entry[@key='#{key}']/@value").to_s
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 = Nokogiri::XML(file).remove_namespaces!
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.xpath('//entity').each do |node|
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 'nokogiri'
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
@@ -15,5 +15,5 @@
15
15
  # Gyro Version
16
16
  #
17
17
  module Gyro
18
- VERSION = '1.0.0'.freeze
18
+ VERSION = '1.0.1'.freeze
19
19
  end
@@ -6,7 +6,9 @@
6
6
  | Invocation example | `gyro -m <model> -t decodable …` |
7
7
  | Language | Swift 3 |
8
8
 
9
- This template generate `Decodable` extension for each object of your data model.
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 generate `ObjectMapper` extension for each object of your data model.
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
+ ```
@@ -41,6 +41,7 @@ In this template optional Realm objects (Attributes - RealmOptional - or Relatio
41
41
  /* DO NOT EDIT | Generated by gyro */
42
42
 
43
43
  import RealmSwift
44
+ import Foundation
44
45
 
45
46
  final class Product: Object {
46
47
 
@@ -1,6 +1,7 @@
1
1
  /* DO NOT EDIT | Generated by gyro */
2
2
 
3
3
  import RealmSwift
4
+ import Foundation
4
5
 
5
6
  final class {{ entity.name }}: Object {
6
7
  {%- include 'inc/attributes_enum' -%}
@@ -40,6 +40,7 @@ In this template optional Realm objects (Attributes - RealmOptional - or Relatio
40
40
  /* DO NOT EDIT | Generated by gyro */
41
41
 
42
42
  import RealmSwift
43
+ import Foundation
43
44
 
44
45
  final class Product: Object {
45
46
 
@@ -1,6 +1,7 @@
1
1
  /* DO NOT EDIT | Generated by gyro */
2
2
 
3
3
  import RealmSwift
4
+ import Foundation
4
5
 
5
6
  final class {{ entity.name }}: Object {
6
7
  {%- include 'inc/attributes_enum' -%}
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.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.6.7
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