pocket-ruby 0.1.0 → 0.2.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 +4 -0
- data/Gemfile.lock +1 -1
- data/lib/pocket-ruby.rb +1 -0
- data/lib/pocket/article.rb +8 -0
- data/lib/pocket/author.rb +23 -0
- data/lib/pocket/version.rb +1 -1
- data/test/fixtures/retreive.json +19 -1
- data/test/pocket/article_test.rb +22 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c29a4044db768b6c30927048ce55ac9ee329a66008cab931c2888c7976ad47
|
4
|
+
data.tar.gz: a1b61bc70be32418276c523ce08ebf88d1110762f07ce397aacb89aca40e758c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24755f21d67f9f4408d24615712002b7380a18ac959a6947cd2983a01278c0c58334a1e914742902768b32aaec76f9c37436ee19e0a5d60c93015d15c4727bcc
|
7
|
+
data.tar.gz: d21a10db04f4bb92cda2cbf9e9014019724bf850aabe784d2b7234d301dc2200c2e0d600bec44112118b7fd1ebb5fa0e77e8cfc2fdfa3a298901ab01066adb04
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.0] - 2021-04-03
|
4
|
+
|
5
|
+
- Add support for authors and tags in `Pocket::Article` ([#44](https://github.com/turadg/pocket-ruby/pull/44))
|
6
|
+
|
3
7
|
## [0.1.0] - 2021-04-03
|
4
8
|
|
5
9
|
- Add `Pocket::Article` for parsing an article response ([#39](https://github.com/turadg/pocket-ruby/pull/39))
|
data/Gemfile.lock
CHANGED
data/lib/pocket-ruby.rb
CHANGED
@@ -3,6 +3,7 @@ require File.expand_path("../pocket/configuration", __FILE__)
|
|
3
3
|
require File.expand_path("../pocket/api", __FILE__)
|
4
4
|
require File.expand_path("../pocket/client", __FILE__)
|
5
5
|
require File.expand_path("../pocket/article", __FILE__)
|
6
|
+
require File.expand_path("../pocket/author", __FILE__)
|
6
7
|
|
7
8
|
module Pocket
|
8
9
|
extend Configuration
|
data/lib/pocket/article.rb
CHANGED
@@ -107,5 +107,13 @@ module Pocket
|
|
107
107
|
def read_url
|
108
108
|
"https://getpocket.com/read/#{item_id}"
|
109
109
|
end
|
110
|
+
|
111
|
+
def tags
|
112
|
+
Hash(response["tags"]).values.map { |tag| tag["tag"] }
|
113
|
+
end
|
114
|
+
|
115
|
+
def authors
|
116
|
+
Hash(response["authors"]).values.map { |value| Pocket::Author.new(value) }
|
117
|
+
end
|
110
118
|
end
|
111
119
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Pocket
|
2
|
+
class Author
|
3
|
+
def initialize(response)
|
4
|
+
@response = response
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
Integer(response.fetch("author_id"))
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
response.fetch("name")
|
13
|
+
end
|
14
|
+
|
15
|
+
def url
|
16
|
+
response.fetch("url")
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :response
|
22
|
+
end
|
23
|
+
end
|
data/lib/pocket/version.rb
CHANGED
data/test/fixtures/retreive.json
CHANGED
@@ -38,5 +38,23 @@
|
|
38
38
|
"type": "1",
|
39
39
|
"vid": "Er34PbFkVGk"
|
40
40
|
}
|
41
|
-
}
|
41
|
+
},
|
42
|
+
"tags":{
|
43
|
+
"bookmark":{
|
44
|
+
"item_id":"229279689",
|
45
|
+
"tag":"my-tag-1"
|
46
|
+
},
|
47
|
+
"gtd":{
|
48
|
+
"item_id":"229279689",
|
49
|
+
"tag":"my-tag-2"
|
50
|
+
}
|
51
|
+
},
|
52
|
+
"authors":{
|
53
|
+
"62344201":{
|
54
|
+
"item_id":"229279689",
|
55
|
+
"author_id":"62344201",
|
56
|
+
"name":"Stephen King",
|
57
|
+
"url":"https://example.com/author"
|
58
|
+
}
|
59
|
+
}
|
42
60
|
}
|
data/test/pocket/article_test.rb
CHANGED
@@ -120,6 +120,28 @@ module Pocket
|
|
120
120
|
assert_equal "https://getpocket.com/read/229279689", article.read_url
|
121
121
|
end
|
122
122
|
|
123
|
+
test "tags" do
|
124
|
+
assert_equal ["my-tag-1", "my-tag-2"], article.tags
|
125
|
+
end
|
126
|
+
|
127
|
+
test "tags returns an empty array if there are no tags" do
|
128
|
+
parsed_response.delete("tags")
|
129
|
+
assert_equal [], article.tags
|
130
|
+
end
|
131
|
+
|
132
|
+
test "authors" do
|
133
|
+
result = article.authors
|
134
|
+
assert_equal 1, result.size
|
135
|
+
assert_equal "Stephen King", result.first.name
|
136
|
+
assert_equal 62344201, result.first.id
|
137
|
+
assert_equal "https://example.com/author", result.first.url
|
138
|
+
end
|
139
|
+
|
140
|
+
test "authors returns an empty array if there are no tags" do
|
141
|
+
parsed_response.delete("authors")
|
142
|
+
assert_equal [], article.authors
|
143
|
+
end
|
144
|
+
|
123
145
|
private
|
124
146
|
|
125
147
|
def article
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Turadg Aleahmad
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/pocket-ruby.rb
|
169
169
|
- lib/pocket/api.rb
|
170
170
|
- lib/pocket/article.rb
|
171
|
+
- lib/pocket/author.rb
|
171
172
|
- lib/pocket/client.rb
|
172
173
|
- lib/pocket/client/add.rb
|
173
174
|
- lib/pocket/client/modify.rb
|