odata4 0.8.0 → 0.8.1

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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odata4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Wagner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-10 00:00:00.000000000 Z
12
+ date: 2018-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -212,6 +212,7 @@ files:
212
212
  - lib/odata4/properties.rb
213
213
  - lib/odata4/properties/binary.rb
214
214
  - lib/odata4/properties/boolean.rb
215
+ - lib/odata4/properties/collection.rb
215
216
  - lib/odata4/properties/date.rb
216
217
  - lib/odata4/properties/date_time.rb
217
218
  - lib/odata4/properties/date_time_offset.rb
@@ -238,16 +239,20 @@ files:
238
239
  - lib/odata4/query/criteria/lambda_operators.rb
239
240
  - lib/odata4/query/criteria/string_functions.rb
240
241
  - lib/odata4/query/in_batches.rb
241
- - lib/odata4/query/result.rb
242
- - lib/odata4/query/result/atom.rb
243
- - lib/odata4/query/result/json.rb
244
242
  - lib/odata4/railtie.rb
245
243
  - lib/odata4/schema.rb
246
244
  - lib/odata4/service.rb
245
+ - lib/odata4/service/request.rb
246
+ - lib/odata4/service/response.rb
247
+ - lib/odata4/service/response/atom.rb
248
+ - lib/odata4/service/response/json.rb
249
+ - lib/odata4/service/response/plain.rb
250
+ - lib/odata4/service/response/xml.rb
247
251
  - lib/odata4/service_registry.rb
248
252
  - lib/odata4/version.rb
249
253
  - odata4.gemspec
250
254
  - spec/fixtures/files/entity_to_xml.xml
255
+ - spec/fixtures/files/error.xml
251
256
  - spec/fixtures/files/metadata.xml
252
257
  - spec/fixtures/files/product_0.json
253
258
  - spec/fixtures/files/product_0.xml
@@ -264,6 +269,7 @@ files:
264
269
  - spec/fixtures/vcr_cassettes/navigation_property_proxy_specs.yml
265
270
  - spec/fixtures/vcr_cassettes/query/result_specs.yml
266
271
  - spec/fixtures/vcr_cassettes/query_specs.yml
272
+ - spec/fixtures/vcr_cassettes/service/request_specs.yml
267
273
  - spec/fixtures/vcr_cassettes/service_registry_specs.yml
268
274
  - spec/fixtures/vcr_cassettes/service_specs.yml
269
275
  - spec/fixtures/vcr_cassettes/usage_example_specs.yml
@@ -277,6 +283,7 @@ files:
277
283
  - spec/odata4/navigation_property_spec.rb
278
284
  - spec/odata4/properties/binary_spec.rb
279
285
  - spec/odata4/properties/boolean_spec.rb
286
+ - spec/odata4/properties/collection_spec.rb
280
287
  - spec/odata4/properties/date_spec.rb
281
288
  - spec/odata4/properties/date_time_offset_spec.rb
282
289
  - spec/odata4/properties/date_time_spec.rb
@@ -294,9 +301,10 @@ files:
294
301
  - spec/odata4/property_registry_spec.rb
295
302
  - spec/odata4/property_spec.rb
296
303
  - spec/odata4/query/criteria_spec.rb
297
- - spec/odata4/query/result_spec.rb
298
304
  - spec/odata4/query_spec.rb
299
305
  - spec/odata4/schema_spec.rb
306
+ - spec/odata4/service/request_spec.rb
307
+ - spec/odata4/service/response_spec.rb
300
308
  - spec/odata4/service_registry_spec.rb
301
309
  - spec/odata4/service_spec.rb
302
310
  - spec/odata4/usage_example_spec.rb
@@ -329,6 +337,7 @@ specification_version: 4
329
337
  summary: Simple OData library
330
338
  test_files:
331
339
  - spec/fixtures/files/entity_to_xml.xml
340
+ - spec/fixtures/files/error.xml
332
341
  - spec/fixtures/files/metadata.xml
333
342
  - spec/fixtures/files/product_0.json
334
343
  - spec/fixtures/files/product_0.xml
@@ -345,6 +354,7 @@ test_files:
345
354
  - spec/fixtures/vcr_cassettes/navigation_property_proxy_specs.yml
346
355
  - spec/fixtures/vcr_cassettes/query/result_specs.yml
347
356
  - spec/fixtures/vcr_cassettes/query_specs.yml
357
+ - spec/fixtures/vcr_cassettes/service/request_specs.yml
348
358
  - spec/fixtures/vcr_cassettes/service_registry_specs.yml
349
359
  - spec/fixtures/vcr_cassettes/service_specs.yml
350
360
  - spec/fixtures/vcr_cassettes/usage_example_specs.yml
@@ -358,6 +368,7 @@ test_files:
358
368
  - spec/odata4/navigation_property_spec.rb
359
369
  - spec/odata4/properties/binary_spec.rb
360
370
  - spec/odata4/properties/boolean_spec.rb
371
+ - spec/odata4/properties/collection_spec.rb
361
372
  - spec/odata4/properties/date_spec.rb
362
373
  - spec/odata4/properties/date_time_offset_spec.rb
363
374
  - spec/odata4/properties/date_time_spec.rb
@@ -375,9 +386,10 @@ test_files:
375
386
  - spec/odata4/property_registry_spec.rb
376
387
  - spec/odata4/property_spec.rb
377
388
  - spec/odata4/query/criteria_spec.rb
378
- - spec/odata4/query/result_spec.rb
379
389
  - spec/odata4/query_spec.rb
380
390
  - spec/odata4/schema_spec.rb
391
+ - spec/odata4/service/request_spec.rb
392
+ - spec/odata4/service/response_spec.rb
381
393
  - spec/odata4/service_registry_spec.rb
382
394
  - spec/odata4/service_spec.rb
383
395
  - spec/odata4/usage_example_spec.rb
@@ -1,84 +0,0 @@
1
- module OData4
2
- class Query
3
- # Represents the results of executing a OData4::Query.
4
- # @api private
5
- class Result
6
- include Enumerable
7
-
8
- attr_reader :query
9
-
10
- # Initialize a result with the query and the result.
11
- # @param query [OData4::Query]
12
- # @param result [Typhoeus::Result]
13
- def initialize(query, result)
14
- @query = query
15
- @result = result
16
- check_result_type
17
- end
18
-
19
- # Provided for Enumerable functionality
20
- # @param block [block] a block to evaluate
21
- # @return [OData4::Entity] each entity in turn for the query result
22
- def each(&block)
23
- unless empty?
24
- process_results(&block)
25
- until next_page.nil?
26
- # ensure query gets executed with the same options
27
- result = query.execute(next_page_url)
28
- process_results(&block)
29
- end
30
- end
31
- end
32
-
33
- # Checks whether the result set contains any results
34
- # @return [Boolean]
35
- def empty?
36
- @empty_result ||= find_entities.empty?
37
- end
38
-
39
- private
40
-
41
- attr_accessor :result
42
-
43
- def check_result_type
44
- # Dynamically extend instance with methods for
45
- # processing the current result type
46
- if is_atom_result?
47
- extend OData4::Query::Result::Atom
48
- elsif is_json_result?
49
- extend OData4::Query::Result::JSON
50
- elsif result.body.empty?
51
- # Some services (*cough* Microsoft *cough*) return
52
- # an empty response with no `Content-Type` header set.
53
- # We catch that here and bypass content type detection.
54
- @empty_result = true
55
- else
56
- raise ArgumentError, "Invalid result type '#{content_type}'"
57
- end
58
- end
59
-
60
- def is_atom_result?
61
- content_type =~ /#{Regexp.escape OData4::Service::MIME_TYPES[:atom]}/
62
- end
63
-
64
- def is_json_result?
65
- content_type =~ /#{Regexp.escape OData4::Service::MIME_TYPES[:json]}/
66
- end
67
-
68
- def content_type
69
- result.headers['Content-Type'] || ''
70
- end
71
-
72
- def service
73
- query.entity_set.service
74
- end
75
-
76
- def entity_options
77
- query.entity_set.entity_options
78
- end
79
- end
80
- end
81
- end
82
-
83
- require 'odata4/query/result/atom'
84
- require 'odata4/query/result/json'
@@ -1,53 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples 'valid result' do
4
- it { expect(result.count).to eq(11) }
5
-
6
- describe '#empty?' do
7
- it { expect(result).to respond_to(:empty?) }
8
- it { expect(result.empty?).to eq(false) }
9
- end
10
-
11
- describe '#each' do
12
- it { expect(result).to respond_to(:each) }
13
- it 'returns just OData4::Entities of the right type' do
14
- result.each do |entity|
15
- expect(entity).to be_a(OData4::Entity)
16
- expect(entity.type).to eq('ODataDemo.Product')
17
- end
18
- end
19
- end
20
- end
21
-
22
- describe OData4::Query::Result, vcr: {cassette_name: 'query/result_specs'} do
23
- before(:example) do
24
- OData4::Service.open('http://services.odata.org/V4/OData/OData.svc', name: 'ODataDemo')
25
- end
26
-
27
- let(:entity_set) { OData4::ServiceRegistry['ODataDemo']['Products'] }
28
- # let(:subject) { entity_set.query.execute }
29
-
30
- let(:response) do
31
- response = double('response')
32
- allow(response).to receive_messages(
33
- headers: { 'Content-Type' => content_type },
34
- body: response_body
35
- )
36
- response
37
- end
38
- let(:result) { OData4::Query::Result.new(entity_set.query, response) }
39
-
40
- context 'with Atom Result' do
41
- let(:content_type) { 'application/atom+xml' }
42
- let(:response_body) { File.read('spec/fixtures/files/products.xml') }
43
-
44
- it_behaves_like 'valid result'
45
- end
46
-
47
- context 'with JSON Result' do
48
- let(:content_type) { 'application/json' }
49
- let(:response_body) { File.read('spec/fixtures/files/products.json') }
50
-
51
- it_behaves_like 'valid result'
52
- end
53
- end