ruby-xcdm 0.0.9 → 0.0.10

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: d0204d65d8ce9337517bcd02c0c7e8dde186c9e8
4
- data.tar.gz: 9b844dcedb2995d97530c7c6959c2218f9fcff90
3
+ metadata.gz: 0d712f1fc465639fd48fdecf1348fd9ce08689fa
4
+ data.tar.gz: 216e010c595afbeefed2375f4dfce8e565a5b99d
5
5
  SHA512:
6
- metadata.gz: a9d535376949a9e3af6b5ecc69f4dd2ad00ba23b799eb461c8df90f6e0991fc9fd2d4e53e3629b3c25ae32652a4e29445e404e5739f636b2631f8b5b49080d6a
7
- data.tar.gz: 10e7477d6e55262f1c5c0a3149ba631c951e4fecf68c5afd398592a8423c60946ed61f8ded98e771fff6b4abbd5137cd08d497604afffa72ce730f9520be7c13
6
+ metadata.gz: c541e88501324879f89d3f55242591f82bdd548e0f57625931db4a8afb534aa2b291a5c2b345213d109c36aaa340abcd06614d4548ea396075f5a3e88cb6c612
7
+ data.tar.gz: f9b23caafabc23de2b59fa05b7a4c131fd7429c561996632752d0ea01d6e3d790a18c404e2062fc9f3f6620b78ed75f6a94ec457aa1121abf3cef92b7fccc651
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-xcdm (0.0.9)
4
+ ruby-xcdm (0.0.10)
5
5
  activesupport (~> 4.1)
6
6
  builder (~> 3.2)
7
7
  plist (~> 3.1)
data/README.md CHANGED
@@ -10,6 +10,8 @@ workflow and some niceties, like automatic inverse relationships.
10
10
  [![Build Status](https://travis-ci.org/infinitered/ruby-xcdm.png?branch=master)](https://travis-ci.org/infinitered/ruby-xcdm)
11
11
  [![Gem Version](https://badge.fury.io/rb/ruby-xcdm.png)](http://badge.fury.io/rb/ruby-xcdm)
12
12
 
13
+ ruby-xcdm is maintained by [Infinite Red](http://infinite.red), a web and mobile development company based in Portland, OR and San Francisco, CA.
14
+
13
15
  ## Installation
14
16
 
15
17
  Add this line to your application's Gemfile:
@@ -164,6 +166,25 @@ You can also have symmetric one-to-one relationships via has_one:
164
166
  end
165
167
  ```
166
168
 
169
+ Deletion rules can be easily set on relationships and the default rule is "Nullify":
170
+
171
+ ```ruby
172
+ entity "Discussion" do
173
+ has_many :messages, deletionRule: "Cascade"
174
+ end
175
+
176
+ entity "Message" do
177
+ belongs_to :discusion
178
+ end
179
+
180
+ # Example:
181
+ # Discussion.first.messages.count => 10
182
+ # Messages.count => 10
183
+ # Discussion.first.destroy
184
+ # cdq.save
185
+ # Messages.count => 0
186
+ ```
187
+
167
188
  Core Data has no equivalent of ```:through``` in ActiveRecord, so you'll
168
189
  need to handle that relation yourself.
169
190
 
@@ -140,7 +140,12 @@ module XCDM
140
140
 
141
141
  def to_xml(builder = nil)
142
142
  builder ||= Builder::XmlMarkup.new(:indent => 2)
143
- options = { name: name, syncable: 'YES', representedClassName: class_name }.merge(@options)
143
+ options = {
144
+ name: name,
145
+ syncable: 'YES',
146
+ representedClassName: class_name,
147
+ codeGenerationType: 'class'
148
+ }.merge(@options)
144
149
  builder.entity(options) do |xml|
145
150
  properties.each do |property|
146
151
  xml.attribute(property)
@@ -1,3 +1,3 @@
1
1
  module XCDM
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -91,6 +91,13 @@ module XCDM
91
91
  "Author", inverseName: "article", inverseEntity: "Author" }], e.relationships
92
92
  end
93
93
 
94
+ def test_has_one_should_not_plural
95
+ e.has_one 'address'
96
+ assert_equal [{ optional: "YES", deletionRule: "Nullify", syncable: "YES",
97
+ name: "address", minCount: "1", maxCount: "1", destinationEntity:
98
+ "Address", inverseName: "article", inverseEntity: "Address" }], e.relationships
99
+ end
100
+
94
101
  def test_belongs_to
95
102
  e.belongs_to 'author'
96
103
  assert_equal [{ optional: "YES", deletionRule: "Nullify", syncable: "YES",
@@ -105,6 +112,13 @@ module XCDM
105
112
  "Author", inverseName: "article", inverseEntity: "Author" }], e.relationships
106
113
  end
107
114
 
115
+ def test_deletion_cascade
116
+ e.has_many 'authors', { deletionRule: 'Cascade'}
117
+ assert_equal [{ optional: "YES", deletionRule: "Cascade", syncable: "YES",
118
+ name: "authors", minCount: "1", maxCount: "-1", destinationEntity:
119
+ "Author", inverseName: "article", inverseEntity: "Author" }], e.relationships
120
+ end
121
+
108
122
  def test_non_inferrable_relationship_with_inverse
109
123
  e.belongs_to 'primary_author', inverse: 'Author.primary_articles'
110
124
  assert_equal [{ optional: "YES", deletionRule: "Nullify", syncable: "YES",
@@ -114,7 +128,7 @@ module XCDM
114
128
 
115
129
  def test_to_xml
116
130
  expected = REXML::Document.new %{
117
- <entity name="Article" representedClassName="Article" parentEntity="Publication" syncable="YES">
131
+ <entity name="Article" codeGenerationType='class' representedClassName="Article" parentEntity="Publication" syncable="YES">
118
132
  <attribute name="body" optional="NO" attributeType="String" syncable="YES"/>
119
133
  <attribute name="length" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
120
134
  <attribute name="published" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
@@ -135,7 +149,7 @@ module XCDM
135
149
  assert_equal expected.to_s.strip, REXML::Document.new(e.to_xml).to_s.strip
136
150
 
137
151
  expected = REXML::Document.new %{
138
- <entity name="Publication" representedClassName="Publication" isAbstract="YES" syncable="YES">
152
+ <entity name="Publication" representedClassName="Publication" codeGenerationType='class' isAbstract="YES" syncable="YES">
139
153
  </entity>
140
154
  }
141
155
 
@@ -25,7 +25,7 @@ __END__
25
25
 
26
26
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
27
27
  <model name="" userDefinedModelVersionIdentifier="0.0.1" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="2061" systemVersion="12D78" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
28
- <entity name="Article" syncable="YES">
28
+ <entity name="Article" syncable="YES" codeGenerationType='class'>
29
29
  <attribute name="body" optional="YES" attributeType="String" syncable="YES"/>
30
30
  <attribute name="length" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
31
31
  <attribute name="published" optional="YES" attributeType="Boolean" syncable="YES"/>
@@ -33,7 +33,7 @@ __END__
33
33
  <attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
34
34
  <relationship name="author" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="Author" inverseName="articles" inverseEntity="Article" syncable="YES"/>
35
35
  </entity>
36
- <entity name="Author" syncable="YES">
36
+ <entity name="Author" syncable="YES" codeGenerationType='class'>
37
37
  <attribute name="fee" optional="YES" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
38
38
  <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
39
39
  <relationship name="articles" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="Article" inverseName="author" inverseEntity="Author" syncable="YES"/>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
2
  <model name="" userDefinedModelVersionIdentifier="0.0.1" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="2061" systemVersion="12D78" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
3
- <entity name="Article" representedClassName="Article" syncable="YES">
3
+ <entity codeGenerationType="class" name="Article" representedClassName="Article" syncable="YES">
4
4
  <attribute name="body" optional="NO" attributeType="String" syncable="YES"/>
5
5
  <attribute name="length" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
6
6
  <attribute name="published" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
@@ -8,7 +8,7 @@
8
8
  <attribute name="title" optional="NO" attributeType="String" syncable="YES"/>
9
9
  <relationship name="author" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="Author" inverseName="articles" inverseEntity="Author" syncable="YES"/>
10
10
  </entity>
11
- <entity name="Author" representedClassName="Author" syncable="YES">
11
+ <entity codeGenerationType="class" name="Author" representedClassName="Author" syncable="YES">
12
12
  <attribute name="fee" optional="YES" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
13
13
  <attribute name="name" optional="NO" attributeType="String" syncable="YES"/>
14
14
  <relationship name="articles" optional="YES" minCount="1" maxCount="-1" deletionRule="Nullify" destinationEntity="Article" inverseName="author" inverseEntity="Article" syncable="YES"/>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-xcdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-20 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder