odata 0.5.7 → 0.5.8
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/properties/string.rb +6 -0
- data/lib/odata/query.rb +2 -1
- data/lib/odata/query/criteria.rb +3 -5
- data/lib/odata/service.rb +3 -1
- data/lib/odata/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/query_specs.yml +22 -18
- data/spec/odata/query/criteria_spec.rb +12 -2
- data/spec/odata/query_spec.rb +1 -1
- 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: c8fdea1fa3181e24c43f5f2121d48d6685df3780
|
4
|
+
data.tar.gz: 4eeda811bf149b107b23a540162041c025c9647d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 436b465b08302628869a881377446d3dcbef41d788c5be2052d4fa9741503d7198959010ab956e0a81685a15435e3e3f96375e27cdf4e959ee34824b0476c41a
|
7
|
+
data.tar.gz: 8498c3425a1b3999857c863dc211d5f5c0aaceb69598cd025456cb15c9c7b485e065524e6e86182c8dfbfe4645ead9e33a0e7d7e2d3ec2a7b6e16d4e8426ca9f
|
data/lib/odata/query.rb
CHANGED
@@ -14,7 +14,8 @@ module OData
|
|
14
14
|
# Instantiates an OData::Query::Criteria for the named property.
|
15
15
|
# @param property [to_s]
|
16
16
|
def [](property)
|
17
|
-
|
17
|
+
property_instance = @entity_set.new_entity.send(:properties)[property.to_s]
|
18
|
+
OData::Query::Criteria.new(property: property_instance)
|
18
19
|
end
|
19
20
|
|
20
21
|
# Adds a filter criteria to the query.
|
data/lib/odata/query/criteria.rb
CHANGED
@@ -62,20 +62,18 @@ module OData
|
|
62
62
|
|
63
63
|
# Returns criteria as query-ready string.
|
64
64
|
def to_s
|
65
|
-
"#{property} #{operator} #{
|
65
|
+
"#{property.name} #{operator} #{property.url_value}"
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def set_operator_and_value(operator, value)
|
71
|
+
property.value = value
|
72
|
+
|
71
73
|
@operator = operator
|
72
74
|
@value = value
|
73
75
|
self
|
74
76
|
end
|
75
|
-
|
76
|
-
def value_for_string
|
77
|
-
value.is_a?(String) ? "#{value}" : value
|
78
|
-
end
|
79
77
|
end
|
80
78
|
end
|
81
79
|
end
|
data/lib/odata/service.rb
CHANGED
data/lib/odata/version.rb
CHANGED
@@ -9,6 +9,8 @@ http_interactions:
|
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
11
|
- Typhoeus - https://github.com/typhoeus/typhoeus
|
12
|
+
DataServiceVersion:
|
13
|
+
- '3.0'
|
12
14
|
response:
|
13
15
|
status:
|
14
16
|
code: 200
|
@@ -39,9 +41,9 @@ http_interactions:
|
|
39
41
|
Access-Control-Expose-Headers:
|
40
42
|
- DataServiceVersion
|
41
43
|
Set-Cookie:
|
42
|
-
- ARRAffinity=
|
44
|
+
- ARRAffinity=cb44902b614a02a3a0dc1bccc3de360d89b180ff17e14b11fd9b289a8de75827;Path=/;Domain=services.odata.org
|
43
45
|
Date:
|
44
|
-
-
|
46
|
+
- Mon, 29 Sep 2014 04:25:33 GMT
|
45
47
|
body:
|
46
48
|
encoding: UTF-8
|
47
49
|
string: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"><edmx:DataServices
|
@@ -160,7 +162,7 @@ http_interactions:
|
|
160
162
|
http_version: '1.1'
|
161
163
|
adapter_metadata:
|
162
164
|
effective_url: http://services.odata.org/OData/OData.svc/$metadata
|
163
|
-
recorded_at:
|
165
|
+
recorded_at: Mon, 29 Sep 2014 04:25:33 GMT
|
164
166
|
- request:
|
165
167
|
method: get
|
166
168
|
uri: http://services.odata.org/OData/OData.svc/Products
|
@@ -170,6 +172,8 @@ http_interactions:
|
|
170
172
|
headers:
|
171
173
|
User-Agent:
|
172
174
|
- Typhoeus - https://github.com/typhoeus/typhoeus
|
175
|
+
DataServiceVersion:
|
176
|
+
- '3.0'
|
173
177
|
response:
|
174
178
|
status:
|
175
179
|
code: 200
|
@@ -200,16 +204,16 @@ http_interactions:
|
|
200
204
|
Access-Control-Expose-Headers:
|
201
205
|
- DataServiceVersion
|
202
206
|
Set-Cookie:
|
203
|
-
- ARRAffinity=
|
207
|
+
- ARRAffinity=cb44902b614a02a3a0dc1bccc3de360d89b180ff17e14b11fd9b289a8de75827;Path=/;Domain=services.odata.org
|
204
208
|
Date:
|
205
|
-
-
|
209
|
+
- Mon, 29 Sep 2014 04:25:33 GMT
|
206
210
|
body:
|
207
211
|
encoding: UTF-8
|
208
212
|
string: <?xml version="1.0" encoding="utf-8"?><feed xml:base="http://services.odata.org/OData/OData.svc/"
|
209
213
|
xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
|
210
214
|
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss"
|
211
215
|
xmlns:gml="http://www.opengis.net/gml"><id>http://services.odata.org/OData/OData.svc/Products</id><title
|
212
|
-
type="text">Products</title><updated>2014-
|
216
|
+
type="text">Products</title><updated>2014-09-29T04:25:33Z</updated><link rel="self"
|
213
217
|
title="Products" href="Products" /><entry><id>http://services.odata.org/OData/OData.svc/Products(0)</id><category
|
214
218
|
term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"
|
215
219
|
/><link rel="edit" title="Product" href="Products(0)" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
|
@@ -218,7 +222,7 @@ http_interactions:
|
|
218
222
|
type="application/atom+xml;type=entry" title="Supplier" href="Products(0)/Supplier"
|
219
223
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
220
224
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(0)/ProductDetail"
|
221
|
-
/><title type="text">Bread</title><summary type="text">Whole grain bread</summary><updated>2014-
|
225
|
+
/><title type="text">Bread</title><summary type="text">Whole grain bread</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
222
226
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
223
227
|
type="application/xml" title="Categories" href="Products(0)/$links/Categories"
|
224
228
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -235,7 +239,7 @@ http_interactions:
|
|
235
239
|
type="application/atom+xml;type=entry" title="Supplier" href="Products(1)/Supplier"
|
236
240
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
237
241
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(1)/ProductDetail"
|
238
|
-
/><title type="text">Milk</title><summary type="text">Low fat milk</summary><updated>2014-
|
242
|
+
/><title type="text">Milk</title><summary type="text">Low fat milk</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
239
243
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
240
244
|
type="application/xml" title="Categories" href="Products(1)/$links/Categories"
|
241
245
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -253,7 +257,7 @@ http_interactions:
|
|
253
257
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
254
258
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(2)/ProductDetail"
|
255
259
|
/><title type="text">Vint soda</title><summary type="text">Americana Variety
|
256
|
-
- Mix of 6 flavors</summary><updated>2014-
|
260
|
+
- Mix of 6 flavors</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
257
261
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
258
262
|
type="application/xml" title="Categories" href="Products(2)/$links/Categories"
|
259
263
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -271,7 +275,7 @@ http_interactions:
|
|
271
275
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
272
276
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(3)/ProductDetail"
|
273
277
|
/><title type="text">Havina Cola</title><summary type="text">The Original
|
274
|
-
Key Lime Cola</summary><updated>2014-
|
278
|
+
Key Lime Cola</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
275
279
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
276
280
|
type="application/xml" title="Categories" href="Products(3)/$links/Categories"
|
277
281
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -290,7 +294,7 @@ http_interactions:
|
|
290
294
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
291
295
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(4)/ProductDetail"
|
292
296
|
/><title type="text">Fruit Punch</title><summary type="text">Mango flavor,
|
293
|
-
8.3 Ounce Cans (Pack of 24)</summary><updated>2014-
|
297
|
+
8.3 Ounce Cans (Pack of 24)</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
294
298
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
295
299
|
type="application/xml" title="Categories" href="Products(4)/$links/Categories"
|
296
300
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -308,7 +312,7 @@ http_interactions:
|
|
308
312
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
309
313
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(5)/ProductDetail"
|
310
314
|
/><title type="text">Cranberry Juice</title><summary type="text">16-Ounce
|
311
|
-
Plastic Bottles (Pack of 12)</summary><updated>2014-
|
315
|
+
Plastic Bottles (Pack of 12)</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
312
316
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
313
317
|
type="application/xml" title="Categories" href="Products(5)/$links/Categories"
|
314
318
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -326,7 +330,7 @@ http_interactions:
|
|
326
330
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
327
331
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(6)/ProductDetail"
|
328
332
|
/><title type="text">Pink Lemonade</title><summary type="text">36 Ounce Cans
|
329
|
-
(Pack of 3)</summary><updated>2014-
|
333
|
+
(Pack of 3)</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
330
334
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
331
335
|
type="application/xml" title="Categories" href="Products(6)/$links/Categories"
|
332
336
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -344,7 +348,7 @@ http_interactions:
|
|
344
348
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
345
349
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(7)/ProductDetail"
|
346
350
|
/><title type="text">DVD Player</title><summary type="text">1080P Upconversion
|
347
|
-
DVD Player</summary><updated>2014-
|
351
|
+
DVD Player</summary><updated>2014-09-29T04:25:33Z</updated><author><name /></author><link
|
348
352
|
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
349
353
|
type="application/xml" title="Categories" href="Products(7)/$links/Categories"
|
350
354
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -362,7 +366,7 @@ http_interactions:
|
|
362
366
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
|
363
367
|
type="application/atom+xml;type=entry" title="ProductDetail" href="Products(8)/ProductDetail"
|
364
368
|
/><title type="text">LCD HDTV</title><summary type="text">42 inch 1080p LCD
|
365
|
-
with Built-in Blu-ray Disc Player</summary><updated>2014-
|
369
|
+
with Built-in Blu-ray Disc Player</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
366
370
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
367
371
|
type="application/xml" title="Categories" href="Products(8)/$links/Categories"
|
368
372
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -383,7 +387,7 @@ http_interactions:
|
|
383
387
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Advertisement"
|
384
388
|
type="application/atom+xml;type=entry" title="Advertisement" href="Products(9)/ODataDemo.FeaturedProduct/Advertisement"
|
385
389
|
/><title type="text">Lemonade</title><summary type="text">Classic, refreshing
|
386
|
-
lemonade (Single bottle)</summary><updated>2014-
|
390
|
+
lemonade (Single bottle)</summary><updated>2014-09-29T04:25:33Z</updated><author><name
|
387
391
|
/></author><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
388
392
|
type="application/xml" title="Categories" href="Products(9)/ODataDemo.FeaturedProduct/$links/Categories"
|
389
393
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -406,7 +410,7 @@ http_interactions:
|
|
406
410
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Advertisement"
|
407
411
|
type="application/atom+xml;type=entry" title="Advertisement" href="Products(10)/ODataDemo.FeaturedProduct/Advertisement"
|
408
412
|
/><title type="text">Coffee</title><summary type="text">Bulk size can of instant
|
409
|
-
coffee</summary><updated>2014-
|
413
|
+
coffee</summary><updated>2014-09-29T04:25:33Z</updated><author><name /></author><link
|
410
414
|
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories"
|
411
415
|
type="application/xml" title="Categories" href="Products(10)/ODataDemo.FeaturedProduct/$links/Categories"
|
412
416
|
/><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier"
|
@@ -421,5 +425,5 @@ http_interactions:
|
|
421
425
|
http_version: '1.1'
|
422
426
|
adapter_metadata:
|
423
427
|
effective_url: http://services.odata.org/OData/OData.svc/Products
|
424
|
-
recorded_at:
|
428
|
+
recorded_at: Mon, 29 Sep 2014 04:25:33 GMT
|
425
429
|
recorded_with: VCR 2.9.2
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OData::Query::Criteria do
|
4
|
-
let(:
|
4
|
+
let(:string_property) { OData::Properties::String.new(:Name, nil) }
|
5
|
+
let(:integer_property) { OData::Properties::Integer.new(:Name, nil) }
|
6
|
+
let(:subject) { OData::Query::Criteria.new(property: string_property) }
|
5
7
|
|
6
8
|
it { expect(subject).to respond_to(:property) }
|
7
|
-
it { expect(subject.property).to eq(
|
9
|
+
it { expect(subject.property).to eq(string_property)}
|
8
10
|
|
9
11
|
it { expect(subject).to respond_to(:operator) }
|
10
12
|
it { expect(subject).to respond_to(:value) }
|
@@ -35,6 +37,8 @@ describe OData::Query::Criteria do
|
|
35
37
|
end
|
36
38
|
|
37
39
|
it '#gt sets up criteria properly' do
|
40
|
+
subject = OData::Query::Criteria.new(property: integer_property)
|
41
|
+
|
38
42
|
criteria = subject.gt(5)
|
39
43
|
expect(criteria).to eq(subject)
|
40
44
|
expect(criteria.operator).to eq(:gt)
|
@@ -43,6 +47,8 @@ describe OData::Query::Criteria do
|
|
43
47
|
end
|
44
48
|
|
45
49
|
it '#ge sets up criteria properly' do
|
50
|
+
subject = OData::Query::Criteria.new(property: integer_property)
|
51
|
+
|
46
52
|
criteria = subject.ge(5)
|
47
53
|
expect(criteria).to eq(subject)
|
48
54
|
expect(criteria.operator).to eq(:ge)
|
@@ -51,6 +57,8 @@ describe OData::Query::Criteria do
|
|
51
57
|
end
|
52
58
|
|
53
59
|
it '#lt sets up criteria properly' do
|
60
|
+
subject = OData::Query::Criteria.new(property: integer_property)
|
61
|
+
|
54
62
|
criteria = subject.lt(5)
|
55
63
|
expect(criteria).to eq(subject)
|
56
64
|
expect(criteria.operator).to eq(:lt)
|
@@ -59,6 +67,8 @@ describe OData::Query::Criteria do
|
|
59
67
|
end
|
60
68
|
|
61
69
|
it '#le sets up criteria properly' do
|
70
|
+
subject = OData::Query::Criteria.new(property: integer_property)
|
71
|
+
|
62
72
|
criteria = subject.le(5)
|
63
73
|
expect(criteria).to eq(subject)
|
64
74
|
expect(criteria.operator).to eq(:le)
|
data/spec/odata/query_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe OData::Query, vcr: {cassette_name: 'query_specs'} do
|
|
18
18
|
it { expect(subject).to respond_to(:[]) }
|
19
19
|
describe '#[]' do
|
20
20
|
it { expect(subject[:Name]).to be_a(OData::Query::Criteria) }
|
21
|
-
it { expect(subject[:Name].property).to
|
21
|
+
it { expect(subject[:Name].property).to be_a(OData::Property) }
|
22
22
|
end
|
23
23
|
|
24
24
|
it { expect(subject).to respond_to(:where) }
|
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.5.
|
4
|
+
version: 0.5.8
|
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-09-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|