odata 0.0.5 → 0.0.6
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/lib/odata/service.rb +8 -2
- data/lib/odata/version.rb +1 -1
- data/spec/fixtures/sample_service/product_0.xml +36 -0
- data/spec/odata/service_spec.rb +1 -0
- data/spec/spec_helper.rb +3 -0
- metadata +3 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4d4292a0e518b0b7733528f80c2b5c2e9097fc80
         | 
| 4 | 
            +
              data.tar.gz: ca790d90d9beb0d6deac504ec66bc563621a5fee
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: af023f47d0d372cf7c3c85cc0cdaef18eca711381e22dd3aa2ebf222b26b4faef3fc6a3d522307dc3577e863fd366d212c749d201157ae28ba1f1307e299a5a7
         | 
| 7 | 
            +
              data.tar.gz: e5837bc7f3a012fd7c94c66f7d9774e90e684f0a7f3d1be93e96c8d0a8e489cb548e4d6f4b4ca9e2ae9dfe9ba0752636a8052c7ede9b00d2b716c85d3d701cc3
         | 
    
        data/lib/odata/service.rb
    CHANGED
    
    | @@ -28,9 +28,9 @@ module OData | |
| 28 28 | 
             
                  "#<#{self.class.name}:#{self.object_id} namespace='#{self.namespace}' service_url='#{self.service_url}'>"
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 | 
            -
                def get(model)
         | 
| 31 | 
            +
                def get(model, criteria = {})
         | 
| 32 32 | 
             
                  request = ::Typhoeus::Request.new(
         | 
| 33 | 
            -
                       | 
| 33 | 
            +
                      build_request_url(model, criteria),
         | 
| 34 34 | 
             
                      method: :get
         | 
| 35 35 | 
             
                  )
         | 
| 36 36 | 
             
                  request.run
         | 
| @@ -52,5 +52,11 @@ module OData | |
| 52 52 | 
             
                    ::Nokogiri::XML(response.body).remove_namespaces!
         | 
| 53 53 | 
             
                  }.call
         | 
| 54 54 | 
             
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def build_request_url(model, criteria)
         | 
| 57 | 
            +
                  request_url = "#{service_url}/#{model.odata_name}"
         | 
| 58 | 
            +
                  request_url += "(#{criteria[:key]})" if criteria[:key]
         | 
| 59 | 
            +
                  request_url
         | 
| 60 | 
            +
                end
         | 
| 55 61 | 
             
              end
         | 
| 56 62 | 
             
            end
         | 
    
        data/lib/odata/version.rb
    CHANGED
    
    
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            <?xml version="1.0" encoding="utf-8"?>
         | 
| 2 | 
            +
            <entry xml:base="http://services.odata.org/OData/OData.svc/" xmlns="http://www.w3.org/2005/Atom"
         | 
| 3 | 
            +
                   xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
         | 
| 4 | 
            +
                   xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
         | 
| 5 | 
            +
                   xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
         | 
| 6 | 
            +
              <id>http://services.odata.org/OData/OData.svc/Products(0)</id>
         | 
| 7 | 
            +
              <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
         | 
| 8 | 
            +
              <link rel="edit" title="Product" href="Products(0)"/>
         | 
| 9 | 
            +
              <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
         | 
| 10 | 
            +
                    type="application/atom+xml;type=feed" title="Categories" href="Products(0)/Categories"/>
         | 
| 11 | 
            +
              <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
         | 
| 12 | 
            +
                    type="application/atom+xml;type=entry" title="Supplier" href="Products(0)/Supplier"/>
         | 
| 13 | 
            +
              <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
         | 
| 14 | 
            +
                    type="application/atom+xml;type=entry" title="ProductDetail" href="Products(0)/ProductDetail"/>
         | 
| 15 | 
            +
              <title type="text">Bread</title>
         | 
| 16 | 
            +
              <summary type="text">Whole grain bread</summary>
         | 
| 17 | 
            +
              <updated>2014-06-20T07:16:24Z</updated>
         | 
| 18 | 
            +
              <author>
         | 
| 19 | 
            +
                <name/>
         | 
| 20 | 
            +
              </author>
         | 
| 21 | 
            +
              <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
         | 
| 22 | 
            +
                    title="Categories" href="Products(0)/$links/Categories"/>
         | 
| 23 | 
            +
              <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
         | 
| 24 | 
            +
                    title="Supplier" href="Products(0)/$links/Supplier"/>
         | 
| 25 | 
            +
              <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
         | 
| 26 | 
            +
                    title="ProductDetail" href="Products(0)/$links/ProductDetail"/>
         | 
| 27 | 
            +
              <content type="application/xml">
         | 
| 28 | 
            +
                <m:properties>
         | 
| 29 | 
            +
                  <d:ID m:type="Edm.Int32">0</d:ID>
         | 
| 30 | 
            +
                  <d:ReleaseDate m:type="Edm.DateTime">1992-01-01T00:00:00</d:ReleaseDate>
         | 
| 31 | 
            +
                  <d:DiscontinuedDate m:null="true"/>
         | 
| 32 | 
            +
                  <d:Rating m:type="Edm.Int16">4</d:Rating>
         | 
| 33 | 
            +
                  <d:Price m:type="Edm.Double">2.5</d:Price>
         | 
| 34 | 
            +
                </m:properties>
         | 
| 35 | 
            +
              </content>
         | 
| 36 | 
            +
            </entry>
         | 
    
        data/spec/odata/service_spec.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -37,5 +37,8 @@ RSpec.configure do |config| | |
| 37 37 |  | 
| 38 38 | 
             
                WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products').
         | 
| 39 39 | 
             
                    to_return(status: 200, body: File.open('spec/fixtures/sample_service/products.xml'))
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products(0)').
         | 
| 42 | 
            +
                    to_return(status: 200, body: File.open('spec/fixtures/sample_service/product_0.xml'))
         | 
| 40 43 | 
             
              end
         | 
| 41 44 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: odata
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - James Thompson
         | 
| @@ -160,6 +160,7 @@ files: | |
| 160 160 | 
             
            - odata.gemspec
         | 
| 161 161 | 
             
            - spec/examples/product_model.rb
         | 
| 162 162 | 
             
            - spec/fixtures/sample_service/metadata.xml
         | 
| 163 | 
            +
            - spec/fixtures/sample_service/product_0.xml
         | 
| 163 164 | 
             
            - spec/fixtures/sample_service/products.xml
         | 
| 164 165 | 
             
            - spec/odata/model_spec.rb
         | 
| 165 166 | 
             
            - spec/odata/service_registry_spec.rb
         | 
| @@ -192,6 +193,7 @@ summary: Simple OData library | |
| 192 193 | 
             
            test_files:
         | 
| 193 194 | 
             
            - spec/examples/product_model.rb
         | 
| 194 195 | 
             
            - spec/fixtures/sample_service/metadata.xml
         | 
| 196 | 
            +
            - spec/fixtures/sample_service/product_0.xml
         | 
| 195 197 | 
             
            - spec/fixtures/sample_service/products.xml
         | 
| 196 198 | 
             
            - spec/odata/model_spec.rb
         | 
| 197 199 | 
             
            - spec/odata/service_registry_spec.rb
         |