representable 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +14 -1
- data/lib/representable/binding.rb +1 -1
- data/lib/representable/definition.rb +2 -4
- data/lib/representable/version.rb +1 -1
- data/test/definition_test.rb +7 -12
- data/test/generic_test.rb +5 -5
- data/test/json_test.rb +0 -5
- data/test/xml_test.rb +0 -8
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b9f91b5b5cb8555b93015a366704fe19f4da5009
         | 
| 4 | 
            +
              data.tar.gz: 045d56ac5c0a9fc165856f3886e5984f95fef452
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e5eb71ab3db99396efbf0804c3612afa380eec0deee5f67697985d560852f0701efad8ab69fd99cf022b9b45b8c7ece5c7707dd60ba00a9dfc7451832aa67727
         | 
| 7 | 
            +
              data.tar.gz: 9acf292ac0687fcb3316a8cecf0f34ea2497664ab354424c1de73462c2458af3d69e8737f07815eee0df31e8702fb13ffce87525a622501842c4074b417b6990
         | 
    
        data/CHANGES.md
    CHANGED
    
    | @@ -1,4 +1,17 @@ | |
| 1 | 
            -
            h2.  | 
| 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 |  | 
| @@ -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 | 
            -
                   | 
| 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  | 
| 32 | 
            +
                def deserialize_class
         | 
| 35 33 | 
             
                  options[:class]
         | 
| 36 34 | 
             
                end
         | 
| 37 35 |  | 
    
        data/test/definition_test.rb
    CHANGED
    
    | @@ -43,8 +43,8 @@ class DefinitionTest < MiniTest::Spec | |
| 43 43 | 
             
                  assert_equal :"songs=", @def.setter
         | 
| 44 44 | 
             
                end
         | 
| 45 45 |  | 
| 46 | 
            -
                it "responds to # | 
| 47 | 
            -
                  assert_equal nil, @def. | 
| 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 # | 
| 212 | 
            -
                  assert_equal nil, @def. | 
| 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  | 
| 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 # | 
| 226 | 
            -
                  assert_equal Hash, @def. | 
| 220 | 
            +
                it "responds to #deserialize_class" do
         | 
| 221 | 
            +
                  assert_equal Hash, @def.deserialize_class
         | 
| 227 222 | 
             
                end
         | 
| 228 223 | 
             
              end
         | 
| 229 224 |  | 
    
        data/test/generic_test.rb
    CHANGED
    
    | @@ -13,14 +13,15 @@ class GenericTest < MiniTest::Spec | |
| 13 13 | 
             
                  collection :songs
         | 
| 14 14 | 
             
                end
         | 
| 15 15 |  | 
| 16 | 
            -
                it " | 
| 16 | 
            +
                it "doesn't initialize property" do
         | 
| 17 17 | 
             
                  new_album.from_hash({})
         | 
| 18 | 
            -
                  new_album.songs.must_equal  | 
| 18 | 
            +
                  new_album.songs.must_equal nil
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| 21 | 
            -
                it " | 
| 21 | 
            +
                it "leaves properties untouched" do
         | 
| 22 22 | 
             
                  album.from_hash({})
         | 
| 23 | 
            -
                   | 
| 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
         | 
    
        data/test/json_test.rb
    CHANGED
    
    | @@ -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
         | 
    
        data/test/xml_test.rb
    CHANGED
    
    | @@ -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. | 
| 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 | 
            +
            date: 2013-12-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: nokogiri
         |