representable 1.7.3 → 1.7.4

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: d73d9f923aac538f7a199d7c1f7c3f2e93de49fe
4
- data.tar.gz: dd4330ac4acfef6810635ed20dc31e0a9752b445
3
+ metadata.gz: b9f91b5b5cb8555b93015a366704fe19f4da5009
4
+ data.tar.gz: 045d56ac5c0a9fc165856f3886e5984f95fef452
5
5
  SHA512:
6
- metadata.gz: 8bd96f1c18ed6c3fc0d191cbb64a76b5163d81d40f98f4a0a8631697fee4cc9685f7448a48f6ed2a01a3f1f1905570d7cf9cb09980257c220f1c84b5f046d6ac
7
- data.tar.gz: 7a40442475d412225a7009b411359c90be019d5c6fa6163f9cbb75bb548f0fc90d0694ace4fabe293a59ae7af473cd1ebd80b97dcab30c931962a3b2c3e44ba1
6
+ metadata.gz: e5eb71ab3db99396efbf0804c3612afa380eec0deee5f67697985d560852f0701efad8ab69fd99cf022b9b45b8c7ece5c7707dd60ba00a9dfc7451832aa67727
7
+ data.tar.gz: 9acf292ac0687fcb3316a8cecf0f34ea2497664ab354424c1de73462c2458af3d69e8737f07815eee0df31e8702fb13ffce87525a622501842c4074b417b6990
data/CHANGES.md CHANGED
@@ -1,4 +1,17 @@
1
- h2. 17.3
1
+ h2. 1.8.0
2
+
3
+ * Major API change: Remove defaults for collections. This fixes a major design flaw - when parsing a document a collection would be reset to `[]` even if it is not present in the parsed document.
4
+ * Minor API change: Rename `Definition#sought_type` to `#deserialize_class`.
5
+ -> constantize :class etc (requires AS)
6
+ -> make all options lambda-able
7
+ -> make major steps lambda-able
8
+ -> strategies for deserialization (lambda-able!)
9
+
10
+ h2. 1.7.4
11
+
12
+ * propagate all options for ::property to ::inline_representer.
13
+
14
+ h2. 1.7.3
2
15
 
3
16
  * Fix segfaulting with XML by passing the document to nested objects. Reported by @timoschilling and fixed by @canadaduane.
4
17
 
@@ -128,7 +128,7 @@ module Representable
128
128
  end
129
129
 
130
130
  def class_from(fragment, *args)
131
- call_proc_for(sought_type, fragment)
131
+ call_proc_for(deserialize_class, fragment)
132
132
  end
133
133
 
134
134
  def instance_for(fragment, *args)
@@ -7,8 +7,6 @@ module Representable
7
7
  def initialize(sym, options={})
8
8
  @name = sym.to_s
9
9
  @options = options
10
-
11
- @options[:default] ||= [] if array? # FIXME: move to CollectionBinding!
12
10
  end
13
11
 
14
12
  def clone
@@ -20,7 +18,7 @@ module Representable
20
18
  end
21
19
 
22
20
  def typed?
23
- sought_type.is_a?(Class) or representer_module or options[:instance] # also true if only :extend is set, for people who want solely rendering.
21
+ deserialize_class.is_a?(Class) or representer_module or options[:instance] # also true if only :extend is set, for people who want solely rendering.
24
22
  end
25
23
 
26
24
  def array?
@@ -31,7 +29,7 @@ module Representable
31
29
  options[:hash]
32
30
  end
33
31
 
34
- def sought_type
32
+ def deserialize_class
35
33
  options[:class]
36
34
  end
37
35
 
@@ -1,3 +1,3 @@
1
1
  module Representable
2
- VERSION = "1.7.3"
2
+ VERSION = "1.7.4"
3
3
  end
@@ -43,8 +43,8 @@ class DefinitionTest < MiniTest::Spec
43
43
  assert_equal :"songs=", @def.setter
44
44
  end
45
45
 
46
- it "responds to #sought_type" do
47
- assert_equal nil, @def.sought_type
46
+ it "responds to #deserialize_class" do
47
+ assert_equal nil, @def.deserialize_class
48
48
  end
49
49
 
50
50
  describe "#clone" do
@@ -67,11 +67,6 @@ class DefinitionTest < MiniTest::Spec
67
67
  it "returns true if :default set" do
68
68
  assert_equal true, Representable::Definition.new(:song, :default => nil).has_default?
69
69
  end
70
-
71
- it "returns true if :collection" do
72
- assert_equal true, Representable::Definition.new(:songs, :collection => true).has_default?
73
- end
74
-
75
70
  end
76
71
 
77
72
 
@@ -208,12 +203,12 @@ class DefinitionTest < MiniTest::Spec
208
203
  assert @def.array?
209
204
  end
210
205
 
211
- it "responds to #sought_type" do
212
- assert_equal nil, @def.sought_type
206
+ it "responds to #deserialize_class" do
207
+ assert_equal nil, @def.deserialize_class
213
208
  end
214
209
 
215
210
  it "responds to #default" do
216
- assert_equal [], @def.send(:default)
211
+ assert_equal nil, @def.send(:default)
217
212
  end
218
213
  end
219
214
 
@@ -222,8 +217,8 @@ class DefinitionTest < MiniTest::Spec
222
217
  @def = Representable::Definition.new(:songs, :class => Hash)
223
218
  end
224
219
 
225
- it "responds to #sought_type" do
226
- assert_equal Hash, @def.sought_type
220
+ it "responds to #deserialize_class" do
221
+ assert_equal Hash, @def.deserialize_class
227
222
  end
228
223
  end
229
224
 
@@ -13,14 +13,15 @@ class GenericTest < MiniTest::Spec
13
13
  collection :songs
14
14
  end
15
15
 
16
- it "initializes property with empty array" do
16
+ it "doesn't initialize property" do
17
17
  new_album.from_hash({})
18
- new_album.songs.must_equal [] # DISCUSS: do we really want this?
18
+ new_album.songs.must_equal nil
19
19
  end
20
20
 
21
- it "overrides property with empty array" do
21
+ it "leaves properties untouched" do
22
22
  album.from_hash({})
23
- album.songs.must_equal [] # DISCUSS: do we really want this?
23
+ # TODO: test property.
24
+ album.songs.must_equal ["Fuck Armageddon"] # DISCUSS: do we really want this?
24
25
  end
25
26
  end
26
27
 
@@ -189,7 +190,6 @@ class GenericTest < MiniTest::Spec
189
190
  end
190
191
  end
191
192
 
192
-
193
193
  describe "mix :extend and inline representers" do
194
194
  representer! do
195
195
  rpr_module = Module.new do
@@ -392,11 +392,6 @@ end
392
392
  {:name => "Diesel Boy"}]}.to_json)
393
393
  assert_equal ["Cobra Skulls", "Diesel Boy"], cd.bands.map(&:name).sort
394
394
  end
395
-
396
- it "creates emtpy array from default if configured" do
397
- cd = Compilation.from_json("{}")
398
- assert_equal [], cd.bands
399
- end
400
395
  end
401
396
 
402
397
  it "responds to #to_json" do
@@ -310,14 +310,6 @@ class CollectionTest < MiniTest::Spec
310
310
  })
311
311
  assert_equal ["Cobra Skulls", "Diesel Boy"], cd.bands.map(&:name).sort
312
312
  end
313
-
314
- it "collections can be empty when default set" do
315
- cd = Compilation.from_xml(%{
316
- <compilation>
317
- </compilation>
318
- })
319
- assert_equal [], cd.bands
320
- end
321
313
  end
322
314
 
323
315
  it "responds to #to_xml" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: representable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-25 00:00:00.000000000 Z
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri