pocket-ruby-andyw8 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40c39385a1a1c1eb0ce3ecc48f84d4983607043e25654aeac1b871ee3467b954
4
- data.tar.gz: e9b1681b23936e9ae5ac6f18952a6e43a82765912685d98ef72c3999a60f05b3
3
+ metadata.gz: 3d6b96511c25bfe6d1d7dd43d90feebce20b58f30cbdbca888ccc25c9af67f7f
4
+ data.tar.gz: ce4c3fdfbcfb50ba911e29cedf9a8c97716b82065e717039c46fed8f48766d84
5
5
  SHA512:
6
- metadata.gz: f382487e138e17d21d59cb098169e7a500a84e0189e5fba3615bfc50f01dfa25dc4ea521139d45c1dce125bb8ac44437d23ffb852edea1479c8badaa7573bc96
7
- data.tar.gz: b7f12023a1f33377c5a47798fcb9972b99561c7a50543d6df73cfc8db729c3b75625d4d1a5f94dae2f3dc6a916334492a40dba693fc73bb5b7146f27b7b7ed27
6
+ metadata.gz: '0984bf105d651453f702918544995ddecd06e0fa16ff6c3de226fcd60d75cdf1f5c92889c3b40967dc83f4210ddf948c383d284f395eadaa01f6bb89848a8111'
7
+ data.tar.gz: 1ceda496e1810c68f4d0ca1db17230ca90d0e92924c23f028ea904a352ac179f2cafaf04ab3716c0c8064d9e6253373af776a5ae1ff83b6bcf9874b94f7a94b0
@@ -11,8 +11,6 @@ jobs:
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
13
13
  ruby-version: 2.6.6
14
+ bundler-cache: true
14
15
  - name: Run the default task
15
- run: |
16
- gem install bundler -v 2.2.8
17
- bundle install
18
- bundle exec rake
16
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.0] - 2021-03-28
4
+
5
+ - Add class for parsing Article response ([#13](https://github.com/andyw8/pocket-ruby/pull/13))
6
+ - Fix Pocket::Client::Retrieve#retrieve params default ([#12](https://github.com/andyw8/pocket-ruby/pull/12))
7
+
3
8
  ## [0.0.8] - 2021-03-28
4
9
 
5
10
  - Remove unused Hashie dependency ([#3](https://github.com/andyw8/pocket-ruby/pull/3))
data/Gemfile.lock CHANGED
@@ -1,10 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pocket-ruby-andyw8 (0.0.7)
4
+ pocket-ruby-andyw8 (0.1.0)
5
5
  faraday (>= 0.7)
6
6
  faraday_middleware
7
- hashie (>= 0.4.0)
8
7
  multi_json (~> 1.0, >= 1.0.3)
9
8
 
10
9
  GEM
@@ -18,14 +17,13 @@ GEM
18
17
  faraday-net_http (1.0.1)
19
18
  faraday_middleware (1.0.0)
20
19
  faraday (~> 1.0)
21
- hashie (4.1.0)
22
20
  multi_json (1.15.0)
23
21
  multi_xml (0.6.0)
24
22
  multipart-post (2.1.1)
25
23
  parallel (1.20.1)
26
24
  parser (3.0.0.0)
27
25
  ast (~> 2.4.1)
28
- power_assert (1.1.3)
26
+ power_assert (2.0.0)
29
27
  rack (1.6.13)
30
28
  rack-protection (1.5.5)
31
29
  rack
@@ -58,13 +56,14 @@ GEM
58
56
  rubocop-performance (= 1.10.1)
59
57
  standardrb (1.0.0)
60
58
  standard
61
- test-unit (3.2.9)
59
+ test-unit (3.4.0)
62
60
  power_assert
63
61
  tilt (1.4.1)
64
62
  unicode-display_width (2.0.0)
65
63
 
66
64
  PLATFORMS
67
65
  x86_64-darwin-19
66
+ x86_64-linux
68
67
 
69
68
  DEPENDENCIES
70
69
  multi_xml
data/lib/pocket-ruby.rb CHANGED
@@ -2,6 +2,7 @@ require File.expand_path("../pocket/error", __FILE__)
2
2
  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
+ require File.expand_path("../pocket/article", __FILE__)
5
6
 
6
7
  module Pocket
7
8
  extend Configuration
@@ -0,0 +1,113 @@
1
+ require "json"
2
+
3
+ module Pocket
4
+ class Article
5
+ attr_reader :response
6
+
7
+ def initialize(response)
8
+ @response = response
9
+ end
10
+
11
+ def item_id
12
+ Integer(parsed_response.fetch("item_id"))
13
+ end
14
+
15
+ def given_url
16
+ parsed_response.fetch("given_url")
17
+ end
18
+
19
+ def resolved_url
20
+ parsed_response.fetch("resolved_url")
21
+ end
22
+
23
+ def given_title
24
+ parsed_response.fetch("given_title")
25
+ end
26
+
27
+ def resolved_title
28
+ parsed_response.fetch("resolved_title")
29
+ end
30
+
31
+ def favorite?
32
+ Integer(parsed_response.fetch("favorite")) == 1
33
+ end
34
+
35
+ def status
36
+ Integer(parsed_response.fetch("status"))
37
+ end
38
+
39
+ def excerpt
40
+ parsed_response.fetch("excerpt")
41
+ end
42
+
43
+ def article?
44
+ Integer(parsed_response.fetch("is_article")) == 1
45
+ end
46
+
47
+ def has_image?
48
+ Integer(parsed_response.fetch("has_image")) == 1
49
+ end
50
+
51
+ def image?
52
+ Integer(parsed_response.fetch("has_image")) == 2
53
+ end
54
+
55
+ def has_video?
56
+ Integer(parsed_response.fetch("has_video")) == 1
57
+ end
58
+
59
+ def video?
60
+ Integer(parsed_response.fetch("has_video")) == 2
61
+ end
62
+
63
+ def word_count
64
+ Integer(parsed_response.fetch("word_count"))
65
+ end
66
+
67
+ def resolved_id
68
+ Integer(parsed_response.fetch("resolved_id"))
69
+ end
70
+
71
+ def thumbnail
72
+ parsed_response.fetch("top_image_url", "")
73
+ end
74
+
75
+ def time_added
76
+ return nil unless parsed_response["time_added"]
77
+ Time.at(Integer(parsed_response["time_added"]))
78
+ end
79
+
80
+ def time_updated
81
+ return nil unless parsed_response["time_updated"]
82
+ Time.at(Integer(parsed_response["time_updated"]))
83
+ end
84
+
85
+ def time_read
86
+ return nil unless parsed_response["time_read"]
87
+ Time.at(Integer(parsed_response["time_read"]))
88
+ end
89
+
90
+ def favorited?
91
+ Integer(parsed_response["time_favorited"]) > 0
92
+ end
93
+
94
+ def time_favorited
95
+ return nil unless parsed_response["time_favorited"]
96
+ Time.at(Integer(parsed_response["time_favorited"]))
97
+ end
98
+
99
+ def read?
100
+ Integer(parsed_response["time_read"]) > 0
101
+ end
102
+
103
+ def read_url
104
+ "https://getpocket.com/read/#{item_id}"
105
+ end
106
+
107
+ private
108
+
109
+ def parsed_response
110
+ @parsed_response ||= JSON.parse(response)
111
+ end
112
+ end
113
+ end
@@ -3,7 +3,7 @@ module Pocket
3
3
  # http://getpocket.com/developer/docs/v3/retrieve
4
4
  module Retrieve
5
5
  # required params: consumer_key, access_token
6
- def retrieve params = []
6
+ def retrieve params = {}
7
7
  response = connection.post("/v3/get", params)
8
8
  response.body
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Pocket
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
data/pocket-ruby.gemspec CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.homepage = "https://github.com/turadg/pocket-ruby"
18
18
  s.name = "pocket-ruby-andyw8"
19
- s.platform = Gem::Platform::RUBY
20
19
  s.require_paths = ["lib"]
21
20
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
22
21
  s.rubyforge_project = s.name
@@ -0,0 +1,37 @@
1
+ {
2
+ "item_id": "229279689",
3
+ "resolved_id": "229279689",
4
+ "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview",
5
+ "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland",
6
+ "favorite": "0",
7
+ "status": "0",
8
+ "resolved_title": "The Massive Ryder Cup Preview",
9
+ "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview",
10
+ "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.",
11
+ "is_article": "1",
12
+ "has_video": "1",
13
+ "has_image": "1",
14
+ "word_count": "3197",
15
+ "images": {
16
+ "1": {
17
+ "item_id": "229279689",
18
+ "image_id": "1",
19
+ "src": "http://a.espncdn.com/combiner/i?img=/photo/2012/0927/grant_g_ryder_cr_640.jpg&w=640&h=360",
20
+ "width": "0",
21
+ "height": "0",
22
+ "credit": "Jamie Squire/Getty Images",
23
+ "caption": ""
24
+ }
25
+ },
26
+ "videos": {
27
+ "1": {
28
+ "item_id": "229279689",
29
+ "video_id": "1",
30
+ "src": "http://www.youtube.com/v/Er34PbFkVGk?version=3&hl=en_US&rel=0",
31
+ "width": "420",
32
+ "height": "315",
33
+ "type": "1",
34
+ "vid": "Er34PbFkVGk"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,14 @@
1
+ require "test_helper"
2
+
3
+ module Pocket
4
+ class VersionTest < Test::Unit::TestCase
5
+ def test_item_id
6
+ pa = Pocket::Article.new(full_response)
7
+ assert_equal 229279689, pa.item_id
8
+ end
9
+
10
+ def full_response
11
+ @full_response ||= File.read("test/fixtures/retreive.json")
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pocket-ruby-andyw8
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Turadg Aleahmad
@@ -153,6 +153,7 @@ files:
153
153
  - lib/faraday/raise_pocket_error.rb
154
154
  - lib/pocket-ruby.rb
155
155
  - lib/pocket/api.rb
156
+ - lib/pocket/article.rb
156
157
  - lib/pocket/client.rb
157
158
  - lib/pocket/client/add.rb
158
159
  - lib/pocket/client/modify.rb
@@ -163,6 +164,8 @@ files:
163
164
  - lib/pocket/oauth.rb
164
165
  - lib/pocket/version.rb
165
166
  - pocket-ruby.gemspec
167
+ - test/fixtures/retreive.json
168
+ - test/pocket/article_test.rb
166
169
  - test/pocket/version_test.rb
167
170
  - test/test_helper.rb
168
171
  homepage: https://github.com/turadg/pocket-ruby
@@ -188,5 +191,7 @@ signing_key:
188
191
  specification_version: 4
189
192
  summary: Ruby wrapper for the Pocket API v3
190
193
  test_files:
194
+ - test/fixtures/retreive.json
195
+ - test/pocket/article_test.rb
191
196
  - test/pocket/version_test.rb
192
197
  - test/test_helper.rb