core_data 0.1.2 → 0.2.0

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: b65bd21319ed65b97bcca20230eec6a3be24ecc6
4
- data.tar.gz: cfcdb77b1865cef6bcf53533c4f56dc8b6834af5
3
+ metadata.gz: bd8ceef611144a6fd8a9565b4d9105c15d9a76c1
4
+ data.tar.gz: ccfe3e1f93cb8218b7b008fd1b732d1eda6bf486
5
5
  SHA512:
6
- metadata.gz: ec83b44f2a3afa5012a4f5844cff30f936ca47921593fc6a31a4092c5e60bcdec885c6a2b78dc68d8728046604a6b6728cf69871a952ae551c6b23d18ce9711b
7
- data.tar.gz: f3cccc28f8d5355005d7d5dd51add5d649d530597e47e3bc0c4c4d87c9c641dfe7292dd6d68a09e18b2f5ef3e8363a070a95ebb3ab12e0dd892482664cfdf80f
6
+ metadata.gz: d82117e89ce6bfadf09ffb499a806388cf71ececb2a9a73c756519b6a832d2cfd8d2f5d23c26b0d4fb7a47fd4b07ee8f3e6af3ea13ff0f4d3831e337c1613d4f
7
+ data.tar.gz: 1b61deb7fe20050c06aef462f5942ab2349b201ea84139279145f0340282199776851e6b767306566e459f22a36a388658783395d0a6d66b4f27df401d1369ec
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- core_data (0.1.2)
4
+ core_data (0.2.0)
5
5
  nokogiri (~> 1.4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- mini_portile (0.6.2)
11
- nokogiri (1.6.6.2)
12
- mini_portile (~> 0.6.0)
13
- rake (10.0.4)
10
+ mini_portile2 (2.4.0)
11
+ nokogiri (1.10.3)
12
+ mini_portile2 (~> 2.4.0)
13
+ rake (12.3.2)
14
14
 
15
15
  PLATFORMS
16
16
  ruby
@@ -18,3 +18,6 @@ PLATFORMS
18
18
  DEPENDENCIES
19
19
  core_data!
20
20
  rake
21
+
22
+ BUNDLED WITH
23
+ 2.0.1
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Mattt Thompson (http://mattt.me/)
1
+ Copyright (c) 2013 – 2019 Mattt (https://mat.tt/)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # Core Data
2
+
2
3
  **Parse Core Data Model (.xcdatamodel) Files**
3
4
 
4
5
  ## Contact
5
6
 
6
- Mattt Thompson
7
-
8
- - http://github.com/mattt
9
- - http://twitter.com/mattt
10
- - m@mattt.me
7
+ [Mattt](https://twitter.com/mattt)
11
8
 
12
9
  ## License
13
10
 
14
- Core Data is released under an MIT license. See LICENSE for more information.
11
+ Core Data is released under an MIT license.
12
+ See LICENSE for more information.
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
2
4
  Bundler.setup
3
5
 
4
- gemspec = eval(File.read("core_data.gemspec"))
6
+ gemspec = eval(File.read('core_data.gemspec'))
5
7
 
6
- task :build => "#{gemspec.full_name}.gem"
8
+ task build: "#{gemspec.full_name}.gem"
7
9
 
8
- file "#{gemspec.full_name}.gem" => gemspec.files + ["core_data.gemspec"] do
9
- system "gem build core_data.gemspec"
10
+ file "#{gemspec.full_name}.gem" => gemspec.files + ['core_data.gemspec'] do
11
+ system 'gem build core_data.gemspec'
10
12
  end
@@ -1,24 +1,25 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "core_data/version"
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+ require 'core_data/version'
4
5
 
5
6
  Gem::Specification.new do |s|
6
- s.name = "core_data"
7
- s.authors = ["Mattt Thompson"]
8
- s.email = "m@mattt.me"
9
- s.homepage = "http://mattt.me"
10
- s.license = "MIT"
7
+ s.name = 'core_data'
8
+ s.authors = ['Mattt Thompson']
9
+ s.email = 'm@mattt.me'
10
+ s.homepage = 'http://mattt.me'
11
+ s.license = 'MIT'
11
12
  s.version = CoreData::VERSION
12
13
  s.platform = Gem::Platform::RUBY
13
- s.summary = "Core Data"
14
- s.description = "Parse Core Data models."
14
+ s.summary = 'Core Data'
15
+ s.description = 'Parse Core Data models.'
15
16
 
16
- s.add_development_dependency "rake"
17
+ s.add_development_dependency 'rake'
17
18
 
18
- s.add_dependency "nokogiri", "~> 1.4"
19
+ s.add_dependency 'nokogiri', '~> 1.4'
19
20
 
20
- s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|example|log|pkg|script|spec|test|vendor)/ }
21
+ s.files = Dir['./**/*'].reject { |file| file =~ %r{\./(bin|example|log|pkg|script|spec|test|vendor)} }
21
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
- s.require_paths = ["lib"]
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
24
+ s.require_paths = ['lib']
24
25
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'core_data/version'
2
4
  require 'core_data/data_model'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'nokogiri'
2
4
 
3
5
  module CoreData
@@ -8,13 +10,13 @@ module CoreData
8
10
  loop do
9
11
  case data_model
10
12
  when File, /^\<\?xml/
11
- data_model = ::Nokogiri::XML(data_model) and redo
13
+ (data_model = ::Nokogiri::XML(data_model)) && redo
12
14
  when String
13
15
  case data_model
14
16
  when /\.xcdatamodeld?$/
15
- data_model = Dir[File.join(data_model, "/**/contents")].first and redo
17
+ (data_model = Dir[File.join(data_model, '/**/contents')].first) && redo
16
18
  else
17
- data_model = ::File.read(data_model) and redo
19
+ (data_model = ::File.read(data_model)) && redo
18
20
  end
19
21
  when ::Nokogiri::XML::Document
20
22
  break
@@ -27,7 +29,7 @@ module CoreData
27
29
 
28
30
  @name = model['name']
29
31
  @version = model['systemVersion']
30
- @entities = model.xpath('entity').collect{|element| Entity.new(element)}
32
+ @entities = model.xpath('entity').collect { |element| Entity.new(element) }
31
33
  end
32
34
  end
33
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CoreData
2
4
  class DataModel
3
5
  class Attribute
@@ -15,20 +17,24 @@ module CoreData
15
17
  @minimum_value = range_value_from_string(attribute['minValueString'])
16
18
  @maximum_value = range_value_from_string(attribute['maxValueString'])
17
19
 
18
- @regular_expression = Regexp.new(attributes['regularExpressionString']) rescue nil
20
+ @regular_expression = begin
21
+ Regexp.new(attributes['regularExpressionString'])
22
+ rescue StandardError
23
+ nil
24
+ end
19
25
 
20
- @optional = attribute['optional'] == "YES"
21
- @transient = attribute['transient'] == "YES"
22
- @indexed = attribute['indexed'] == "YES"
23
- @syncable = attribute['syncable'] == "YES"
26
+ @optional = attribute['optional'] == 'YES'
27
+ @transient = attribute['transient'] == 'YES'
28
+ @indexed = attribute['indexed'] == 'YES'
29
+ @syncable = attribute['syncable'] == 'YES'
24
30
  end
25
31
 
26
32
  def to_s
27
33
  [@name, @type].to_s
28
34
  end
29
35
 
30
- [:optional, :transient, :indexed, :syncable].each do |symbol|
31
- define_method("#{symbol}?") {!!instance_variable_get(("@#{symbol}").intern)}
36
+ %i[optional transient indexed syncable].each do |symbol|
37
+ define_method("#{symbol}?") { !!instance_variable_get("@#{symbol}".intern) }
32
38
  end
33
39
 
34
40
  private
@@ -36,28 +42,28 @@ module CoreData
36
42
  def default_value_from_string(string)
37
43
  return nil unless string
38
44
 
39
- return case @type
40
- when "Integer 16", "Integer 32", "Integer 64"
41
- string.to_i
42
- when "Float", "Decimal"
43
- string.to_f
44
- when "Boolean"
45
- string == "YES"
46
- else
47
- string
45
+ case @type
46
+ when 'Integer 16', 'Integer 32', 'Integer 64'
47
+ string.to_i
48
+ when 'Float', 'Decimal'
49
+ string.to_f
50
+ when 'Boolean'
51
+ string == 'YES'
52
+ else
53
+ string
48
54
  end
49
55
  end
50
56
 
51
57
  def range_value_from_string(string)
52
58
  return nil unless string
53
59
 
54
- return case @type
55
- when "Float", "Decimal"
56
- string.to_f
57
- when "Date"
58
- string
59
- else
60
- string.to_i
60
+ case @type
61
+ when 'Float', 'Decimal'
62
+ string.to_f
63
+ when 'Date'
64
+ string
65
+ else
66
+ string.to_i
61
67
  end
62
68
  end
63
69
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CoreData
2
4
  class DataModel
3
5
  class Entity
@@ -7,8 +9,8 @@ module CoreData
7
9
  raise ArgumentError unless ::Nokogiri::XML::Element === entity
8
10
 
9
11
  @name = entity['name']
10
- @attributes = entity.xpath('attribute').collect{|element| Attribute.new(element)}
11
- @relationships = entity.xpath('relationship').collect{|element| Relationship.new(element)}
12
+ @attributes = entity.xpath('attribute').collect { |element| Attribute.new(element) }
13
+ @relationships = entity.xpath('relationship').collect { |element| Relationship.new(element) }
12
14
  end
13
15
 
14
16
  def to_s
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CoreData
2
4
  class DataModel
3
5
  class Relationship
@@ -14,10 +16,10 @@ module CoreData
14
16
  @min_count = relationship['minCount'].to_i
15
17
  @max_count = relationship['maxCount'].to_i
16
18
 
17
- @to_many = relationship['toMany'] == "YES"
18
- @optional = relationship['optional'] == "YES"
19
- @syncable = relationship['syncable'] == "YES"
20
- @ordered = relationship['ordered'] == "YES"
19
+ @to_many = relationship['toMany'] == 'YES'
20
+ @optional = relationship['optional'] == 'YES'
21
+ @syncable = relationship['syncable'] == 'YES'
22
+ @ordered = relationship['ordered'] == 'YES'
21
23
  end
22
24
 
23
25
  def to_s
@@ -36,8 +38,8 @@ module CoreData
36
38
  @ordered
37
39
  end
38
40
 
39
- [:optional, :syncable].each do |symbol|
40
- define_method("#{symbol}?") {!!instance_variable_get(("@#{symbol}").intern)}
41
+ %i[optional syncable].each do |symbol|
42
+ define_method("#{symbol}?") { !!instance_variable_get("@#{symbol}".intern) }
41
43
  end
42
44
  end
43
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CoreData
2
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
3
5
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattt Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2019-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.4'
41
41
  description: Parse Core Data models.
@@ -44,18 +44,18 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - ./core_data.gemspec
48
- - ./Gemfile
49
- - ./Gemfile.lock
50
- - ./lib/core_data/data_model/attribute.rb
51
- - ./lib/core_data/data_model/entity.rb
52
- - ./lib/core_data/data_model/relationship.rb
53
- - ./lib/core_data/data_model.rb
54
- - ./lib/core_data/version.rb
55
- - ./lib/core_data.rb
56
- - ./LICENSE
57
- - ./Rakefile
58
- - ./README.md
47
+ - "./Gemfile"
48
+ - "./Gemfile.lock"
49
+ - "./LICENSE.md"
50
+ - "./README.md"
51
+ - "./Rakefile"
52
+ - "./core_data.gemspec"
53
+ - "./lib/core_data.rb"
54
+ - "./lib/core_data/data_model.rb"
55
+ - "./lib/core_data/data_model/attribute.rb"
56
+ - "./lib/core_data/data_model/entity.rb"
57
+ - "./lib/core_data/data_model/relationship.rb"
58
+ - "./lib/core_data/version.rb"
59
59
  homepage: http://mattt.me
60
60
  licenses:
61
61
  - MIT
@@ -66,17 +66,17 @@ require_paths:
66
66
  - lib
67
67
  required_ruby_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.1.11
79
+ rubygems_version: 2.6.14
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Core Data