soapy_cake 1.14.2 → 1.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e818f8c8f8f07c68afce7217b6ec5289d889dba4
4
- data.tar.gz: b2ca4293be84d7e7bc3dbeb25763e951375a8b30
3
+ metadata.gz: 274c6c48d643201ef471755c417f79cb6d706327
4
+ data.tar.gz: 570e80542b976f9e557a1e0146c3b7848ed52f49
5
5
  SHA512:
6
- metadata.gz: b41b4e7c2b45f00c9ed526970f6765cd66ee0e58f14a8e10b45f4f7421fbf72c84d168f54a8c4f41302cfda13b42e746f85971c433b6041f1fc670895210b9d9
7
- data.tar.gz: 5375bb41a9b31ae198368eddf1ba7164ffe75f8f97ea606a72afa901a6c74abe66df66601d5676dad7a7bf31f47a2d44aeaf3080ff07e138f9ee00b195f096c5
6
+ metadata.gz: c2e0fe1d2b066fb8faf733788118d7ec2c302b306ac91313168a4d8c542406571f10964ff6b42dc5909420f092937d4117863b3cc1ba45d1d49d791e53dea01e
7
+ data.tar.gz: 6f5b4a158f277ce3fb6c6c444c152719cf69385550c376a3d829514cc4ad6cd7ad5128c861ca02f137fec979654d272ebb9ce6040c229c9385922f0a35995dec
@@ -32,10 +32,7 @@ module SoapyCake
32
32
  def to_enum
33
33
  Enumerator.new do |y|
34
34
  loop do
35
- result = next_batch
36
- # raises StopIteration when less than `limit` elements are present
37
- # which is then rescued by `loop`
38
- limit.times { y << result.next }
35
+ fetch_elements(y)
39
36
  @offset += limit
40
37
  end
41
38
  end
@@ -43,7 +40,18 @@ module SoapyCake
43
40
 
44
41
  private
45
42
 
46
- def next_batch
43
+ def fetch_elements(enumerator)
44
+ result = fetch_batch
45
+ # raises StopIteration when less than `limit` elements are present
46
+ # which is then rescued by `loop`
47
+ if admin.xml_response?
48
+ enumerator << result.next
49
+ else
50
+ limit.times { enumerator << result.next }
51
+ end
52
+ end
53
+
54
+ def fetch_batch
47
55
  admin.public_send(method, opts.merge(row_limit: limit, start_at_row: offset))
48
56
  end
49
57
 
@@ -10,6 +10,10 @@ module SoapyCake
10
10
  @opts = opts
11
11
  end
12
12
 
13
+ def xml_response?
14
+ opts[:xml_response] == true
15
+ end
16
+
13
17
  protected
14
18
 
15
19
  attr_reader :opts
@@ -25,10 +29,6 @@ module SoapyCake
25
29
 
26
30
  private
27
31
 
28
- def xml_response?
29
- opts[:xml_response] == true
30
- end
31
-
32
32
  def response_body(request)
33
33
  if request.opts[:response].present?
34
34
  request.opts[:response]
@@ -1,3 +1,3 @@
1
1
  module SoapyCake
2
- VERSION = '1.14.2'.freeze
2
+ VERSION = '1.14.3'.freeze
3
3
  end
@@ -1,5 +1,5 @@
1
1
  RSpec.describe SoapyCake::AdminBatched do
2
- let(:admin) { double('admin') }
2
+ let(:admin) { double('admin', xml_response?: false) }
3
3
 
4
4
  before :each do
5
5
  allow(SoapyCake::Admin).to receive(:new).and_return(admin)
@@ -26,6 +26,28 @@ RSpec.describe SoapyCake::AdminBatched do
26
26
  expect(subject.offers({ advertiser: 1 }, 100).to_a).to eq(%i(a b))
27
27
  end
28
28
 
29
+ context 'SoapyCake Batched with XMLResponse set' do
30
+ subject { described_class.new(xml_response: true) }
31
+
32
+ before do
33
+ allow(admin).to receive(:xml_response?).and_return(true)
34
+ end
35
+
36
+ it 'returns all affiliates in batched mode' do
37
+ expect(admin).to receive(:affiliates)
38
+ .with(start_at_row: 1, row_limit: 10).and_return(%i(a).to_enum)
39
+ expect(admin).to receive(:affiliates)
40
+ .with(start_at_row: 11, row_limit: 10).and_return(%i(b).to_enum)
41
+ expect(admin).to receive(:affiliates)
42
+ .with(start_at_row: 21, row_limit: 10).and_return([].to_enum)
43
+
44
+ result = subject.affiliates({}, 10)
45
+
46
+ expect(result).to be_a(Enumerator)
47
+ expect(result.to_a).to eq(%i(a b))
48
+ end
49
+ end
50
+
29
51
  context 'errors' do
30
52
  it 'fails with an invalid method' do
31
53
  expect { subject.something }.to raise_error(/Invalid method something/)
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.14.2
4
+ version: 1.14.3
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-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -250,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  version: '0'
251
251
  requirements: []
252
252
  rubyforge_project:
253
- rubygems_version: 2.4.8
253
+ rubygems_version: 2.4.5.1
254
254
  signing_key:
255
255
  specification_version: 4
256
256
  summary: Simple client for the CAKE API