odata 0.0.5 → 0.0.6

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: e6981ed111f758f019824c0616927692584ad31a
4
- data.tar.gz: 2f187e5ea95313d48ce325f752e59787624bb9a8
3
+ metadata.gz: 4d4292a0e518b0b7733528f80c2b5c2e9097fc80
4
+ data.tar.gz: ca790d90d9beb0d6deac504ec66bc563621a5fee
5
5
  SHA512:
6
- metadata.gz: e49a84b9757a07d297ac25606a0f92a0760bac242d07a2de0e0d404006382d93c256e08e5e983a72119c28d1f57322d541ee2fabd3e7d4c3a69e07d3d48f61b5
7
- data.tar.gz: 4a55c19eba6a3e609ffae47a24e737148992f98ab433fab36bdd9d285f876eb0c8b88bab54d94bd7cd881b88cd80fe7f2c434236c7b1b3ce8a3b5d63a48b656e
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
- "#{service_url}/#{model.odata_name}",
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
@@ -1,3 +1,3 @@
1
1
  module OData
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -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>
@@ -52,5 +52,6 @@ describe OData::Service do
52
52
 
53
53
  describe '#get' do
54
54
  it { expect(subject.get(::Examples::Product).size).to eq(11) }
55
+ it { expect(subject.get(::Examples::Product, {key: 0}).size).to eq(1) }
55
56
  end
56
57
  end
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.5
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