odata 0.6.10 → 0.6.11

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: 85ba94e38c8e98ac39b5473ce471f035d127f968
4
- data.tar.gz: a7330a45e25e9aa0f3d3eded2a2859caae7710f0
3
+ metadata.gz: a572559e7706b0bef39c622c2e4b3a4b4e5a7b21
4
+ data.tar.gz: cf9f5a4a0afce81ef6c0eb9cf2f7df1ec47d2cd2
5
5
  SHA512:
6
- metadata.gz: 634d49a0e0aa249d6666c3d9b73c4443643fbd1050508661894ff8a9598c359d4d9b03b1bc49b7191d6e458a3db36abfb3a8292ec9f1db733877a6d6efdacf9a
7
- data.tar.gz: c4cc4de9202a0fc17c8aa0b69b63f49f2d0ec8c056cd7cea3b340c3c9d80ef15dadc7658e630e40e677d63771eeb999893d3b92f6a76e81d48d5033023f54f34
6
+ metadata.gz: 5afefdbeb87aa038ce5d4bfea737712d8afbcb87ddc4e6a240eda5213d5d2969491b953a86e1827b84bc885739a4d4ba871451971e7fe1892f5f391901337fe9
7
+ data.tar.gz: 614b2f640935183abb86acc1823c808605e067fc6e217413079a5e0e0256a777338904edea14ab9e24c628c0cf3b8377ae35be698c5645871eafb3f96dc2b176
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.6.11
4
+
5
+ * Added logic to allow OData::Query::Result#each to handle paginated results.
6
+
3
7
  ## 0.6.10
4
8
 
5
9
  * Changed how associations behave with mulitiplicity of one.
@@ -17,15 +17,19 @@ module OData
17
17
  # @param block [block] a block to evaluate
18
18
  # @return [OData::Entity] each entity in turn for the query result
19
19
  def each(&block)
20
- service.find_entities(result).each do |entity_xml|
21
- entity = OData::Entity.from_xml(entity_xml, entity_options)
22
- block_given? ? block.call(entity) : yield(entity)
20
+ until next_page.nil?
21
+ service.find_entities(result).each do |entity_xml|
22
+ entity = OData::Entity.from_xml(entity_xml, entity_options)
23
+ block_given? ? block.call(entity) : yield(entity)
24
+ end
25
+ result = service.execute(next_page_url)
23
26
  end
24
27
  end
25
28
 
26
29
  private
27
30
 
28
- attr_reader :query, :result
31
+ attr_reader :query
32
+ attr_accessor :result
29
33
 
30
34
  def service
31
35
  query.entity_set.service
@@ -34,6 +38,16 @@ module OData
34
38
  def entity_options
35
39
  query.entity_set.entity_options
36
40
  end
41
+
42
+ def next_page
43
+ doc = ::Nokogiri::XML(result.body)
44
+ doc.remove_namespaces!
45
+ doc.xpath("/feed/link[@rel='next']").first
46
+ end
47
+
48
+ def next_page_url
49
+ next_page.attributes['href'].gsub(service.service_url, '')
50
+ end
37
51
  end
38
52
  end
39
53
  end
@@ -1,3 +1,3 @@
1
1
  module OData
2
- VERSION = '0.6.10'
2
+ VERSION = '0.6.11'
3
3
  end
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.6.10
4
+ version: 0.6.11
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-10-08 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler