pandarus 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pandarus/remote_collection.rb +5 -3
- data/lib/pandarus/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/remote_collection_all_pages.yml +24 -24
- data/spec/fixtures/vcr_cassettes/remote_collection_empty.yml +64 -0
- data/spec/fixtures/vcr_cassettes/remote_collection_single_page.yml +59 -0
- data/spec/lib/pandarus/remote_collection_spec.rb +19 -6
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea1afaaa6919f9eed893eb274a1fe527421bf5b8
|
4
|
+
data.tar.gz: 77706c514f1af00058f5ac2795a82c0d861c5fc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 565b795b90cd23a8e712d3aa967c9bb069bbe986c3cf8b054ec7d17fd9a3ce2c1448f9a4a6a32f5e5698aedd59a578035877279dd5f00de5eab5efd99d898fde
|
7
|
+
data.tar.gz: a69996ea83e880e05766f0f35f6ba185ebaa2bac8dbfb696c108e7904ca0ab34b9caf8209110d4f3542ac4fb30c746bd93145320d9c3a3461230301c5ab4ece1
|
@@ -48,19 +48,21 @@ module Pandarus
|
|
48
48
|
handle_response @http_client.get(@pagination_links.last.next)
|
49
49
|
end
|
50
50
|
|
51
|
+
private
|
52
|
+
|
51
53
|
def was_last_page?
|
54
|
+
return true if @pagination_links == []
|
52
55
|
@pagination_links.last.last_page?
|
53
56
|
end
|
54
57
|
|
55
58
|
def handle_response(response)
|
56
|
-
|
59
|
+
response_links = response.env[:pagination_links]
|
60
|
+
if response_links && !@pagination_links.any? {|existing_links| existing_links == response_links }
|
57
61
|
@pagination_links << response.env[:pagination_links]
|
58
62
|
end
|
59
63
|
response.body.map{|member| @target_class.new(member) }
|
60
64
|
end
|
61
65
|
|
62
|
-
private
|
63
|
-
|
64
66
|
def base_path
|
65
67
|
@http_client.url_prefix.path
|
66
68
|
end
|
data/lib/pandarus/version.rb
CHANGED
@@ -39,20 +39,20 @@ http_interactions:
|
|
39
39
|
Cache-Control:
|
40
40
|
- must-revalidate, private, max-age=0
|
41
41
|
Set-Cookie:
|
42
|
-
- _csrf_token=
|
42
|
+
- _csrf_token=jsM58YpsUDxPQGzaKcvUwzWfBulRrJgI%2B1fYmLoOqbPou3WV%2BSsBUiILFpZng7v0TNsw3inu0mK%2FGu%2Br7zjO4Q%3D%3D;
|
43
43
|
path=/
|
44
|
-
- _normandy_session=
|
44
|
+
- _normandy_session=zWF8MzAVtYcQl4Ocez9TJA.MdkGjGCWASvMn2GyQEJ647UUwZ5PfS7B216UEU8vilJ2GtqnGI0JSxUhWZLMUldMPFXiOyDU2PCOCp2z1k9e4pbXNa0NRyaywnJYcGazLc5ECUK7aYdUdUTlL5Scj2-j.UrtD2RSC0LuX-gDM8YjMG_WHlvk.VJiTTw;
|
45
45
|
path=/; HttpOnly
|
46
46
|
X-Session-Id:
|
47
|
-
-
|
47
|
+
- 76414941a586ff4bef0337f23df28509
|
48
48
|
X-Request-Context-Id:
|
49
|
-
-
|
49
|
+
- 29716e60-6c53-0132-52e9-38e85630c82a
|
50
50
|
X-Canvas-Meta:
|
51
|
-
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=
|
51
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=371464;m=371464;u=0.23;y=0.02;d=0.01;
|
52
52
|
X-Runtime:
|
53
|
-
- '0.
|
53
|
+
- '0.269341'
|
54
54
|
Date:
|
55
|
-
-
|
55
|
+
- Mon, 22 Dec 2014 21:55:27 GMT
|
56
56
|
X-Rack-Cache:
|
57
57
|
- miss
|
58
58
|
Connection:
|
@@ -71,7 +71,7 @@ http_interactions:
|
|
71
71
|
Holland","sortable_name":"Holland, Jonathan","short_name":"Jonathan Holland","sis_user_id":"student_4459","integration_id":null,"sis_login_id":"westudent215","sis_import_id":4,"login_id":"westudent215"},{"id":91,"name":"Corey
|
72
72
|
Kelly","sortable_name":"Kelly, Corey","short_name":"Corey Kelly","sis_user_id":"student_4408","integration_id":null,"sis_login_id":"westudent259","sis_import_id":4,"login_id":"westudent259"}]'
|
73
73
|
http_version:
|
74
|
-
recorded_at:
|
74
|
+
recorded_at: Mon, 22 Dec 2014 21:55:27 GMT
|
75
75
|
- request:
|
76
76
|
method: get
|
77
77
|
uri: http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=2&per_page=10
|
@@ -112,20 +112,20 @@ http_interactions:
|
|
112
112
|
Cache-Control:
|
113
113
|
- must-revalidate, private, max-age=0
|
114
114
|
Set-Cookie:
|
115
|
-
- _csrf_token=
|
115
|
+
- _csrf_token=PwTWrdYNGV1TEWZ7FgiuFE%2FvSm3ihJcSadN98OblgM5bT47cnXxgZDl7FjpRSsRBfosOG9TgpiYbugW206zEhQ%3D%3D;
|
116
116
|
path=/
|
117
|
-
- _normandy_session=
|
117
|
+
- _normandy_session=C44slFtEIvJWZfqJXerjLg.qGoXBN9TzBFAYQJLHoL0Ks2u7WJtMDPFD18x8vSdF_FpLwpvOlyBA9nig8aGXbr2wMnom5kV_b45TBP-P1v8WuGPN1JBc0_S_6slI7VYvYOsBidQhoGMU9jk2HdNW7GU.domHfXFXb9VInjtD4HxbfHhaGbs.VJiTTw;
|
118
118
|
path=/; HttpOnly
|
119
119
|
X-Session-Id:
|
120
|
-
-
|
120
|
+
- 0a8f103db518fda7bb13dc1fe57f68af
|
121
121
|
X-Request-Context-Id:
|
122
|
-
-
|
122
|
+
- 299d2f70-6c53-0132-52e9-38e85630c82a
|
123
123
|
X-Canvas-Meta:
|
124
|
-
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=
|
124
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=371464;m=371464;u=0.31;y=0.02;d=0.01;
|
125
125
|
X-Runtime:
|
126
|
-
- '0.
|
126
|
+
- '0.367507'
|
127
127
|
Date:
|
128
|
-
-
|
128
|
+
- Mon, 22 Dec 2014 21:55:27 GMT
|
129
129
|
X-Rack-Cache:
|
130
130
|
- miss
|
131
131
|
Connection:
|
@@ -144,7 +144,7 @@ http_interactions:
|
|
144
144
|
Watts","sortable_name":"Watts, Stephenson","short_name":"Stephenson Watts","sis_user_id":"student_4442","integration_id":null,"sis_login_id":"westudent496","sis_import_id":4,"login_id":"westudent496"},{"id":115,"name":"Britney
|
145
145
|
Whittle","sortable_name":"Whittle, Britney","short_name":"Britney Whittle","sis_user_id":"student_4432","integration_id":null,"sis_login_id":"westudent504","sis_import_id":4,"login_id":"westudent504"}]'
|
146
146
|
http_version:
|
147
|
-
recorded_at:
|
147
|
+
recorded_at: Mon, 22 Dec 2014 21:55:27 GMT
|
148
148
|
- request:
|
149
149
|
method: get
|
150
150
|
uri: http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=3&per_page=10
|
@@ -184,20 +184,20 @@ http_interactions:
|
|
184
184
|
Cache-Control:
|
185
185
|
- must-revalidate, private, max-age=0
|
186
186
|
Set-Cookie:
|
187
|
-
- _csrf_token=
|
187
|
+
- _csrf_token=dSENVLsxmQ4hosrEI2e8TwBIPF2ioOYAQ90gHTFrA35HS38nw2XRYxT1%2F4JmC%2B8CKzhXE8TqhFAwhE8qYS56NQ%3D%3D;
|
188
188
|
path=/
|
189
|
-
- _normandy_session=
|
189
|
+
- _normandy_session=vXrwazjrTOLyY4EZV54PGA.1oBz9DK-UZghtfaMWXSTsnqTGCjlKeJZsX6fmXufW9UsK1BoUUG3sY2jnjkP9a7CFjDUW9K7AVFaHwy1B8G1riFP9C8S_i2fg5VS6tFpEBsOydFriP5w10_7Mltd_o64.ZYeQUSsY-vnIhxhUUO8sWdNoRXs.VJiTTw;
|
190
190
|
path=/; HttpOnly
|
191
191
|
X-Session-Id:
|
192
|
-
-
|
192
|
+
- 1b093ceebeb6ef802d1b834b9019d557
|
193
193
|
X-Request-Context-Id:
|
194
|
-
-
|
194
|
+
- 29d75230-6c53-0132-52e9-38e85630c82a
|
195
195
|
X-Canvas-Meta:
|
196
|
-
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=
|
196
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=371464;m=371464;u=0.06;y=0.01;d=0.01;
|
197
197
|
X-Runtime:
|
198
|
-
- '0.
|
198
|
+
- '0.096645'
|
199
199
|
Date:
|
200
|
-
-
|
200
|
+
- Mon, 22 Dec 2014 21:55:27 GMT
|
201
201
|
X-Rack-Cache:
|
202
202
|
- miss
|
203
203
|
Connection:
|
@@ -207,5 +207,5 @@ http_interactions:
|
|
207
207
|
string: '[{"id":108,"name":"Jessy Young","sortable_name":"Young, Jessy","short_name":"Jessy
|
208
208
|
Young","sis_user_id":"student_4425","integration_id":null,"sis_login_id":"westudent520","sis_import_id":4,"login_id":"westudent520"}]'
|
209
209
|
http_version:
|
210
|
-
recorded_at:
|
210
|
+
recorded_at: Mon, 22 Dec 2014 21:55:27 GMT
|
211
211
|
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://shard1.canvas.dev/api/v1/courses/183/users?enrollment_type=student
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Authorization:
|
13
|
+
- Bearer Bearer 1~A5dY8IsOyhVOVRJi4V3XWGNsa7pzuIbdM8OCv62YTRFqOsiS9vX0NbtY8PR9q4pX
|
14
|
+
User-Agent:
|
15
|
+
- Footrest
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
X-Canvas-User-Id:
|
24
|
+
- '10000000000001'
|
25
|
+
Link:
|
26
|
+
- <http://shard1.canvas.dev/api/v1/courses/183/users?enrollment_type=student&page=1&per_page=10>;
|
27
|
+
rel="current",<http://shard1.canvas.dev/api/v1/courses/183/users?enrollment_type=student&page=1&per_page=10>;
|
28
|
+
rel="first",<http://shard1.canvas.dev/api/v1/courses/183/users?enrollment_type=student&page=1&per_page=10>;
|
29
|
+
rel="last"
|
30
|
+
X-Frame-Options:
|
31
|
+
- SAMEORIGIN
|
32
|
+
Content-Type:
|
33
|
+
- application/json; charset=utf-8
|
34
|
+
X-Ua-Compatible:
|
35
|
+
- IE=Edge
|
36
|
+
Etag:
|
37
|
+
- '"d751713988987e9331980363e24189ce"'
|
38
|
+
Cache-Control:
|
39
|
+
- must-revalidate, private, max-age=0
|
40
|
+
Set-Cookie:
|
41
|
+
- _csrf_token=70LPEWYX8OUtxNrRWPyLn%2FF5xpDuVASz9YBJQekUgJWBGIBcE2bBqV2erbMBqe713ivx4L8%2FZsKnuBgEv2TDow%3D%3D;
|
42
|
+
path=/
|
43
|
+
- _normandy_session=yClqZDQD-PKanqxq4xbeUA.YKVmGVKaKJ6pC4Lf_jlDeelPxqjDK5ZO1wn57l9_e2q_xaAlLWt_nkEYd4arBr8x1sFipxANo5tXnOmCIxduDZhah0oXGnPxhwcowYPwH4bW3R0-udl6FsJ6WGAFwU2z._u4S-ax72PiWoXX-kD6cSPOo88Y.VK1_SA;
|
44
|
+
path=/; HttpOnly
|
45
|
+
X-Session-Id:
|
46
|
+
- 2698d12b0db9b5da795f2e5df6f53ba6
|
47
|
+
X-Request-Context-Id:
|
48
|
+
- 927c35e0-78cb-0132-bea1-38e85630c82a
|
49
|
+
X-Canvas-Meta:
|
50
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=341124;m=341280;u=0.21;y=0.02;d=0.01;
|
51
|
+
X-Runtime:
|
52
|
+
- '0.260593'
|
53
|
+
Date:
|
54
|
+
- Wed, 07 Jan 2015 18:47:36 GMT
|
55
|
+
X-Rack-Cache:
|
56
|
+
- miss
|
57
|
+
Connection:
|
58
|
+
- close
|
59
|
+
body:
|
60
|
+
encoding: UTF-8
|
61
|
+
string: "[]"
|
62
|
+
http_version:
|
63
|
+
recorded_at: Wed, 07 Jan 2015 18:47:36 GMT
|
64
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://shard1.canvas.dev/api/v1/courses/14/sections
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Authorization:
|
13
|
+
- Bearer Bearer 1~A5dY8IsOyhVOVRJi4V3XWGNsa7pzuIbdM8OCv62YTRFqOsiS9vX0NbtY8PR9q4pX
|
14
|
+
User-Agent:
|
15
|
+
- Footrest
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
X-Canvas-User-Id:
|
24
|
+
- '10000000000001'
|
25
|
+
X-Frame-Options:
|
26
|
+
- SAMEORIGIN
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
X-Ua-Compatible:
|
30
|
+
- IE=Edge
|
31
|
+
Etag:
|
32
|
+
- '"d57de41ff2edcb1840cba95cd99ceb93"'
|
33
|
+
Cache-Control:
|
34
|
+
- must-revalidate, private, max-age=0
|
35
|
+
Set-Cookie:
|
36
|
+
- _csrf_token=Nn0Xriy%2BzySk5XIE4WX%2FIYmWuMirPk52%2FY8rWDthFp1SS17JfMipYP6%2FS2%2BwNaVx8N%2F9pflOPDfI%2FmpuYVlb%2BA%3D%3D;
|
37
|
+
path=/
|
38
|
+
- _normandy_session=kjUGEKraWqjH8yUDgkjv0g.KV0__PysS8xFX02CiZFVHdyhaQB6RboB7hzYJ4R95FKcBGg7GgtaHLEfZ1wtPz2RAJ-53cGqRKwvcGM-ZJxi4gTz4iBuSHLC990OlekqmtjCyIq1Z4jnpAkGQ2Lc0md7.-Fkgs-L9w-l5bvVJaon6h0U9ths.VJiCAA;
|
39
|
+
path=/; HttpOnly
|
40
|
+
X-Session-Id:
|
41
|
+
- ed3089094605b369c73c4ff0002cc5fe
|
42
|
+
X-Request-Context-Id:
|
43
|
+
- d877b560-6c48-0132-52e9-38e85630c82a
|
44
|
+
X-Canvas-Meta:
|
45
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=328372;m=328372;u=0.19;y=0.01;d=0.00;
|
46
|
+
X-Runtime:
|
47
|
+
- '0.225363'
|
48
|
+
Date:
|
49
|
+
- Mon, 22 Dec 2014 20:41:36 GMT
|
50
|
+
X-Rack-Cache:
|
51
|
+
- miss
|
52
|
+
Connection:
|
53
|
+
- close
|
54
|
+
body:
|
55
|
+
encoding: UTF-8
|
56
|
+
string: '[{"course_id":14,"end_at":null,"id":14,"name":"1st Grade English-EL101-14-15-Barker","nonxlist_course_id":null,"start_at":null,"sis_section_id":"1994","sis_course_id":"1994","integration_id":"1994","sis_import_id":4}]'
|
57
|
+
http_version:
|
58
|
+
recorded_at: Mon, 22 Dec 2014 20:41:36 GMT
|
59
|
+
recorded_with: VCR 2.9.3
|
@@ -43,14 +43,27 @@ module Pandarus
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe '#to_a' do
|
46
|
-
|
47
|
-
VCR.use_cassette('
|
48
|
-
collection.
|
46
|
+
it 'must gracefully handle an empty collection' do
|
47
|
+
VCR.use_cassette('remote_collection_empty') do
|
48
|
+
collection.instance_variable_set(:@path, '/v1/courses/183/users')
|
49
|
+
array = collection.to_a
|
50
|
+
expect(array).to be_empty
|
49
51
|
end
|
50
|
-
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'must happily fetch a collection with a single page' do
|
55
|
+
VCR.use_cassette('remote_collection_single_page') do
|
56
|
+
collection = RemoteCollection.new(client, Section, '/v1/courses/14/sections', {})
|
57
|
+
array = collection.to_a
|
58
|
+
expect(array.size).to eq 1
|
59
|
+
end
|
60
|
+
end
|
51
61
|
|
52
|
-
it 'must fetch all pages and combine them into a single array' do
|
53
|
-
|
62
|
+
it 'must fetch all pages of a multi page collection and combine them into a single array' do
|
63
|
+
VCR.use_cassette('remote_collection_all_pages') do
|
64
|
+
array = collection.to_a
|
65
|
+
expect(array.size).to eq 21
|
66
|
+
end
|
54
67
|
end
|
55
68
|
end
|
56
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pandarus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duane Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -261,7 +261,9 @@ files:
|
|
261
261
|
- spec/api_base_spec.rb
|
262
262
|
- spec/client_spec.rb
|
263
263
|
- spec/fixtures/vcr_cassettes/remote_collection_all_pages.yml
|
264
|
+
- spec/fixtures/vcr_cassettes/remote_collection_empty.yml
|
264
265
|
- spec/fixtures/vcr_cassettes/remote_collection_first_page.yml
|
266
|
+
- spec/fixtures/vcr_cassettes/remote_collection_single_page.yml
|
265
267
|
- spec/lib/pandarus/remote_collection_spec.rb
|
266
268
|
- spec/model_base_spec.rb
|
267
269
|
- spec/sis_import_spec.rb
|
@@ -296,7 +298,9 @@ test_files:
|
|
296
298
|
- spec/api_base_spec.rb
|
297
299
|
- spec/client_spec.rb
|
298
300
|
- spec/fixtures/vcr_cassettes/remote_collection_all_pages.yml
|
301
|
+
- spec/fixtures/vcr_cassettes/remote_collection_empty.yml
|
299
302
|
- spec/fixtures/vcr_cassettes/remote_collection_first_page.yml
|
303
|
+
- spec/fixtures/vcr_cassettes/remote_collection_single_page.yml
|
300
304
|
- spec/lib/pandarus/remote_collection_spec.rb
|
301
305
|
- spec/model_base_spec.rb
|
302
306
|
- spec/sis_import_spec.rb
|