lhs 1.2.1 → 1.2.2
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 +4 -4
- data/lib/lhs/collection.rb +1 -0
- data/lib/lhs/concerns/service/all.rb +6 -4
- data/lib/lhs/version.rb +1 -1
- data/spec/service/all_spec.rb +11 -2
- 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: 79706509847d5e009bdc036cd616b804d88c6dfa
|
4
|
+
data.tar.gz: 2530ee6f7e347584cba1ec46c51ff13291307950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbdb3f1be6fb3412a94f08f1bf55661b660ff7d0587a88b2f8704fce74ccdac57aaca9618d9bff8fd3cf8b34aec1b768b4fa25b6caa8ae30cc778b5912147b7b
|
7
|
+
data.tar.gz: 63ef7d714318e13a90507512bd7a8be1e2bc4122931e2acc3bfc262142d9fb0b5ea3d9ebdfa414f2c96788a7635e241754e48deb63049da3e9da4f3a0af3ff1e
|
data/lib/lhs/collection.rb
CHANGED
@@ -19,10 +19,12 @@ class LHS::Service
|
|
19
19
|
all.concat(data._raw['items'])
|
20
20
|
total_left = data._raw['total'] - data.count
|
21
21
|
limit = data._raw['limit'] || data.count
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
if limit > 0
|
23
|
+
requests = total_left / limit
|
24
|
+
requests.times do |i|
|
25
|
+
offset = limit * (i+1) + 1
|
26
|
+
all.concat instance.request(params: params.merge(limit: limit, offset: offset))._raw['items']
|
27
|
+
end
|
26
28
|
end
|
27
29
|
LHS::Data.new(all, nil, self)
|
28
30
|
end
|
data/lib/lhs/version.rb
CHANGED
data/spec/service/all_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe LHS::Collection do
|
|
25
25
|
expect(all).to be_kind_of LHS::Data
|
26
26
|
expect(all._proxy).to be_kind_of LHS::Collection
|
27
27
|
expect(all.count).to eq 300
|
28
|
-
expect(all
|
28
|
+
expect(all.last).to eq 300
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'also fetches all when there is not meta information for limit' do
|
@@ -39,7 +39,16 @@ describe LHS::Collection do
|
|
39
39
|
expect(all).to be_kind_of LHS::Data
|
40
40
|
expect(all._proxy).to be_kind_of LHS::Collection
|
41
41
|
expect(all.count).to eq 300
|
42
|
-
expect(all
|
42
|
+
expect(all.last).to eq 300
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'also works when there is no item in the first response' do
|
46
|
+
stub_request(:get, "#{datastore}/feedbacks?limit=100")
|
47
|
+
.to_return(status: 200, body: {items: [], total: 300, offset: 0}.to_json)
|
48
|
+
all = SomeService.all
|
49
|
+
expect(all).to be_kind_of LHS::Data
|
50
|
+
expect(all._proxy).to be_kind_of LHS::Collection
|
51
|
+
expect(all.count).to eq 0
|
43
52
|
end
|
44
53
|
end
|
45
54
|
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: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|