soapy_cake 1.11.0 → 1.11.1
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 -8
- data/lib/soapy_cake/version.rb +1 -1
- data/spec/lib/soapy_cake/admin_batched_spec.rb +8 -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: ed9db59499f69b6cd0a980b55982bc4b76e232ed
|
4
|
+
data.tar.gz: e7478c8e5784094990a86f11626632c7f0fe4244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43567a1c4a870a24c650c6d23b3c276ba4e63017adc058151fc64b14b4baef063eacfc1e152e265b3558d8047005b5d5b152445d02b172a8bfac5037ee83e199
|
7
|
+
data.tar.gz: d7de64c699a0efdf9e5232402cfd2175195f0b9fed4fcdaba5db711661e98c0b476e44da320cdb44c975ce7238dbbeab6098806ed4229e0dec83a03811edf04f
|
@@ -9,7 +9,7 @@ module SoapyCake
|
|
9
9
|
# When all offers have a lot of info (e.g. geotargeting) we probably need to decrease this.
|
10
10
|
LIMIT = 500
|
11
11
|
|
12
|
-
def initialize(admin, method, opts)
|
12
|
+
def initialize(admin, method, opts, limit)
|
13
13
|
if opts.key?(:row_limit) || opts.key?(:start_at_row)
|
14
14
|
fail Error, 'Cannot set row_limit/start_at_row in batched mode!'
|
15
15
|
end
|
@@ -18,6 +18,7 @@ module SoapyCake
|
|
18
18
|
@method = method
|
19
19
|
@opts = opts
|
20
20
|
@offset = INITIAL_OFFSET
|
21
|
+
@limit = limit || LIMIT
|
21
22
|
@finished = false
|
22
23
|
end
|
23
24
|
|
@@ -29,22 +30,22 @@ module SoapyCake
|
|
29
30
|
|
30
31
|
private
|
31
32
|
|
32
|
-
attr_reader :admin, :method, :opts, :finished, :offset
|
33
|
+
attr_reader :admin, :method, :opts, :finished, :offset, :limit
|
33
34
|
|
34
35
|
def next_batch
|
35
|
-
result = admin.public_send(method, opts.merge(row_limit:
|
36
|
-
@finished = true if result.count <
|
37
|
-
@offset +=
|
36
|
+
result = admin.public_send(method, opts.merge(row_limit: limit, start_at_row: offset))
|
37
|
+
@finished = true if result.count < limit
|
38
|
+
@offset += limit
|
38
39
|
result
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
ALLOWED_METHODS = %i(advertisers affiliates campaigns offers creatives)
|
43
|
+
ALLOWED_METHODS = %i(advertisers affiliates campaigns offers creatives clicks conversions)
|
43
44
|
|
44
|
-
def method_missing(name, opts = {})
|
45
|
+
def method_missing(name, opts = {}, limit = nil)
|
45
46
|
fail Error, "Invalid method #{name}" unless ALLOWED_METHODS.include?(name)
|
46
47
|
|
47
|
-
BatchedRequest.new(admin, name, opts).to_enum
|
48
|
+
BatchedRequest.new(admin, name, opts, limit).to_enum
|
48
49
|
end
|
49
50
|
|
50
51
|
private
|
data/lib/soapy_cake/version.rb
CHANGED
@@ -19,9 +19,16 @@ RSpec.describe SoapyCake::AdminBatched do
|
|
19
19
|
expect(result.to_a).to eq(%i(a b c))
|
20
20
|
end
|
21
21
|
|
22
|
+
it 'can use a custom limit' do
|
23
|
+
expect(admin).to receive(:offers)
|
24
|
+
.with(advertiser: 1, start_at_row: 1, row_limit: 100).and_return(%i(a b))
|
25
|
+
|
26
|
+
expect(subject.offers({ advertiser: 1 }, 100).to_a).to eq(%i(a b))
|
27
|
+
end
|
28
|
+
|
22
29
|
context 'errors' do
|
23
30
|
it 'fails with an invalid method' do
|
24
|
-
expect { subject.
|
31
|
+
expect { subject.something }.to raise_error(/Invalid method something/)
|
25
32
|
end
|
26
33
|
|
27
34
|
it 'fails when row_limit is set' do
|
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.1
|
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-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|