pocket-ruby 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 820f73644ee1f21cea8033e70e5c3c038b6dc061cb9e05b36c3ede86421763e1
4
- data.tar.gz: 30744f3d1257e1d7fcee9cda79abf518f4277d996c8716720ec6cc1bbbce59f8
3
+ metadata.gz: 94c29a4044db768b6c30927048ce55ac9ee329a66008cab931c2888c7976ad47
4
+ data.tar.gz: a1b61bc70be32418276c523ce08ebf88d1110762f07ce397aacb89aca40e758c
5
5
  SHA512:
6
- metadata.gz: acb0b74a3bd7df194b1ed532dc7f54a1eb860d5632f1854aab803c905c9f8c4c7d3fe23b42553507b82165776a892d93ac38f98874cc5c811cbb81dfcd34b76c
7
- data.tar.gz: e2526ed17125c7c51be1d8baaaa1d30e610858c0968b03348e875aeec75a9384cc566b65b0ca5c02ab85aff5e0288f3fc8d02ce4b364a99e98a820a11debe830
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pocket-ruby (0.1.0)
4
+ pocket-ruby (0.2.0)
5
5
  faraday (>= 0.7)
6
6
  faraday_middleware
7
7
  multi_json (~> 1.0, >= 1.0.3)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Pocket
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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
  }
@@ -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.1.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