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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f638bcf63e5c298c8106c4c71bacdbe8acd6927
4
- data.tar.gz: 264608b47a9493bc9d3251339a6ceaf1d303495c
3
+ metadata.gz: ed9db59499f69b6cd0a980b55982bc4b76e232ed
4
+ data.tar.gz: e7478c8e5784094990a86f11626632c7f0fe4244
5
5
  SHA512:
6
- metadata.gz: d66e47f6285e02f0e2adde97ee5834d440cb4d67a9f10cd1c36325d73bdacdf2393fa2a29a56e0d4e8ba45af782871467b027f63168051885b7abee9aae02ce3
7
- data.tar.gz: aa0d393e775190a19e457406bef37d4b6fd8fe05d41ddc4ab56f767de084f38a1b91c253cd17043bd0a70365f2b3ddde6537c5c82cc9de2a61fc77ef1239ef5b
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: LIMIT, start_at_row: offset))
36
- @finished = true if result.count < LIMIT
37
- @offset += LIMIT
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
@@ -1,3 +1,3 @@
1
1
  module SoapyCake
2
- VERSION = '1.11.0'
2
+ VERSION = '1.11.1'
3
3
  end
@@ -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.clicks }.to raise_error(/Invalid method clicks/)
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.0
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-27 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport