pocket-ruby 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +13 -2
- data/README.md +6 -3
- data/lib/faraday/raise_pocket_error.rb +3 -3
- data/lib/pocket-ruby.rb +0 -11
- data/lib/pocket/article.rb +3 -2
- data/lib/pocket/client.rb +19 -7
- data/lib/pocket/version.rb +1 -1
- data/pocket-ruby.gemspec +2 -1
- data/test/pocket/article_test.rb +65 -50
- data/test/pocket/client_test.rb +23 -0
- metadata +20 -7
- data/lib/pocket/client/add.rb +0 -12
- data/lib/pocket/client/modify.rb +0 -12
- data/lib/pocket/client/retrieve.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f83cad90dd723c6fca321e9c1851141faac117ecf3e34dba0880c93494485f15
|
4
|
+
data.tar.gz: 1458858158eb2ddfbe63bb732bbe07af2d15aeab6fe93f4bd015ab74641fa5b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e1b0318db4819e83719397f4cd3c67f2aa66a62d9e0305f93ab782fe5537d1130c0a6298b360e486554826086f9bda48a49c76ddd63923b9f9fdf9960010ba1
|
7
|
+
data.tar.gz: 355774840e30cd2841360c15725c019afdd2ad284ca1de05f028339369a9761ba83162f17a9c510b2696be5bebf253fae6a682e1e11f851e0e23dd9e3742b2c8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.0] - 2021-04-18
|
4
|
+
|
5
|
+
- Fix Faraday error handling. ([#81](https://github.com/turadg/pocket-ruby/pull/81))
|
6
|
+
- Don't assume `is_article` is present ([#78](https://github.com/turadg/pocket-ruby/pull/78)).
|
7
|
+
- Handle article with missing `resolved_url` or `resolved_title` ([#77](https://github.com/turadg/pocket-ruby/pull/77))
|
8
|
+
- Remove unnecessary use of `method_missing`. ([#71](https://github.com/turadg/pocket-ruby/pull/71))
|
9
|
+
- Simplify internal structure for `Client` class and modules.
|
10
|
+
|
3
11
|
## [0.3.0] - 2021-04-11
|
4
12
|
|
5
13
|
- Hand article with missing `excerpt`. ([#63](https://github.com/turadg/pocket-ruby/pull/63))
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pocket-ruby (0.
|
5
|
-
faraday (>= 0
|
4
|
+
pocket-ruby (0.4.0)
|
5
|
+
faraday (>= 1.0)
|
6
6
|
faraday_middleware
|
7
7
|
multi_json (~> 1.0, >= 1.0.3)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
+
addressable (2.7.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
14
|
ast (2.4.2)
|
15
|
+
crack (0.4.5)
|
16
|
+
rexml
|
13
17
|
docile (1.3.5)
|
14
18
|
faraday (1.3.0)
|
15
19
|
faraday-net_http (~> 1.0)
|
@@ -18,6 +22,7 @@ GEM
|
|
18
22
|
faraday-net_http (1.0.1)
|
19
23
|
faraday_middleware (1.0.0)
|
20
24
|
faraday (~> 1.0)
|
25
|
+
hashdiff (1.0.1)
|
21
26
|
multi_json (1.15.0)
|
22
27
|
multi_xml (0.6.0)
|
23
28
|
multipart-post (2.1.1)
|
@@ -25,6 +30,7 @@ GEM
|
|
25
30
|
parser (3.0.0.0)
|
26
31
|
ast (~> 2.4.1)
|
27
32
|
power_assert (2.0.0)
|
33
|
+
public_suffix (4.0.6)
|
28
34
|
rack (1.6.13)
|
29
35
|
rack-protection (1.5.5)
|
30
36
|
rack
|
@@ -65,6 +71,10 @@ GEM
|
|
65
71
|
power_assert
|
66
72
|
tilt (1.4.1)
|
67
73
|
unicode-display_width (2.0.0)
|
74
|
+
webmock (3.12.1)
|
75
|
+
addressable (>= 2.3.6)
|
76
|
+
crack (>= 0.3.2)
|
77
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
68
78
|
|
69
79
|
PLATFORMS
|
70
80
|
x86_64-darwin-19
|
@@ -78,6 +88,7 @@ DEPENDENCIES
|
|
78
88
|
sinatra (~> 1.3.3)
|
79
89
|
standard
|
80
90
|
test-unit
|
91
|
+
webmock
|
81
92
|
|
82
93
|
BUNDLED WITH
|
83
94
|
2.2.8
|
data/README.md
CHANGED
@@ -29,11 +29,14 @@ Below are some aspects of the Pocket API that aren't covered in the official doc
|
|
29
29
|
* For very long articles, the maximum reported `word_count` is 65535, even if the article is longer.
|
30
30
|
* If a `count` isn't specified, the `Retreive` call will return maximum of 5000 items.
|
31
31
|
* The API response may contain a number of undocumented fields, including:
|
32
|
-
* `domain_metadata`
|
33
32
|
* `amp_url`
|
33
|
+
* `domain_metadata`
|
34
|
+
* `is_index`
|
35
|
+
* `lang` ([ISO_639-1](https://en.wikipedia.org/wiki/ISO_639-1)?)
|
34
36
|
* `listen_duration_estimate`
|
35
|
-
* `time_to_read`
|
36
37
|
* `sort_id`
|
37
|
-
* `
|
38
|
+
* `time_to_read`
|
39
|
+
* `top_image_url`
|
38
40
|
* Every integer value is returned as a string, *except* for `time_to_read`, `listen_duration_estimate` and `sort_id`.
|
39
41
|
* The `time_to_read` is in minutes, but `listen_duration_estimate` is in seconds.
|
42
|
+
* If an article's `status` is `"2"` ('should be deleted') then most fields will not be present.
|
@@ -16,11 +16,11 @@ module Faraday
|
|
16
16
|
def on_complete(env)
|
17
17
|
case env[:status]
|
18
18
|
when 404
|
19
|
-
raise Faraday::
|
20
|
-
when 400
|
19
|
+
raise Faraday::ResourceNotFound, response_values(env)
|
20
|
+
when 400..403
|
21
21
|
raise Pocket::Error, env[:response_headers]["X-Error"]
|
22
22
|
when CLIENT_ERROR_STATUSES
|
23
|
-
raise Faraday::
|
23
|
+
raise Faraday::ClientError, response_values(env)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/lib/pocket-ruby.rb
CHANGED
@@ -15,15 +15,4 @@ module Pocket
|
|
15
15
|
def self.client(options = {})
|
16
16
|
Pocket::Client.new(options)
|
17
17
|
end
|
18
|
-
|
19
|
-
# Delegate to Pocket::Client
|
20
|
-
def self.method_missing(method, *args, &block)
|
21
|
-
return super unless client.respond_to?(method)
|
22
|
-
client.send(method, *args, &block)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Delegate to Pocket::Client
|
26
|
-
def self.respond_to_missing?(method)
|
27
|
-
client.respond_to?(method) || super
|
28
|
-
end
|
29
18
|
end
|
data/lib/pocket/article.rb
CHANGED
@@ -21,7 +21,7 @@ module Pocket
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def resolved_url
|
24
|
-
response.fetch("resolved_url")
|
24
|
+
response.fetch("resolved_url", nil)
|
25
25
|
end
|
26
26
|
|
27
27
|
def given_title
|
@@ -29,7 +29,7 @@ module Pocket
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def resolved_title
|
32
|
-
response.fetch("resolved_title")
|
32
|
+
response.fetch("resolved_title", nil)
|
33
33
|
end
|
34
34
|
|
35
35
|
def favorite?
|
@@ -46,6 +46,7 @@ module Pocket
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def article?
|
49
|
+
return false unless response["is_article"]
|
49
50
|
Integer(response.fetch("is_article")) == 1
|
50
51
|
end
|
51
52
|
|
data/lib/pocket/client.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
module Pocket
|
2
2
|
# Wrapper for the Pocket REST API
|
3
|
-
#
|
4
|
-
# @note All methods have been separated into modules and follow the same grouping used in {TODO:doc_URL the Pocket API Documentation}.
|
5
|
-
# @see TODO:doc_url
|
6
3
|
class Client < API
|
7
|
-
|
4
|
+
# http://getpocket.com/developer/docs/v3/add
|
5
|
+
# required params: url, consumer_key, access_token
|
6
|
+
def add params
|
7
|
+
response = connection.post("/v3/add", params)
|
8
|
+
response.body
|
9
|
+
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
# http://getpocket.com/developer/docs/v3/modify
|
12
|
+
# required params: actions, consumer_key, access_token
|
13
|
+
def modify actions
|
14
|
+
response = connection.post("/v3/send", {actions: actions})
|
15
|
+
response.body
|
16
|
+
end
|
17
|
+
|
18
|
+
# http://getpocket.com/developer/docs/v3/retrieve
|
19
|
+
# required params: consumer_key, access_token
|
20
|
+
def retrieve params = {}
|
21
|
+
response = connection.post("/v3/get", params)
|
22
|
+
response.body
|
23
|
+
end
|
12
24
|
end
|
13
25
|
end
|
data/lib/pocket/version.rb
CHANGED
data/pocket-ruby.gemspec
CHANGED
@@ -7,7 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.add_development_dependency("standard")
|
8
8
|
s.add_development_dependency("test-unit")
|
9
9
|
s.add_development_dependency("simplecov")
|
10
|
-
s.
|
10
|
+
s.add_development_dependency("webmock")
|
11
|
+
s.add_runtime_dependency("faraday", ">= 1.0")
|
11
12
|
s.add_runtime_dependency("faraday_middleware")
|
12
13
|
s.add_runtime_dependency("multi_json", ">= 1.0.3", "~> 1.0")
|
13
14
|
s.authors = ["Turadg Aleahmad", "Jason Ng PT", "Andy Waite"]
|
data/test/pocket/article_test.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
module Pocket
|
4
|
-
class
|
4
|
+
class ArticleTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@article = Pocket::Article.new(parsed_response)
|
7
|
+
end
|
8
|
+
|
5
9
|
test "from_json" do
|
6
10
|
json_string = File.read("test/fixtures/retreive.json")
|
7
11
|
article = Pocket::Article.from_json(json_string)
|
@@ -9,148 +13,163 @@ module Pocket
|
|
9
13
|
end
|
10
14
|
|
11
15
|
test "item_id" do
|
12
|
-
assert_equal 229279689, article.item_id
|
16
|
+
assert_equal 229279689, @article.item_id
|
13
17
|
end
|
14
18
|
|
15
19
|
test "given_url" do
|
16
|
-
assert_equal "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview?given", article.given_url
|
20
|
+
assert_equal "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview?given", @article.given_url
|
17
21
|
end
|
18
22
|
|
19
23
|
test "resolved_url" do
|
20
|
-
assert_equal "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview?resolved", article.resolved_url
|
24
|
+
assert_equal "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview?resolved", @article.resolved_url
|
25
|
+
end
|
26
|
+
|
27
|
+
test "resolved_url is nil is field not present" do
|
28
|
+
parsed_response.delete("resolved_url")
|
29
|
+
assert_nil @article.resolved_url
|
21
30
|
end
|
22
31
|
|
23
32
|
test "given_title" do
|
24
|
-
assert_equal "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", article.given_title
|
33
|
+
assert_equal "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", @article.given_title
|
25
34
|
end
|
26
35
|
|
27
36
|
test "resolved_title" do
|
28
|
-
assert_equal "The Massive Ryder Cup Preview", article.resolved_title
|
37
|
+
assert_equal "The Massive Ryder Cup Preview", @article.resolved_title
|
38
|
+
end
|
39
|
+
|
40
|
+
test "resolved_title is nil is field not present" do
|
41
|
+
parsed_response.delete("resolved_title")
|
42
|
+
assert_nil @article.resolved_title
|
29
43
|
end
|
30
44
|
|
31
45
|
test "favorite? is false is field is '0'" do
|
32
|
-
assert_equal false, article.favorite?
|
46
|
+
assert_equal false, @article.favorite?
|
33
47
|
end
|
34
48
|
|
35
49
|
test "status" do
|
36
|
-
assert_equal 0, article.status
|
50
|
+
assert_equal 0, @article.status
|
37
51
|
end
|
38
52
|
|
39
53
|
test "excerpt" do
|
40
|
-
assert_include article.excerpt, "list of things"
|
54
|
+
assert_include @article.excerpt, "list of things"
|
41
55
|
end
|
42
56
|
|
43
57
|
test "excerpt is nil if field not present" do
|
44
58
|
parsed_response.delete("excerpt")
|
45
|
-
assert_nil article.excerpt
|
59
|
+
assert_nil @article.excerpt
|
46
60
|
end
|
47
61
|
|
48
62
|
test "article?" do
|
49
|
-
assert article.article?
|
63
|
+
assert @article.article?
|
64
|
+
end
|
65
|
+
|
66
|
+
test "article? returns false if `is_article` field not present" do
|
67
|
+
parsed_response.delete("is_article")
|
68
|
+
refute @article.article?
|
50
69
|
end
|
51
70
|
|
52
71
|
test "has_image?" do
|
53
|
-
assert article.has_image?
|
72
|
+
assert @article.has_image?
|
54
73
|
end
|
55
74
|
|
56
75
|
test "image?" do
|
57
|
-
refute article.image?
|
76
|
+
refute @article.image?
|
58
77
|
end
|
59
78
|
|
60
79
|
test "has_video?" do
|
61
|
-
assert article.has_video?
|
80
|
+
assert @article.has_video?
|
62
81
|
end
|
63
82
|
|
64
83
|
test "video?" do
|
65
|
-
refute article.video?
|
84
|
+
refute @article.video?
|
66
85
|
end
|
67
86
|
|
68
87
|
test "word_count" do
|
69
|
-
assert_equal 3197, article.word_count
|
88
|
+
assert_equal 3197, @article.word_count
|
70
89
|
end
|
71
90
|
|
72
91
|
test "word_count is nil is field not present" do
|
73
92
|
parsed_response.delete("word_count")
|
74
|
-
assert_nil article.word_count
|
93
|
+
assert_nil @article.word_count
|
75
94
|
end
|
76
95
|
|
77
96
|
test "resolved_id" do
|
78
|
-
assert_equal 229279689, article.resolved_id
|
97
|
+
assert_equal 229279689, @article.resolved_id
|
79
98
|
end
|
80
99
|
|
81
100
|
test "thumbnail" do
|
82
|
-
assert_equal "https://example.com/image.png", article.thumbnail
|
101
|
+
assert_equal "https://example.com/image.png", @article.thumbnail
|
83
102
|
end
|
84
103
|
|
85
104
|
test "time_added" do
|
86
|
-
assert_equal Time.utc(2021, 4, 3, 1, 23, 12), article.time_added
|
105
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 12), @article.time_added
|
87
106
|
end
|
88
107
|
|
89
108
|
test "time_added is nil if field not present" do
|
90
109
|
parsed_response.delete("time_added")
|
91
|
-
assert_nil article.time_added
|
110
|
+
assert_nil @article.time_added
|
92
111
|
end
|
93
112
|
|
94
113
|
test "time_updated" do
|
95
|
-
assert_equal Time.utc(2021, 4, 3, 1, 23, 13), article.time_updated
|
114
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 13), @article.time_updated
|
96
115
|
end
|
97
116
|
|
98
117
|
test "time_updated is nil if field not present" do
|
99
118
|
parsed_response.delete("time_updated")
|
100
|
-
assert_nil article.time_updated
|
119
|
+
assert_nil @article.time_updated
|
101
120
|
end
|
102
121
|
|
103
122
|
test "time_read" do
|
104
|
-
assert_equal Time.utc(2021, 4, 3, 1, 23, 14), article.time_read
|
123
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 14), @article.time_read
|
105
124
|
end
|
106
125
|
|
107
126
|
test "time_read is nil if field is not present" do
|
108
127
|
parsed_response.delete("time_read")
|
109
|
-
assert_nil article.time_read
|
128
|
+
assert_nil @article.time_read
|
110
129
|
end
|
111
130
|
|
112
131
|
test "time_read is nil if field is zero" do
|
113
132
|
parsed_response["time_read"] = "0"
|
114
|
-
assert_nil article.time_read
|
133
|
+
assert_nil @article.time_read
|
115
134
|
end
|
116
135
|
|
117
136
|
test "favorited?" do
|
118
|
-
assert article.favorited?
|
137
|
+
assert @article.favorited?
|
119
138
|
end
|
120
139
|
|
121
140
|
test "time_favorited" do
|
122
|
-
assert_equal Time.utc(2021, 4, 3, 1, 23, 15), article.time_favorited
|
141
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 15), @article.time_favorited
|
123
142
|
end
|
124
143
|
|
125
144
|
test "time_favorited is nil if field not present" do
|
126
145
|
parsed_response.delete("time_favorited")
|
127
|
-
assert_nil article.time_favorited
|
146
|
+
assert_nil @article.time_favorited
|
128
147
|
end
|
129
148
|
|
130
149
|
test "time_favorited is nil if field is zero" do
|
131
150
|
parsed_response["time_favorited"] = "0"
|
132
|
-
assert_nil article.time_favorited
|
151
|
+
assert_nil @article.time_favorited
|
133
152
|
end
|
134
153
|
|
135
154
|
test "read?" do
|
136
|
-
assert article.read?
|
155
|
+
assert @article.read?
|
137
156
|
end
|
138
157
|
|
139
158
|
test "read_url" do
|
140
|
-
assert_equal "https://getpocket.com/read/229279689", article.read_url
|
159
|
+
assert_equal "https://getpocket.com/read/229279689", @article.read_url
|
141
160
|
end
|
142
161
|
|
143
162
|
test "tags" do
|
144
|
-
assert_equal ["my-tag-1", "my-tag-2"], article.tags
|
163
|
+
assert_equal ["my-tag-1", "my-tag-2"], @article.tags
|
145
164
|
end
|
146
165
|
|
147
166
|
test "tags returns an empty array if there are no tags" do
|
148
167
|
parsed_response.delete("tags")
|
149
|
-
assert_equal [], article.tags
|
168
|
+
assert_equal [], @article.tags
|
150
169
|
end
|
151
170
|
|
152
171
|
test "authors" do
|
153
|
-
result = article.authors
|
172
|
+
result = @article.authors
|
154
173
|
assert_equal 1, result.size
|
155
174
|
assert_equal "Stephen King", result.first.name
|
156
175
|
assert_equal 62344201, result.first.id
|
@@ -159,53 +178,49 @@ module Pocket
|
|
159
178
|
|
160
179
|
test "authors returns an empty array if there are no tags" do
|
161
180
|
parsed_response.delete("authors")
|
162
|
-
assert_equal [], article.authors
|
181
|
+
assert_equal [], @article.authors
|
163
182
|
end
|
164
183
|
|
165
184
|
test "time_to_read" do
|
166
|
-
assert_equal 14, article.time_to_read
|
185
|
+
assert_equal 14, @article.time_to_read
|
167
186
|
end
|
168
187
|
|
169
188
|
test "time_to_read returns nil if field not present" do
|
170
189
|
parsed_response.delete("time_to_read")
|
171
|
-
assert_nil article.time_to_read
|
190
|
+
assert_nil @article.time_to_read
|
172
191
|
end
|
173
192
|
|
174
193
|
test "time_to_read returns nil if value is 0" do
|
175
194
|
parsed_response["time_to_read"] = 0
|
176
|
-
assert_nil article.time_to_read
|
195
|
+
assert_nil @article.time_to_read
|
177
196
|
end
|
178
197
|
|
179
198
|
test "time_to_read_category" do
|
180
199
|
parsed_response.delete("time_to_read")
|
181
|
-
assert_nil article.time_to_read_category
|
200
|
+
assert_nil @article.time_to_read_category
|
182
201
|
|
183
202
|
parsed_response["time_to_read"] = 0
|
184
|
-
assert_nil article.time_to_read_category
|
203
|
+
assert_nil @article.time_to_read_category
|
185
204
|
|
186
205
|
parsed_response["time_to_read"] = 25
|
187
|
-
assert_equal "very_long", article.time_to_read_category
|
206
|
+
assert_equal "very_long", @article.time_to_read_category
|
188
207
|
|
189
208
|
parsed_response["time_to_read"] = 15
|
190
|
-
assert_equal "long", article.time_to_read_category
|
209
|
+
assert_equal "long", @article.time_to_read_category
|
191
210
|
|
192
211
|
parsed_response["time_to_read"] = 8
|
193
|
-
assert_equal "medium", article.time_to_read_category
|
212
|
+
assert_equal "medium", @article.time_to_read_category
|
194
213
|
|
195
214
|
parsed_response["time_to_read"] = 3
|
196
|
-
assert_equal "quick", article.time_to_read_category
|
215
|
+
assert_equal "quick", @article.time_to_read_category
|
197
216
|
end
|
198
217
|
|
199
218
|
test "domain_metadata" do
|
200
|
-
assert_equal "The Verge", article.domain_metadata.name
|
219
|
+
assert_equal "The Verge", @article.domain_metadata.name
|
201
220
|
end
|
202
221
|
|
203
222
|
private
|
204
223
|
|
205
|
-
def article
|
206
|
-
@article ||= Pocket::Article.new(parsed_response)
|
207
|
-
end
|
208
|
-
|
209
224
|
def parsed_response
|
210
225
|
@parsed_response ||= JSON.parse(File.read("test/fixtures/retreive.json"))
|
211
226
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "webmock/test_unit"
|
3
|
+
|
4
|
+
class ClientTest < Test::Unit::TestCase
|
5
|
+
test "retrieve" do
|
6
|
+
stub_request(:post, "https://getpocket.com/v3/get")
|
7
|
+
.with(
|
8
|
+
body: "{\"detailType\":\"complete\",\"count\":1,\"consumer_key\":null,\"access_token\":\"access_token\"}",
|
9
|
+
headers: {
|
10
|
+
"Accept" => "*/*",
|
11
|
+
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
12
|
+
"Content-Type" => "application/json",
|
13
|
+
"User-Agent" => "Pocket Ruby Gem #{Pocket::VERSION}"
|
14
|
+
}
|
15
|
+
)
|
16
|
+
.to_return(status: 200, body: "body response", headers: {})
|
17
|
+
client = Pocket.client(access_token: "access_token")
|
18
|
+
|
19
|
+
result = client.retrieve(detailType: :complete, count: 1)
|
20
|
+
|
21
|
+
assert_equal "body response", result
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pocket-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Turadg Aleahmad
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-04-
|
13
|
+
date: 2021-04-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
@@ -96,20 +96,34 @@ dependencies:
|
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: webmock
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
99
113
|
- !ruby/object:Gem::Dependency
|
100
114
|
name: faraday
|
101
115
|
requirement: !ruby/object:Gem::Requirement
|
102
116
|
requirements:
|
103
117
|
- - ">="
|
104
118
|
- !ruby/object:Gem::Version
|
105
|
-
version: '0
|
119
|
+
version: '1.0'
|
106
120
|
type: :runtime
|
107
121
|
prerelease: false
|
108
122
|
version_requirements: !ruby/object:Gem::Requirement
|
109
123
|
requirements:
|
110
124
|
- - ">="
|
111
125
|
- !ruby/object:Gem::Version
|
112
|
-
version: '0
|
126
|
+
version: '1.0'
|
113
127
|
- !ruby/object:Gem::Dependency
|
114
128
|
name: faraday_middleware
|
115
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,9 +184,6 @@ files:
|
|
170
184
|
- lib/pocket/article.rb
|
171
185
|
- lib/pocket/author.rb
|
172
186
|
- lib/pocket/client.rb
|
173
|
-
- lib/pocket/client/add.rb
|
174
|
-
- lib/pocket/client/modify.rb
|
175
|
-
- lib/pocket/client/retrieve.rb
|
176
187
|
- lib/pocket/configuration.rb
|
177
188
|
- lib/pocket/connection.rb
|
178
189
|
- lib/pocket/domain_metadata.rb
|
@@ -182,6 +193,7 @@ files:
|
|
182
193
|
- pocket-ruby.gemspec
|
183
194
|
- test/fixtures/retreive.json
|
184
195
|
- test/pocket/article_test.rb
|
196
|
+
- test/pocket/client_test.rb
|
185
197
|
- test/pocket/version_test.rb
|
186
198
|
- test/test_helper.rb
|
187
199
|
homepage: https://github.com/turadg/pocket-ruby
|
@@ -209,5 +221,6 @@ summary: Ruby wrapper for the Pocket API v3
|
|
209
221
|
test_files:
|
210
222
|
- test/fixtures/retreive.json
|
211
223
|
- test/pocket/article_test.rb
|
224
|
+
- test/pocket/client_test.rb
|
212
225
|
- test/pocket/version_test.rb
|
213
226
|
- test/test_helper.rb
|
data/lib/pocket/client/add.rb
DELETED
data/lib/pocket/client/modify.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module Pocket
|
2
|
-
class Client
|
3
|
-
# http://getpocket.com/developer/docs/v3/modify
|
4
|
-
module Modify
|
5
|
-
# required params: actions, consumer_key, access_token
|
6
|
-
def modify actions
|
7
|
-
response = connection.post("/v3/send", {actions: actions})
|
8
|
-
response.body
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Pocket
|
2
|
-
class Client
|
3
|
-
# http://getpocket.com/developer/docs/v3/retrieve
|
4
|
-
module Retrieve
|
5
|
-
# required params: consumer_key, access_token
|
6
|
-
def retrieve params = {}
|
7
|
-
response = connection.post("/v3/get", params)
|
8
|
-
response.body
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|