greedy 0.0.4 → 0.0.5
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.
- data/VERSION +1 -1
- data/greedy.gemspec +1 -1
- data/lib/greedy/stream.rb +1 -0
- data/test/test_stream.rb +34 -14
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/greedy.gemspec
CHANGED
data/lib/greedy/stream.rb
CHANGED
@@ -21,6 +21,7 @@ module Greedy
|
|
21
21
|
|
22
22
|
# Continue fetching earlier entries from where the last request left off
|
23
23
|
def continue!
|
24
|
+
return [] unless @continuation_token
|
24
25
|
new_entries = pull!(endpoint(@state), @options.merge(:c => @continuation_token))
|
25
26
|
@entries.concat new_entries
|
26
27
|
new_entries
|
data/test/test_stream.rb
CHANGED
@@ -30,25 +30,45 @@ class TestStream < Test::Unit::TestCase
|
|
30
30
|
setup do
|
31
31
|
assert_equal @reading_list.instance_variable_get("@continuation_token"), "continuationtoken"
|
32
32
|
@continued_response_hash = eval(File.open('test/fixtures/another_success_hash.txt').read)
|
33
|
-
@connection.expects(:fetch).with("stream/contents/user/-/state/com.google/reading-list",
|
34
|
-
{ :c => "continuationtoken" }).returns(@continued_response_hash)
|
35
33
|
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
context "when there's more entries to get" do
|
36
|
+
setup do
|
37
|
+
@connection.expects(:fetch).with("stream/contents/user/-/state/com.google/reading-list",
|
38
|
+
{ :c => "continuationtoken" }).returns(@continued_response_hash)
|
39
|
+
end
|
40
|
+
|
41
|
+
should "send the continuation token on the next pull" do
|
42
|
+
@reading_list.continue!
|
43
|
+
@reading_list.instance_variable_get("@continuation_token").should == "CKXmmOLq_aIC"
|
44
|
+
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
should "increase the entries size" do
|
47
|
+
entry_count = @reading_list.entries.size
|
48
|
+
continued_count = @reading_list.continue!.size
|
49
|
+
@reading_list.entries.size.should == (entry_count + continued_count)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "not change the last update token" do
|
53
|
+
token = @reading_list.instance_variable_get("@last_update_token")
|
54
|
+
@reading_list.continue!
|
55
|
+
@reading_list.instance_variable_get("@last_update_token").should == token
|
56
|
+
end
|
46
57
|
end
|
58
|
+
|
59
|
+
context "when no more entries exist to fetch" do
|
60
|
+
setup do
|
61
|
+
@reading_list.instance_variable_set "@continuation_token", nil
|
62
|
+
end
|
63
|
+
|
64
|
+
should "return an empty array if no continuation token was set on last fetch" do
|
65
|
+
@reading_list.continue!.should == []
|
66
|
+
end
|
47
67
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
68
|
+
should "never attempt the continuation fetch" do
|
69
|
+
@connection.expects(:fetch).never
|
70
|
+
@reading_list.continue!
|
71
|
+
end
|
52
72
|
end
|
53
73
|
end
|
54
74
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greedy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Weiland
|