soapy_cake 1.11.4 → 1.11.5

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: 0c358f062efa7fc3ac3b7c59bc98929e832f080a
4
- data.tar.gz: 67e5fbfe4b111b42839c517012481be87349e9df
3
+ metadata.gz: 90aab26ebb422cf0e5e2acbd44948a2314b0a90d
4
+ data.tar.gz: 3875d9128e5cabcbfd05e3087ca54f074d6cc05d
5
5
  SHA512:
6
- metadata.gz: 4bf611fe1c634dcc60dc302cf1525120377f253a40fbcf6f592c5a1f95d3e803237640f94c1af484b8015458ed16d28d88f86df90acbfc3883137fa5a4ebe997
7
- data.tar.gz: d5cdb2090387c8a044007bf33d83f360a0610fd7f507f3445060de1918d629b90094e75017cb826974dbc6e5d187f7674bd58683ed5d3587c11a65825842679a
6
+ metadata.gz: 4a0ec1a818f34a0e3687b03e9ee2b38c94ede2de97dff7e3354da284a49bd1246ed95e9e4c36ffe9a8730cc58e17a5f3741a45c28dc384db88122774f43a2981
7
+ data.tar.gz: 202628dd1eb5bd7035c972970e9f6d522290aa19d01de5267bcae54d7e53cdbb4c7289822aa159fe32e06c6855d88db4bb04c34e9a5a5f059ba329ce821e6249
@@ -23,25 +23,24 @@ module SoapyCake
23
23
  @opts = opts
24
24
  @offset = INITIAL_OFFSET
25
25
  @limit = limit || LIMIT
26
- @finished = false
27
26
  end
28
27
 
29
28
  def to_enum
30
29
  Enumerator.new do |y|
31
- next_batch.each { |row| y << row } until finished
30
+ loop do
31
+ result = admin.public_send(method, opts.merge(row_limit: limit, start_at_row: offset))
32
+ @offset += limit
33
+ limit.times { y << result.next }
34
+ end
32
35
  end
36
+ # we know we received less than limit objects when we see a stop iteration exception from
37
+ # the underlying result enumerator and therefore know that we're done.
38
+ rescue StopIteration # rubocop:disable Lint/HandleExceptions
33
39
  end
34
40
 
35
41
  private
36
42
 
37
- attr_reader :admin, :method, :opts, :finished, :offset, :limit
38
-
39
- def next_batch
40
- result = admin.public_send(method, opts.merge(row_limit: limit, start_at_row: offset))
41
- @finished = true if result.count < limit
42
- @offset += limit
43
- result
44
- end
43
+ attr_reader :admin, :method, :opts, :offset, :limit
45
44
  end
46
45
 
47
46
  def method_missing(name, opts = {}, limit = nil)
@@ -1,3 +1,3 @@
1
1
  module SoapyCake
2
- VERSION = '1.11.4'
2
+ VERSION = '1.11.5'
3
3
  end
@@ -9,9 +9,9 @@ RSpec.describe SoapyCake::AdminBatched do
9
9
 
10
10
  it 'returns an enumerator and uses batched CAKE calls' do
11
11
  expect(admin).to receive(:offers)
12
- .with(advertiser: 1, start_at_row: 1, row_limit: 2).and_return(%i(a b))
12
+ .with(advertiser: 1, start_at_row: 1, row_limit: 2).and_return(%i(a b).to_enum)
13
13
  expect(admin).to receive(:offers)
14
- .with(advertiser: 1, start_at_row: 3, row_limit: 2).and_return(%i(c))
14
+ .with(advertiser: 1, start_at_row: 3, row_limit: 2).and_return(%i(c).to_enum)
15
15
 
16
16
  result = subject.offers(advertiser: 1)
17
17
 
@@ -21,7 +21,7 @@ RSpec.describe SoapyCake::AdminBatched do
21
21
 
22
22
  it 'can use a custom limit' do
23
23
  expect(admin).to receive(:offers)
24
- .with(advertiser: 1, start_at_row: 1, row_limit: 100).and_return(%i(a b))
24
+ .with(advertiser: 1, start_at_row: 1, row_limit: 100).and_return(%i(a b).to_enum)
25
25
 
26
26
  expect(subject.offers({ advertiser: 1 }, 100).to_a).to eq(%i(a b))
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapy_cake
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.4
4
+ version: 1.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
247
  version: '0'
248
248
  requirements: []
249
249
  rubyforge_project:
250
- rubygems_version: 2.4.8
250
+ rubygems_version: 2.4.5
251
251
  signing_key:
252
252
  specification_version: 4
253
253
  summary: Simple client for the CAKE API