occi 2.5.12 → 2.5.13
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.
- data/lib/occi/core/entity.rb +4 -0
- data/lib/occi/core/link.rb +1 -1
- data/lib/occi/parser.rb +19 -2
- data/lib/occi/version.rb +1 -1
- metadata +2 -2
    
        data/lib/occi/core/entity.rb
    CHANGED
    
    
    
        data/lib/occi/core/link.rb
    CHANGED
    
    | @@ -77,7 +77,7 @@ module OCCI | |
| 77 77 | 
             
                  def as_json(options={ })
         | 
| 78 78 | 
             
                    link = super
         | 
| 79 79 | 
             
                    link.rel = @rel if @rel
         | 
| 80 | 
            -
                    link.source = self.source.to_s if self.source. | 
| 80 | 
            +
                    link.source = self.source.to_s if self.source.to_s
         | 
| 81 81 | 
             
                    link.target = self.target.to_s if self.target
         | 
| 82 82 | 
             
                    link
         | 
| 83 83 | 
             
                  end
         | 
    
        data/lib/occi/parser.rb
    CHANGED
    
    | @@ -190,11 +190,28 @@ module OCCI | |
| 190 190 | 
             
                # @return [OCCI::Collection]
         | 
| 191 191 | 
             
                def self.json(json)
         | 
| 192 192 | 
             
                  collection = OCCI::Collection.new
         | 
| 193 | 
            -
                  hash | 
| 193 | 
            +
                  hash = Hashie::Mash.new(JSON.parse(json))
         | 
| 194 194 | 
             
                  collection.kinds.concat hash.kinds.collect { |kind| OCCI::Core::Kind.new(kind.scheme, kind.term, kind.title, kind.attributes, kind.related, kind.actions) } if hash.kinds
         | 
| 195 195 | 
             
                  collection.mixins.concat hash.mixins.collect { |mixin| OCCI::Core::Mixin.new(mixin.scheme, mixin.term, mixin.title, mixin.attributes, mixin.related, mixin.actions) } if hash.mixins
         | 
| 196 | 
            +
                  collection.actions.concat hash.actions.collect { |action| OCCI::Core::Action.new(action.scheme, action.term, action.title, action.attributes) } if hash.actions
         | 
| 196 197 | 
             
                  collection.resources.concat hash.resources.collect { |resource| OCCI::Core::Resource.new(resource.kind, resource.mixins, resource.attributes, resource.actions, resource.links) } if hash.resources
         | 
| 197 | 
            -
                  collection.links.concat hash.links.collect { |link| OCCI::Core::Link.new(link.kind, link.mixins, link.attributes) } if hash.links
         | 
| 198 | 
            +
                  collection.links.concat hash.links.collect { |link| OCCI::Core::Link.new(link.kind, link.mixins, link.attributes, [], nil, link.target) } if hash.links
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                  if collection.resources.size == 1 && collection.links.size > 0
         | 
| 201 | 
            +
                    if collection.resources.first.links.empty?
         | 
| 202 | 
            +
                      collection.links.each { |link| link.source = collection.resources.first }
         | 
| 203 | 
            +
                      collection.resources.first.links = collection.links
         | 
| 204 | 
            +
                    end
         | 
| 205 | 
            +
                  end
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                  # TODO: replace the following mechanism with one in the Links class
         | 
| 208 | 
            +
                  # replace link locations with link objects in all resources
         | 
| 209 | 
            +
                  collection.resources.each do |resource|
         | 
| 210 | 
            +
                    resource.links.collect! do |resource_link|
         | 
| 211 | 
            +
                      lnk = collection.links.select { |link| resource_link == link.to_s }.first
         | 
| 212 | 
            +
                      lnk ||= resource_link
         | 
| 213 | 
            +
                    end
         | 
| 214 | 
            +
                  end
         | 
| 198 215 | 
             
                  collection
         | 
| 199 216 | 
             
                end
         | 
| 200 217 |  | 
    
        data/lib/occi/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: occi
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.5. | 
| 4 | 
            +
              version: 2.5.13
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date:  | 
| 13 | 
            +
            date: 2013-01-03 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: json
         |