ghee 0.14.20 → 0.14.21

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: 159a60f71f17830d6f2db1b6d4eca19910cb1f19
4
- data.tar.gz: 6bba5d09f642b3db0d9cd8e2bfd41457dfe945f0
3
+ metadata.gz: 8bc9d03023ca7469fce90c8d6262842d93676523
4
+ data.tar.gz: bf6eb60d0fb591242b671e1cd54d95532d74d209
5
5
  SHA512:
6
- metadata.gz: 81cf9af3be3f3c7672972b5b34b1eea5f5bda7a6fbeb772e1b920fb01a25e9ea80e06110669c992954fd301429e198dc5513542e762f2a2adb4c7cab2bbfa1bd
7
- data.tar.gz: 7124953aea1149c46c334c6e9e8f12c88c3d07d18748ed6ccecc99f61897cb7341b5822203ca5a07da3e333585775322e8e4f7da997b4e2605fe1ed8e269c5b0
6
+ metadata.gz: 95ca7b1ccf40b7fe8108b6dd868a612fd3a1f8c258ab78691e79f20f862fd635cc5f2f496520e2d1225b1ee8f1b54d62ab0f5312d1080f4208107ee3a35e20db
7
+ data.tar.gz: c7e1ad8a8f77411bd4c4b892e8fe4b57c2da731050b8a2d670756a3c07f8806d03c396faa9261790714cf29642050ff328f59ebbb18286f389183a129b83827e
@@ -81,12 +81,13 @@ class Ghee
81
81
  #
82
82
  # Returns self
83
83
  #
84
- def paginate(options)
84
+ def paginate(options, &block)
85
85
  @current_page = options.fetch(:page) {raise ArgumentError, ":page parameter required"}
86
86
  per_page = options.delete(:per_page) || 30
87
87
  response = connection.get do |req|
88
88
  req.url path_prefix, :per_page => per_page, :page => current_page
89
89
  req.params.merge! params
90
+ block.call(req)
90
91
  end
91
92
 
92
93
  if @subject.nil?
@@ -100,12 +101,12 @@ class Ghee
100
101
  return self
101
102
  end
102
103
 
103
- def all
104
+ def all(&block)
104
105
  return self if pagination && next_page.nil?
105
106
 
106
- self.paginate :per_page => 100, :page => next_page || 1
107
+ self.paginate :per_page => 100, :page => next_page || 1, &block
107
108
 
108
- self.all
109
+ self.all(&block)
109
110
  end
110
111
 
111
112
  def all_parallel
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  class Ghee
3
- VERSION = "0.14.20"
3
+ VERSION = "0.14.21"
4
4
  end
@@ -65,6 +65,29 @@ describe "Pagination" do
65
65
  end
66
66
  end
67
67
 
68
+ describe "#all with block" do
69
+ before(:each) do
70
+ @connection = mock('connection')
71
+ @request = OpenStruct.new()
72
+ @request.stub(:url)
73
+ @request.stub(:params).and_return(Hash.new)
74
+
75
+ @block = Proc.new {}
76
+ @connection.stub!(:get)
77
+ .and_yield(@request)
78
+ .and_return(IncrementPager.new 1)
79
+ end
80
+
81
+ subject do
82
+ Ghee::ResourceProxy.new(@connection, '/foo')
83
+ end
84
+
85
+ it "Passes the request down to the block" do
86
+ @block.should_receive(:call).with(@request)
87
+ subject.all(&@block)
88
+ end
89
+ end
90
+
68
91
 
69
92
  describe "past first page" do
70
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.20
4
+ version: 0.14.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Rauh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-16 00:00:00.000000000 Z
12
+ date: 2016-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday