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 +4 -4
- data/lib/soapy_cake/admin_batched.rb +9 -10
- data/lib/soapy_cake/version.rb +1 -1
- data/spec/lib/soapy_cake/admin_batched_spec.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90aab26ebb422cf0e5e2acbd44948a2314b0a90d
|
4
|
+
data.tar.gz: 3875d9128e5cabcbfd05e3087ca54f074d6cc05d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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, :
|
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)
|
data/lib/soapy_cake/version.rb
CHANGED
@@ -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
|
+
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-
|
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.
|
250
|
+
rubygems_version: 2.4.5
|
251
251
|
signing_key:
|
252
252
|
specification_version: 4
|
253
253
|
summary: Simple client for the CAKE API
|