lhs 3.3.5 → 3.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhs/concerns/record/all.rb +16 -2
- data/lib/lhs/version.rb +1 -1
- data/spec/record/all_spec.rb +16 -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: e6e194ca0104d33690c704260ef36ef265ab9979
|
4
|
+
data.tar.gz: 63de1464cea6731ab54c58e01c5ef46d74d6b46c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71f0954b3bea0a23ba9f8c6169e86df4a92b4d81b8702f3634eeb770b9e989a0b4795703f2de97b533ffd521711fac0a54a5e540426978a55413c83c393f0cce
|
7
|
+
data.tar.gz: 84ac812bc020fe427adc6d34ae0d87a1c528701b8cb644da0bfe50b613e7a12dd7eb0bcf00c5c8b046afb024fb6d112cd36cbe729dbb2f89c39479fa8bb0e66b
|
@@ -15,7 +15,22 @@ class LHS::Record
|
|
15
15
|
all = []
|
16
16
|
default_max_limit = 100
|
17
17
|
data = request(params: params.merge(limit: default_max_limit))
|
18
|
-
all.concat(data
|
18
|
+
all.concat(all_items_from(data))
|
19
|
+
request_all_the_rest(data, all, params) if data._raw.is_a?(Hash) && data._raw[:total]
|
20
|
+
data._record_class.new(LHS::Data.new(all, nil, self))
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def all_items_from(data)
|
26
|
+
if data._raw.is_a?(Array)
|
27
|
+
data._raw
|
28
|
+
else
|
29
|
+
data._raw[:items]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def request_all_the_rest(data, all, params)
|
19
34
|
total_left = data._raw[:total] - data.count
|
20
35
|
limit = data._raw[:limit] || data.count
|
21
36
|
if limit > 0
|
@@ -25,7 +40,6 @@ class LHS::Record
|
|
25
40
|
all.concat request(params: params.merge(limit: limit, offset: offset))._raw[:items]
|
26
41
|
end
|
27
42
|
end
|
28
|
-
data._record_class.new(LHS::Data.new(all, nil, self))
|
29
43
|
end
|
30
44
|
end
|
31
45
|
end
|
data/lib/lhs/version.rb
CHANGED
data/spec/record/all_spec.rb
CHANGED
@@ -48,5 +48,21 @@ describe LHS::Collection do
|
|
48
48
|
expect(all._proxy).to be_kind_of LHS::Collection
|
49
49
|
expect(all.count).to eq 0
|
50
50
|
end
|
51
|
+
|
52
|
+
it 'alsow works when there is no total in the stubbing' do
|
53
|
+
stub_request(:get, %r{/feedbacks}).to_return(body: { items: (1..100).to_a }.to_json)
|
54
|
+
all = Record.all
|
55
|
+
expect(all).to be_kind_of Record
|
56
|
+
expect(all._proxy).to be_kind_of LHS::Collection
|
57
|
+
expect(all.count).to eq 100
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'alsow works when there is no key "items" in the stubbing' do
|
61
|
+
stub_request(:get, %r{/feedbacks}).to_return(body: (1..100).to_a.to_json)
|
62
|
+
all = Record.all
|
63
|
+
expect(all).to be_kind_of Record
|
64
|
+
expect(all._proxy).to be_kind_of LHS::Collection
|
65
|
+
expect(all.count).to eq 100
|
66
|
+
end
|
51
67
|
end
|
52
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|