odata 0.2.0 → 0.3.0
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/CHANGELOG.md +9 -0
 - data/lib/odata.rb +3 -3
 - data/lib/odata/entity.rb +3 -3
 - data/lib/odata/property.rb +16 -0
 - data/lib/odata/service.rb +10 -1
 - data/lib/odata/version.rb +1 -1
 - data/odata.gemspec +0 -1
 - metadata +2 -16
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0edaeaf91c4af10ef3abbaec91c7694d889b0bc9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5cf9ba52511908d11fa2a7c091a1ee6ea335dc39
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7b898de7fad69b94bb1f3aa6aaaae8ed14089a38bd410f8e83e0984f34dad689c2fec27d38ea87fcdd656f13acff48a57491922b45336a69244d266200fb9adc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 73ac706f0686f81c9f8b61066b2feb8ae29824dc23946303167e7acaa00481b1d18a1c94a804e0c28b245fd144a76bb3297f761bebd4125f8ea8e2f5dfae7808
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # CHANGELOG
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## 0.3.0
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * Removed dependency on ActiveSupport
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## 0.2.0
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            * Added query interface for [System Query Options](http://www.odata.org/documentation/odata-version-3-0/odata-version-3-0-core-protocol#queryingcollections)
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Refactored internal uses of System Query Options
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       3 
12 
     | 
    
         
             
            ## 0.1.0
         
     | 
| 
       4 
13 
     | 
    
         | 
| 
       5 
14 
     | 
    
         
             
            * Core read/write behavior for OData v1-3
         
     | 
    
        data/lib/odata.rb
    CHANGED
    
    | 
         @@ -5,9 +5,9 @@ require 'date' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            require 'nokogiri'
         
     | 
| 
       6 
6 
     | 
    
         
             
            require 'typhoeus'
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            require 'active_support'
         
     | 
| 
       9 
     | 
    
         
            -
            require 'active_support/core_ext'
         
     | 
| 
       10 
     | 
    
         
            -
            require 'active_support/concern'
         
     | 
| 
      
 8 
     | 
    
         
            +
            # require 'active_support'
         
     | 
| 
      
 9 
     | 
    
         
            +
            # require 'active_support/core_ext'
         
     | 
| 
      
 10 
     | 
    
         
            +
            # require 'active_support/concern'
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            require 'odata/version'
         
     | 
| 
       13 
13 
     | 
    
         
             
            require 'odata/property'
         
     | 
    
        data/lib/odata/entity.rb
    CHANGED
    
    | 
         @@ -56,7 +56,7 @@ module OData 
     | 
|
| 
       56 
56 
     | 
    
         
             
                        value = property_xml.content
         
     | 
| 
       57 
57 
     | 
    
         
             
                      end
         
     | 
| 
       58 
58 
     | 
    
         
             
                      klass_name = value_type.gsub(/^Edm\./, '')
         
     | 
| 
       59 
     | 
    
         
            -
                      property = "OData::Properties::#{klass_name}". 
     | 
| 
      
 59 
     | 
    
         
            +
                      property = Kernel.const_get("OData::Properties::#{klass_name}").new(property_name, value)
         
     | 
| 
       60 
60 
     | 
    
         
             
                      set_property(property_name, property)
         
     | 
| 
       61 
61 
     | 
    
         
             
                    end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
         @@ -65,7 +65,7 @@ module OData 
     | 
|
| 
       65 
65 
     | 
    
         
             
                      property_name = service.get_title_property_name(name)
         
     | 
| 
       66 
66 
     | 
    
         
             
                      value_type = service.get_property_type(name, property_name)
         
     | 
| 
       67 
67 
     | 
    
         
             
                      klass_name = value_type.gsub(/^Edm\./, '')
         
     | 
| 
       68 
     | 
    
         
            -
                      property = "OData::Properties::#{klass_name}". 
     | 
| 
      
 68 
     | 
    
         
            +
                      property = Kernel.const_get("OData::Properties::#{klass_name}").new(property_name, title_value)
         
     | 
| 
       69 
69 
     | 
    
         
             
                      set_property(property_name, property)
         
     | 
| 
       70 
70 
     | 
    
         
             
                    end
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
         @@ -74,7 +74,7 @@ module OData 
     | 
|
| 
       74 
74 
     | 
    
         
             
                      property_name = service.get_summary_property_name(name)
         
     | 
| 
       75 
75 
     | 
    
         
             
                      value_type = service.get_property_type(name, property_name)
         
     | 
| 
       76 
76 
     | 
    
         
             
                      klass_name = value_type.gsub(/^Edm\./, '')
         
     | 
| 
       77 
     | 
    
         
            -
                      property = "OData::Properties::#{klass_name}". 
     | 
| 
      
 77 
     | 
    
         
            +
                      property = Kernel.const_get("OData::Properties::#{klass_name}").new(property_name, summary_value)
         
     | 
| 
       78 
78 
     | 
    
         
             
                      set_property(property_name, property)
         
     | 
| 
       79 
79 
     | 
    
         
             
                    end
         
     | 
| 
       80 
80 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/odata/property.rb
    CHANGED
    
    | 
         @@ -3,28 +3,44 @@ module OData 
     | 
|
| 
       3 
3 
     | 
    
         
             
                attr_reader :name
         
     | 
| 
       4 
4 
     | 
    
         
             
                attr_accessor :value
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
                # Default intialization for a property with a name, value and options.
         
     | 
| 
      
 7 
     | 
    
         
            +
                # @param name [to_s]
         
     | 
| 
      
 8 
     | 
    
         
            +
                # @param value [to_s,nil]
         
     | 
| 
      
 9 
     | 
    
         
            +
                # @param options [Hash]
         
     | 
| 
       6 
10 
     | 
    
         
             
                def initialize(name, value, options = {})
         
     | 
| 
       7 
11 
     | 
    
         
             
                  @name = name.to_s
         
     | 
| 
       8 
12 
     | 
    
         
             
                  @value = value.nil? ? nil : value.to_s
         
     | 
| 
       9 
13 
     | 
    
         
             
                  @options = default_options.merge(options)
         
     | 
| 
       10 
14 
     | 
    
         
             
                end
         
     | 
| 
       11 
15 
     | 
    
         | 
| 
      
 16 
     | 
    
         
            +
                # Abstract implementation, should return property type, based on
         
     | 
| 
      
 17 
     | 
    
         
            +
                # OData::Service metadata in proper implementation.
         
     | 
| 
      
 18 
     | 
    
         
            +
                # @raise NotImplementedError
         
     | 
| 
       12 
19 
     | 
    
         
             
                def type
         
     | 
| 
       13 
20 
     | 
    
         
             
                  raise NotImplementedError
         
     | 
| 
       14 
21 
     | 
    
         
             
                end
         
     | 
| 
       15 
22 
     | 
    
         | 
| 
      
 23 
     | 
    
         
            +
                # Provides for value-based equality checking.
         
     | 
| 
      
 24 
     | 
    
         
            +
                # @param other [value] object for comparison
         
     | 
| 
      
 25 
     | 
    
         
            +
                # @return [Boolean]
         
     | 
| 
       16 
26 
     | 
    
         
             
                def ==(other)
         
     | 
| 
       17 
27 
     | 
    
         
             
                  self.value == other.value
         
     | 
| 
       18 
28 
     | 
    
         
             
                end
         
     | 
| 
       19 
29 
     | 
    
         | 
| 
      
 30 
     | 
    
         
            +
                # Whether the property permits a nil value.
         
     | 
| 
      
 31 
     | 
    
         
            +
                # @return [Boolean]
         
     | 
| 
       20 
32 
     | 
    
         
             
                def allows_nil?
         
     | 
| 
       21 
33 
     | 
    
         
             
                  @allows_nil ||= options[:allows_nil]
         
     | 
| 
       22 
34 
     | 
    
         
             
                end
         
     | 
| 
       23 
35 
     | 
    
         | 
| 
      
 36 
     | 
    
         
            +
                # The configured concurrency mode for the property.
         
     | 
| 
      
 37 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
       24 
38 
     | 
    
         
             
                def concurrency_mode
         
     | 
| 
       25 
39 
     | 
    
         
             
                  @concurrecy_mode ||= options[:concurrency_mode]
         
     | 
| 
       26 
40 
     | 
    
         
             
                end
         
     | 
| 
       27 
41 
     | 
    
         | 
| 
      
 42 
     | 
    
         
            +
                # Value to be used in XML.
         
     | 
| 
      
 43 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
       28 
44 
     | 
    
         
             
                def xml_value
         
     | 
| 
       29 
45 
     | 
    
         
             
                  @value
         
     | 
| 
       30 
46 
     | 
    
         
             
                end
         
     | 
    
        data/lib/odata/service.rb
    CHANGED
    
    | 
         @@ -138,10 +138,19 @@ module OData 
     | 
|
| 
       138 
138 
     | 
    
         
             
                  metadata.xpath("//EntityType[@Name='#{entity_name}']/Property[@FC_TargetPath='SyndicationSummary']").first.attributes['Name'].value
         
     | 
| 
       139 
139 
     | 
    
         
             
                end
         
     | 
| 
       140 
140 
     | 
    
         | 
| 
      
 141 
     | 
    
         
            +
                # Get the primary key for the supplied Entity.
         
     | 
| 
      
 142 
     | 
    
         
            +
                #
         
     | 
| 
      
 143 
     | 
    
         
            +
                # @param entity_name [to_s]
         
     | 
| 
      
 144 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
       141 
145 
     | 
    
         
             
                def primary_key_for(entity_name)
         
     | 
| 
       142 
146 
     | 
    
         
             
                  metadata.xpath("//EntityType[@Name='#{entity_name}']/Key/PropertyRef").first.attributes['Name'].value
         
     | 
| 
       143 
147 
     | 
    
         
             
                end
         
     | 
| 
       144 
148 
     | 
    
         | 
| 
      
 149 
     | 
    
         
            +
                # Get the list of properties and their various options for the supplied
         
     | 
| 
      
 150 
     | 
    
         
            +
                # Entity name.
         
     | 
| 
      
 151 
     | 
    
         
            +
                #
         
     | 
| 
      
 152 
     | 
    
         
            +
                # @param entity_name [to_s]
         
     | 
| 
      
 153 
     | 
    
         
            +
                # @return [Hash]
         
     | 
| 
       145 
154 
     | 
    
         
             
                def properties_for(entity_name)
         
     | 
| 
       146 
155 
     | 
    
         
             
                  type_definition = metadata.xpath("//EntityType[@Name='#{entity_name}']").first
         
     | 
| 
       147 
156 
     | 
    
         
             
                  raise ArgumentError, "Unknown EntityType: #{entity_name}" if type_definition.nil?
         
     | 
| 
         @@ -152,7 +161,7 @@ module OData 
     | 
|
| 
       152 
161 
     | 
    
         
             
                    property_options = {}
         
     | 
| 
       153 
162 
     | 
    
         
             
                    property_options[:allows_nil] = false if property_xml.attributes['Nullable'] == 'false'
         
     | 
| 
       154 
163 
     | 
    
         
             
                    klass_name = value_type.gsub(/^Edm\./, '')
         
     | 
| 
       155 
     | 
    
         
            -
                    properties_to_return[property_name] = "OData::Properties::#{klass_name}". 
     | 
| 
      
 164 
     | 
    
         
            +
                    properties_to_return[property_name] = Kernel.const_get("OData::Properties::#{klass_name}").new(property_name, nil, property_options)
         
     | 
| 
       156 
165 
     | 
    
         
             
                  end
         
     | 
| 
       157 
166 
     | 
    
         
             
                  properties_to_return
         
     | 
| 
       158 
167 
     | 
    
         
             
                end
         
     | 
    
        data/lib/odata/version.rb
    CHANGED
    
    
    
        data/odata.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: odata
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - James Thompson
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-07- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-07-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -136,20 +136,6 @@ dependencies: 
     | 
|
| 
       136 
136 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       137 
137 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       138 
138 
     | 
    
         
             
                    version: 1.6.2
         
     | 
| 
       139 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       140 
     | 
    
         
            -
              name: activesupport
         
     | 
| 
       141 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       142 
     | 
    
         
            -
                requirements:
         
     | 
| 
       143 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       144 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       145 
     | 
    
         
            -
                    version: 3.0.0
         
     | 
| 
       146 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       147 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       148 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       149 
     | 
    
         
            -
                requirements:
         
     | 
| 
       150 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       151 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       152 
     | 
    
         
            -
                    version: 3.0.0
         
     | 
| 
       153 
139 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       154 
140 
     | 
    
         
             
              name: typhoeus
         
     | 
| 
       155 
141 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |