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 +4 -4
- data/lib/ghee/resource_proxy.rb +5 -4
- data/lib/ghee/version.rb +1 -1
- data/spec/ghee/resource_proxy_spec.rb +23 -0
- 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: 8bc9d03023ca7469fce90c8d6262842d93676523
|
4
|
+
data.tar.gz: bf6eb60d0fb591242b671e1cd54d95532d74d209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95ca7b1ccf40b7fe8108b6dd868a612fd3a1f8c258ab78691e79f20f862fd635cc5f2f496520e2d1225b1ee8f1b54d62ab0f5312d1080f4208107ee3a35e20db
|
7
|
+
data.tar.gz: c7e1ad8a8f77411bd4c4b892e8fe4b57c2da731050b8a2d670756a3c07f8806d03c396faa9261790714cf29642050ff328f59ebbb18286f389183a129b83827e
|
data/lib/ghee/resource_proxy.rb
CHANGED
@@ -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
|
data/lib/ghee/version.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|