pocket-ruby 0.0.6 → 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 +5 -5
- data/.github/workflows/changelog-checker.yml +19 -0
- data/.github/workflows/tests.yml +16 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +83 -0
- data/README.md +0 -10
- data/Rakefile +24 -20
- data/demo-server.rb +15 -15
- data/lib/faraday/pocket_oauth.rb +4 -4
- data/lib/faraday/raise_pocket_error.rb +5 -6
- data/lib/pocket-ruby.rb +9 -7
- data/lib/pocket/api.rb +4 -4
- data/lib/pocket/article.rb +119 -0
- data/lib/pocket/author.rb +23 -0
- data/lib/pocket/client.rb +1 -1
- data/lib/pocket/client/retrieve.rb +1 -1
- data/lib/pocket/configuration.rb +14 -13
- data/lib/pocket/connection.rb +8 -8
- data/lib/pocket/oauth.rb +14 -14
- data/lib/pocket/version.rb +1 -1
- data/pocket-ruby.gemspec +19 -17
- data/test/fixtures/retreive.json +60 -0
- data/test/pocket/article_test.rb +155 -0
- data/test/pocket/version_test.rb +9 -0
- data/test/test_helper.rb +11 -0
- metadata +84 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
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
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: changelog-checker
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
name: Check Actions
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v1
|
|
13
|
+
- name: Changelog check
|
|
14
|
+
uses: Zomzog/changelog-checker@v1.2.0
|
|
15
|
+
with:
|
|
16
|
+
fileName: CHANGELOG.md
|
|
17
|
+
checksNotification: Simple
|
|
18
|
+
env:
|
|
19
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on: [push,pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v2
|
|
10
|
+
- name: Set up Ruby
|
|
11
|
+
uses: ruby/setup-ruby@v1
|
|
12
|
+
with:
|
|
13
|
+
ruby-version: 2.6.6
|
|
14
|
+
bundler-cache: true
|
|
15
|
+
- name: Run the default task
|
|
16
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## [Unreleased]
|
|
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
|
+
|
|
7
|
+
## [0.1.0] - 2021-04-03
|
|
8
|
+
|
|
9
|
+
- Add `Pocket::Article` for parsing an article response ([#39](https://github.com/turadg/pocket-ruby/pull/39))
|
|
10
|
+
- Fix Pocket::Client::Retrieve#retrieve params default ([#21](https://github.com/turadg/pocket-ruby/pull/21))
|
|
11
|
+
|
|
12
|
+
## [0.0.9] - 2021-04-01
|
|
13
|
+
|
|
14
|
+
- Actually remove unused Hashie dependency ([#35](https://github.com/turadg/pocket-ruby/pull/35))
|
|
15
|
+
|
|
16
|
+
## [0.0.8] - 2021-03-31
|
|
17
|
+
|
|
18
|
+
- Fix Ruby warnings ([#32](https://github.com/turadg/pocket-ruby/pull/32))
|
|
19
|
+
- Remove unused Hashie dependency ([#31](https://github.com/turadg/pocket-ruby/pull/31))
|
|
20
|
+
|
|
21
|
+
## [0.0.7] - 2021-03-29
|
|
22
|
+
|
|
23
|
+
- Relax `faraday_middleware` version constraint ([#25](https://github.com/turadg/pocket-ruby/pull/25))
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
pocket-ruby (0.2.0)
|
|
5
|
+
faraday (>= 0.7)
|
|
6
|
+
faraday_middleware
|
|
7
|
+
multi_json (~> 1.0, >= 1.0.3)
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: http://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
ast (2.4.2)
|
|
13
|
+
docile (1.3.5)
|
|
14
|
+
faraday (1.3.0)
|
|
15
|
+
faraday-net_http (~> 1.0)
|
|
16
|
+
multipart-post (>= 1.2, < 3)
|
|
17
|
+
ruby2_keywords
|
|
18
|
+
faraday-net_http (1.0.1)
|
|
19
|
+
faraday_middleware (1.0.0)
|
|
20
|
+
faraday (~> 1.0)
|
|
21
|
+
multi_json (1.15.0)
|
|
22
|
+
multi_xml (0.6.0)
|
|
23
|
+
multipart-post (2.1.1)
|
|
24
|
+
parallel (1.20.1)
|
|
25
|
+
parser (3.0.0.0)
|
|
26
|
+
ast (~> 2.4.1)
|
|
27
|
+
power_assert (2.0.0)
|
|
28
|
+
rack (1.6.13)
|
|
29
|
+
rack-protection (1.5.5)
|
|
30
|
+
rack
|
|
31
|
+
rainbow (3.0.0)
|
|
32
|
+
rake (13.0.3)
|
|
33
|
+
regexp_parser (2.1.1)
|
|
34
|
+
rexml (3.2.4)
|
|
35
|
+
rubocop (1.11.0)
|
|
36
|
+
parallel (~> 1.10)
|
|
37
|
+
parser (>= 3.0.0.0)
|
|
38
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
39
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
40
|
+
rexml
|
|
41
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
42
|
+
ruby-progressbar (~> 1.7)
|
|
43
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
44
|
+
rubocop-ast (1.4.1)
|
|
45
|
+
parser (>= 2.7.1.5)
|
|
46
|
+
rubocop-performance (1.10.1)
|
|
47
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
48
|
+
rubocop-ast (>= 0.4.0)
|
|
49
|
+
ruby-progressbar (1.11.0)
|
|
50
|
+
ruby2_keywords (0.0.4)
|
|
51
|
+
simplecov (0.21.2)
|
|
52
|
+
docile (~> 1.1)
|
|
53
|
+
simplecov-html (~> 0.11)
|
|
54
|
+
simplecov_json_formatter (~> 0.1)
|
|
55
|
+
simplecov-html (0.12.3)
|
|
56
|
+
simplecov_json_formatter (0.1.2)
|
|
57
|
+
sinatra (1.3.6)
|
|
58
|
+
rack (~> 1.4)
|
|
59
|
+
rack-protection (~> 1.3)
|
|
60
|
+
tilt (~> 1.3, >= 1.3.3)
|
|
61
|
+
standard (1.0.4)
|
|
62
|
+
rubocop (= 1.11.0)
|
|
63
|
+
rubocop-performance (= 1.10.1)
|
|
64
|
+
test-unit (3.4.0)
|
|
65
|
+
power_assert
|
|
66
|
+
tilt (1.4.1)
|
|
67
|
+
unicode-display_width (2.0.0)
|
|
68
|
+
|
|
69
|
+
PLATFORMS
|
|
70
|
+
x86_64-darwin-19
|
|
71
|
+
x86_64-linux
|
|
72
|
+
|
|
73
|
+
DEPENDENCIES
|
|
74
|
+
multi_xml
|
|
75
|
+
pocket-ruby!
|
|
76
|
+
rake
|
|
77
|
+
simplecov
|
|
78
|
+
sinatra (~> 1.3.3)
|
|
79
|
+
standard
|
|
80
|
+
test-unit
|
|
81
|
+
|
|
82
|
+
BUNDLED WITH
|
|
83
|
+
2.2.8
|
data/README.md
CHANGED
|
@@ -19,13 +19,3 @@ Just clone the repo here and refer to the demo-server.rb file for examples on ho
|
|
|
19
19
|
Pocket-Ruby can be installed via the gem, ```gem install pocket-ruby```
|
|
20
20
|
|
|
21
21
|
Or via bundler, ```gem 'pocket-ruby'```
|
|
22
|
-
|
|
23
|
-
# For v0.0.5 and earlier
|
|
24
|
-
|
|
25
|
-
Using v0.0.5 and earlier may result in a ```require``` error. To fix this you may either update to a newer version of the gem or uninstall with ```gem uninstall pocket-ruby``` and try again using the method below:
|
|
26
|
-
|
|
27
|
-
Install via the gem, ```gem install pocket-ruby -v 0.0.5```
|
|
28
|
-
|
|
29
|
-
Or via bundler, ```gem 'pocket-ruby', '0.0.5', :require => 'pocket'```
|
|
30
|
-
|
|
31
|
-
Be sure to require the gem in your code with ```require 'pocket'``` not ```require 'pocket-ruby'```
|
data/Rakefile
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "bundler"
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
|
3
3
|
|
|
4
|
-
require
|
|
5
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
4
|
+
require "standard/rake"
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
require "rake/testtask"
|
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
|
8
|
+
t.libs << "test"
|
|
9
|
+
t.libs << "lib"
|
|
10
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task default: [:test, :standard]
|
|
8
14
|
|
|
9
15
|
namespace :doc do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
]
|
|
25
|
-
end
|
|
16
|
+
require "yard"
|
|
17
|
+
rescue LoadError
|
|
18
|
+
# ignore
|
|
19
|
+
else
|
|
20
|
+
YARD::Rake::YardocTask.new do |task|
|
|
21
|
+
task.files = ["HISTORY.mkd", "LICENSE.mkd", "lib/**/*.rb"]
|
|
22
|
+
task.options = [
|
|
23
|
+
"--protected",
|
|
24
|
+
"--output-dir", "doc/yard",
|
|
25
|
+
"--tag", "format:Supported formats",
|
|
26
|
+
"--tag", "authenticated:Requires Authentication",
|
|
27
|
+
"--tag", "rate_limited:Rate Limited",
|
|
28
|
+
"--markup", "markdown"
|
|
29
|
+
]
|
|
26
30
|
end
|
|
27
31
|
end
|
data/demo-server.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
require "sinatra"
|
|
2
2
|
|
|
3
|
-
require "./lib/pocket
|
|
3
|
+
require "./lib/pocket-ruby"
|
|
4
4
|
|
|
5
5
|
enable :sessions
|
|
6
6
|
|
|
7
7
|
CALLBACK_URL = "http://localhost:4567/oauth/callback"
|
|
8
8
|
|
|
9
9
|
Pocket.configure do |config|
|
|
10
|
-
config.consumer_key =
|
|
10
|
+
config.consumer_key = "10188-3565cd04d1464e6d0e64b67f"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
get
|
|
13
|
+
get "/reset" do
|
|
14
14
|
puts "GET /reset"
|
|
15
15
|
session.clear
|
|
16
16
|
end
|
|
@@ -31,8 +31,8 @@ end
|
|
|
31
31
|
|
|
32
32
|
get "/oauth/connect" do
|
|
33
33
|
puts "OAUTH CONNECT"
|
|
34
|
-
session[:code] = Pocket.get_code(:
|
|
35
|
-
new_url = Pocket.authorize_url(:
|
|
34
|
+
session[:code] = Pocket.get_code(redirect_uri: CALLBACK_URL)
|
|
35
|
+
new_url = Pocket.authorize_url(code: session[:code], redirect_uri: CALLBACK_URL)
|
|
36
36
|
puts "new_url: #{new_url}"
|
|
37
37
|
puts "session: #{session}"
|
|
38
38
|
redirect new_url
|
|
@@ -42,26 +42,26 @@ get "/oauth/callback" do
|
|
|
42
42
|
puts "OAUTH CALLBACK"
|
|
43
43
|
puts "request.url: #{request.url}"
|
|
44
44
|
puts "request.body: #{request.body.read}"
|
|
45
|
-
result = Pocket.get_result(session[:code], :
|
|
46
|
-
session[:access_token] = result[
|
|
47
|
-
puts result[
|
|
48
|
-
puts result[
|
|
45
|
+
result = Pocket.get_result(session[:code], redirect_uri: CALLBACK_URL)
|
|
46
|
+
session[:access_token] = result["access_token"]
|
|
47
|
+
puts result["access_token"]
|
|
48
|
+
puts result["username"]
|
|
49
49
|
# Alternative method to get the access token directly
|
|
50
|
-
#session[:access_token] = Pocket.get_access_token(session[:code])
|
|
50
|
+
# session[:access_token] = Pocket.get_access_token(session[:code])
|
|
51
51
|
puts session[:access_token]
|
|
52
52
|
puts "session: #{session}"
|
|
53
53
|
redirect "/"
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
get
|
|
57
|
-
client = Pocket.client(:
|
|
58
|
-
info = client.add :
|
|
56
|
+
get "/add" do
|
|
57
|
+
client = Pocket.client(access_token: session[:access_token])
|
|
58
|
+
info = client.add url: "http://getpocket.com"
|
|
59
59
|
"<pre>#{info}</pre>"
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
get "/retrieve" do
|
|
63
|
-
client = Pocket.client(:
|
|
64
|
-
info = client.retrieve(:
|
|
63
|
+
client = Pocket.client(access_token: session[:access_token])
|
|
64
|
+
info = client.retrieve(detailType: :complete, count: 1)
|
|
65
65
|
|
|
66
66
|
# html = "<h1>#{user.username}'s recent photos</h1>"
|
|
67
67
|
# for media_item in client.user_recent_media
|
data/lib/faraday/pocket_oauth.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "faraday"
|
|
2
2
|
|
|
3
3
|
# @private
|
|
4
4
|
module FaradayMiddleware
|
|
@@ -6,16 +6,16 @@ module FaradayMiddleware
|
|
|
6
6
|
class PocketOAuth < Faraday::Middleware
|
|
7
7
|
def call(env)
|
|
8
8
|
env[:body] = {} if env[:body].nil?
|
|
9
|
-
env[:body] = env[:body].merge(:
|
|
9
|
+
env[:body] = env[:body].merge(consumer_key: @consumer_key)
|
|
10
10
|
|
|
11
11
|
if @access_token
|
|
12
|
-
env[:body] = env[:body].merge(:
|
|
12
|
+
env[:body] = env[:body].merge(access_token: @access_token)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
@app.call env
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def initialize(app, consumer_key, access_token=nil)
|
|
18
|
+
def initialize(app, consumer_key, access_token = nil)
|
|
19
19
|
@app = app
|
|
20
20
|
@consumer_key = consumer_key
|
|
21
21
|
@access_token = access_token
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
module Faraday
|
|
2
|
-
|
|
3
2
|
# HTTP Status X-Error-Code X-Error
|
|
4
3
|
# 400 138 Missing consumer key.
|
|
5
4
|
# 403 152 Invalid consumer key.
|
|
@@ -9,24 +8,24 @@ module Faraday
|
|
|
9
8
|
# 403 158 User rejected code.
|
|
10
9
|
# 403 159 Already used code.
|
|
11
10
|
# 50X 199 Pocket server issue.
|
|
12
|
-
#
|
|
11
|
+
#
|
|
13
12
|
# @see http://getpocket.com/developer/docs/authentication
|
|
14
13
|
class Response::RaisePocketError < Response::Middleware
|
|
15
|
-
|
|
14
|
+
CLIENT_ERROR_STATUSES = 400...600
|
|
16
15
|
|
|
17
16
|
def on_complete(env)
|
|
18
17
|
case env[:status]
|
|
19
18
|
when 404
|
|
20
19
|
raise Faraday::Error::ResourceNotFound, response_values(env)
|
|
21
20
|
when 400...403
|
|
22
|
-
raise Pocket::Error, env[:response_headers][
|
|
23
|
-
when
|
|
21
|
+
raise Pocket::Error, env[:response_headers]["X-Error"]
|
|
22
|
+
when CLIENT_ERROR_STATUSES
|
|
24
23
|
raise Faraday::Error::ClientError, response_values(env)
|
|
25
24
|
end
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
def response_values(env)
|
|
29
|
-
{:
|
|
28
|
+
{status: env[:status], headers: env[:response_headers], body: env[:body]}
|
|
30
29
|
end
|
|
31
30
|
end
|
|
32
31
|
end
|
data/lib/pocket-ruby.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
require File.expand_path(
|
|
2
|
-
require File.expand_path(
|
|
3
|
-
require File.expand_path(
|
|
4
|
-
require File.expand_path(
|
|
1
|
+
require File.expand_path("../pocket/error", __FILE__)
|
|
2
|
+
require File.expand_path("../pocket/configuration", __FILE__)
|
|
3
|
+
require File.expand_path("../pocket/api", __FILE__)
|
|
4
|
+
require File.expand_path("../pocket/client", __FILE__)
|
|
5
|
+
require File.expand_path("../pocket/article", __FILE__)
|
|
6
|
+
require File.expand_path("../pocket/author", __FILE__)
|
|
5
7
|
|
|
6
8
|
module Pocket
|
|
7
9
|
extend Configuration
|
|
@@ -9,7 +11,7 @@ module Pocket
|
|
|
9
11
|
# Alias for Pocket::Client.new
|
|
10
12
|
#
|
|
11
13
|
# @return [Pocket::Client]
|
|
12
|
-
def self.client(options={})
|
|
14
|
+
def self.client(options = {})
|
|
13
15
|
Pocket::Client.new(options)
|
|
14
16
|
end
|
|
15
17
|
|
|
@@ -20,7 +22,7 @@ module Pocket
|
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
# Delegate to Pocket::Client
|
|
23
|
-
def self.
|
|
24
|
-
|
|
25
|
+
def self.respond_to_missing?(method)
|
|
26
|
+
client.respond_to?(method) || super
|
|
25
27
|
end
|
|
26
28
|
end
|
data/lib/pocket/api.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
require File.expand_path(
|
|
2
|
-
require File.expand_path(
|
|
1
|
+
require File.expand_path("../connection", __FILE__)
|
|
2
|
+
require File.expand_path("../oauth", __FILE__)
|
|
3
3
|
|
|
4
4
|
module Pocket
|
|
5
5
|
# @private
|
|
6
6
|
class API
|
|
7
7
|
# @private
|
|
8
|
-
attr_accessor
|
|
8
|
+
attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
|
|
9
9
|
|
|
10
10
|
# Creates a new API
|
|
11
|
-
def initialize(options={})
|
|
11
|
+
def initialize(options = {})
|
|
12
12
|
options = Pocket.options.merge(options)
|
|
13
13
|
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
|
14
14
|
send("#{key}=", options[key])
|
|
@@ -0,0 +1,119 @@
|
|
|
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 self.from_json(json_string)
|
|
12
|
+
new(JSON.parse(json_string))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def item_id
|
|
16
|
+
Integer(response.fetch("item_id"))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def given_url
|
|
20
|
+
response.fetch("given_url")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def resolved_url
|
|
24
|
+
response.fetch("resolved_url")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def given_title
|
|
28
|
+
response.fetch("given_title")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def resolved_title
|
|
32
|
+
response.fetch("resolved_title")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def favorite?
|
|
36
|
+
Integer(response.fetch("favorite")) == 1
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def status
|
|
40
|
+
Integer(response.fetch("status"))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def excerpt
|
|
44
|
+
response.fetch("excerpt")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def article?
|
|
48
|
+
Integer(response.fetch("is_article")) == 1
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def has_image?
|
|
52
|
+
Integer(response.fetch("has_image")) == 1
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def image?
|
|
56
|
+
Integer(response.fetch("has_image")) == 2
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def has_video?
|
|
60
|
+
Integer(response.fetch("has_video")) == 1
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def video?
|
|
64
|
+
Integer(response.fetch("has_video")) == 2
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def word_count
|
|
68
|
+
Integer(response.fetch("word_count"))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def resolved_id
|
|
72
|
+
Integer(response.fetch("resolved_id"))
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def thumbnail
|
|
76
|
+
response.fetch("top_image_url", "")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def time_added
|
|
80
|
+
return nil unless response["time_added"]
|
|
81
|
+
Time.at(Integer(response["time_added"])).utc
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def time_updated
|
|
85
|
+
return nil unless response["time_updated"]
|
|
86
|
+
Time.at(Integer(response["time_updated"])).utc
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def time_read
|
|
90
|
+
return nil unless response["time_read"]
|
|
91
|
+
Time.at(Integer(response["time_read"])).utc
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def favorited?
|
|
95
|
+
Integer(response["time_favorited"]) > 0
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def time_favorited
|
|
99
|
+
return nil unless response["time_favorited"]
|
|
100
|
+
Time.at(Integer(response["time_favorited"])).utc
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def read?
|
|
104
|
+
Integer(response["time_read"]) > 0
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def read_url
|
|
108
|
+
"https://getpocket.com/read/#{item_id}"
|
|
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
|
|
118
|
+
end
|
|
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/client.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Pocket
|
|
|
4
4
|
# @note All methods have been separated into modules and follow the same grouping used in {TODO:doc_URL the Pocket API Documentation}.
|
|
5
5
|
# @see TODO:doc_url
|
|
6
6
|
class Client < API
|
|
7
|
-
Dir[File.expand_path(
|
|
7
|
+
Dir[File.expand_path("../client/*.rb", __FILE__)].sort.each { |f| require f }
|
|
8
8
|
|
|
9
9
|
include Pocket::Client::Add
|
|
10
10
|
include Pocket::Client::Modify
|
data/lib/pocket/configuration.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
require File.expand_path(
|
|
1
|
+
require "faraday"
|
|
2
|
+
require File.expand_path("../version", __FILE__)
|
|
3
3
|
|
|
4
4
|
module Pocket
|
|
5
5
|
# Defines constants and methods related to configuration
|
|
@@ -20,7 +20,8 @@ module Pocket
|
|
|
20
20
|
#
|
|
21
21
|
# @note Not all methods support the XML format.
|
|
22
22
|
VALID_FORMATS = [
|
|
23
|
-
:json
|
|
23
|
+
:json
|
|
24
|
+
].freeze
|
|
24
25
|
|
|
25
26
|
# The adapter that will be used to connect if none is set
|
|
26
27
|
#
|
|
@@ -39,7 +40,7 @@ module Pocket
|
|
|
39
40
|
# The endpoint that will be used to connect if none is set
|
|
40
41
|
#
|
|
41
42
|
# @note There is no reason to use any other endpoint at this time
|
|
42
|
-
DEFAULT_ENDPOINT =
|
|
43
|
+
DEFAULT_ENDPOINT = "https://getpocket.com/v3/".freeze
|
|
43
44
|
|
|
44
45
|
# The response format appended to the path and sent in the 'Accept' header if none is set
|
|
45
46
|
#
|
|
@@ -53,7 +54,7 @@ module Pocket
|
|
|
53
54
|
DEFAULT_USER_AGENT = "Pocket Ruby Gem #{Pocket::VERSION}".freeze
|
|
54
55
|
|
|
55
56
|
# @private
|
|
56
|
-
attr_accessor
|
|
57
|
+
attr_accessor(*VALID_OPTIONS_KEYS)
|
|
57
58
|
|
|
58
59
|
# When this module is extended, set all configuration options to their default values
|
|
59
60
|
def self.extended(base)
|
|
@@ -74,14 +75,14 @@ module Pocket
|
|
|
74
75
|
|
|
75
76
|
# Reset all configuration options to defaults
|
|
76
77
|
def reset
|
|
77
|
-
self.adapter
|
|
78
|
-
self.consumer_key
|
|
79
|
-
self.access_token
|
|
80
|
-
self.endpoint
|
|
81
|
-
self.redirect_uri
|
|
82
|
-
self.format
|
|
83
|
-
self.user_agent
|
|
84
|
-
self.proxy
|
|
78
|
+
self.adapter = DEFAULT_ADAPTER
|
|
79
|
+
self.consumer_key = DEFAULT_CONSUMER_KEY
|
|
80
|
+
self.access_token = DEFAULT_ACCESS_TOKEN
|
|
81
|
+
self.endpoint = DEFAULT_ENDPOINT
|
|
82
|
+
self.redirect_uri = DEFAULT_REDIRECT_URI
|
|
83
|
+
self.format = DEFAULT_FORMAT
|
|
84
|
+
self.user_agent = DEFAULT_USER_AGENT
|
|
85
|
+
self.proxy = DEFAULT_PROXY
|
|
85
86
|
end
|
|
86
87
|
end
|
|
87
88
|
end
|
data/lib/pocket/connection.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require
|
|
2
|
-
Dir[File.expand_path(
|
|
1
|
+
require "faraday_middleware"
|
|
2
|
+
Dir[File.expand_path("../../faraday/*.rb", __FILE__)].sort.each { |f| require f }
|
|
3
3
|
|
|
4
4
|
module Pocket
|
|
5
5
|
# @private
|
|
6
6
|
module Connection
|
|
7
7
|
private
|
|
8
8
|
|
|
9
|
-
def connection(raw=false)
|
|
9
|
+
def connection(raw = false)
|
|
10
10
|
options = {
|
|
11
|
-
:
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
:
|
|
11
|
+
headers: {"User-Agent" => user_agent},
|
|
12
|
+
proxy: proxy,
|
|
13
|
+
ssl: {verify: false},
|
|
14
|
+
url: endpoint
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
Faraday::Connection.new(options) do |conn|
|
|
@@ -20,7 +20,7 @@ module Pocket
|
|
|
20
20
|
|
|
21
21
|
conn.request :json
|
|
22
22
|
|
|
23
|
-
conn.response :json, :
|
|
23
|
+
conn.response :json, content_type: /\bjson$/
|
|
24
24
|
|
|
25
25
|
conn.adapter Faraday.default_adapter
|
|
26
26
|
end
|
data/lib/pocket/oauth.rb
CHANGED
|
@@ -2,7 +2,7 @@ module Pocket
|
|
|
2
2
|
# Defines HTTP request methods
|
|
3
3
|
module OAuth
|
|
4
4
|
# Return URL for OAuth authorization
|
|
5
|
-
def authorize_url(options={})
|
|
5
|
+
def authorize_url(options = {})
|
|
6
6
|
params = access_token_params.merge(options)
|
|
7
7
|
params.delete(:consumer_key) # shouldn't be exposed publically
|
|
8
8
|
# Pocket renames `code` to `request_token` for some reason in this call
|
|
@@ -11,34 +11,34 @@ module Pocket
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# Return a Pocket code
|
|
14
|
-
def get_code(options={})
|
|
14
|
+
def get_code(options = {})
|
|
15
15
|
params = access_token_params.merge(options)
|
|
16
|
-
response = connection.post
|
|
16
|
+
response = connection.post "oauth/request", params
|
|
17
17
|
results = Hash[URI.decode_www_form(response.body)]
|
|
18
|
-
|
|
18
|
+
results["code"]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Return an access token from authorization
|
|
22
|
-
def get_access_token(code, options={})
|
|
23
|
-
params = access_token_params.merge(:
|
|
24
|
-
response = connection.post
|
|
22
|
+
def get_access_token(code, options = {})
|
|
23
|
+
params = access_token_params.merge(code: code).merge(options)
|
|
24
|
+
response = connection.post "oauth/authorize", params
|
|
25
25
|
results = Hash[URI.decode_www_form(response.body)]
|
|
26
|
-
|
|
26
|
+
results["access_token"]
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Return result from authorization
|
|
30
|
-
def get_result(code, options={})
|
|
31
|
-
params = access_token_params.merge(:
|
|
32
|
-
response = connection.post
|
|
33
|
-
|
|
30
|
+
def get_result(code, options = {})
|
|
31
|
+
params = access_token_params.merge(code: code).merge(options)
|
|
32
|
+
response = connection.post "oauth/authorize", params
|
|
33
|
+
Hash[URI.decode_www_form(response.body)]
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
private
|
|
37
37
|
|
|
38
38
|
def access_token_params
|
|
39
39
|
{
|
|
40
|
-
:
|
|
41
|
-
:
|
|
40
|
+
consumer_key: consumer_key,
|
|
41
|
+
redirect_uri: redirect_uri
|
|
42
42
|
}
|
|
43
43
|
end
|
|
44
44
|
end
|
data/lib/pocket/version.rb
CHANGED
data/pocket-ruby.gemspec
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
require File.expand_path('../lib/pocket/version', __FILE__)
|
|
1
|
+
require File.expand_path("../lib/pocket/version", __FILE__)
|
|
3
2
|
|
|
4
3
|
Gem::Specification.new do |s|
|
|
5
|
-
s.add_development_dependency(
|
|
6
|
-
s.add_development_dependency(
|
|
7
|
-
s.
|
|
8
|
-
s.
|
|
9
|
-
s.
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
12
|
-
s.
|
|
13
|
-
s.
|
|
14
|
-
s.
|
|
4
|
+
s.add_development_dependency("sinatra", "~> 1.3.3")
|
|
5
|
+
s.add_development_dependency("multi_xml")
|
|
6
|
+
s.add_development_dependency("rake")
|
|
7
|
+
s.add_development_dependency("standard")
|
|
8
|
+
s.add_development_dependency("test-unit")
|
|
9
|
+
s.add_development_dependency("simplecov")
|
|
10
|
+
s.add_runtime_dependency("faraday", [">= 0.7"])
|
|
11
|
+
s.add_runtime_dependency("faraday_middleware")
|
|
12
|
+
s.add_runtime_dependency("multi_json", ">= 1.0.3", "~> 1.0")
|
|
13
|
+
s.authors = ["Turadg Aleahmad", "Jason Ng PT", "Andy Waite"]
|
|
14
|
+
s.description = "A Ruby wrapper for the Pocket API v3 (Add, Modify and Retrieve)"
|
|
15
|
+
s.email = ["turadg@aleahmad.net", "me@jasonngpt.com"]
|
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
15
17
|
s.files = `git ls-files`.split("\n")
|
|
16
|
-
s.homepage =
|
|
17
|
-
s.name =
|
|
18
|
+
s.homepage = "https://github.com/turadg/pocket-ruby"
|
|
19
|
+
s.name = "pocket-ruby"
|
|
18
20
|
s.platform = Gem::Platform::RUBY
|
|
19
|
-
s.require_paths = [
|
|
20
|
-
s.required_rubygems_version = Gem::Requirement.new(
|
|
21
|
+
s.require_paths = ["lib"]
|
|
22
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
|
|
21
23
|
s.rubyforge_project = s.name
|
|
22
|
-
s.summary =
|
|
24
|
+
s.summary = "Ruby wrapper for the Pocket API v3"
|
|
23
25
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
24
26
|
s.version = Pocket::VERSION
|
|
25
27
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
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?given",
|
|
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?resolved",
|
|
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
|
+
"top_image_url": "https://example.com/image.png",
|
|
16
|
+
"time_added": "1617412992",
|
|
17
|
+
"time_updated": "1617412993",
|
|
18
|
+
"time_read": "1617412994",
|
|
19
|
+
"time_favorited": "1617412995",
|
|
20
|
+
"images": {
|
|
21
|
+
"1": {
|
|
22
|
+
"item_id": "229279689",
|
|
23
|
+
"image_id": "1",
|
|
24
|
+
"src": "http://a.espncdn.com/combiner/i?img=/photo/2012/0927/grant_g_ryder_cr_640.jpg&w=640&h=360",
|
|
25
|
+
"width": "0",
|
|
26
|
+
"height": "0",
|
|
27
|
+
"credit": "Jamie Squire/Getty Images",
|
|
28
|
+
"caption": ""
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"videos": {
|
|
32
|
+
"1": {
|
|
33
|
+
"item_id": "229279689",
|
|
34
|
+
"video_id": "1",
|
|
35
|
+
"src": "http://www.youtube.com/v/Er34PbFkVGk?version=3&hl=en_US&rel=0",
|
|
36
|
+
"width": "420",
|
|
37
|
+
"height": "315",
|
|
38
|
+
"type": "1",
|
|
39
|
+
"vid": "Er34PbFkVGk"
|
|
40
|
+
}
|
|
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
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
module Pocket
|
|
4
|
+
class VersionTest < Test::Unit::TestCase
|
|
5
|
+
test "from_json" do
|
|
6
|
+
json_string = File.read("test/fixtures/retreive.json")
|
|
7
|
+
article = Pocket::Article.from_json(json_string)
|
|
8
|
+
assert_equal 229279689, article.item_id
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "item_id" do
|
|
12
|
+
assert_equal 229279689, article.item_id
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "given_url" do
|
|
16
|
+
assert_equal "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview?given", article.given_url
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "resolved_url" do
|
|
20
|
+
assert_equal "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview?resolved", article.resolved_url
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "given_title" do
|
|
24
|
+
assert_equal "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", article.given_title
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test "resolved_title" do
|
|
28
|
+
assert_equal "The Massive Ryder Cup Preview", article.resolved_title
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
test "favorite? is false is field is '0'" do
|
|
32
|
+
assert_equal false, article.favorite?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
test "status" do
|
|
36
|
+
assert_equal 0, article.status
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test "excerpt" do
|
|
40
|
+
assert_include article.excerpt, "list of things"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test "article?" do
|
|
44
|
+
assert article.article?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
test "has_image?" do
|
|
48
|
+
assert article.has_image?
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
test "image?" do
|
|
52
|
+
refute article.image?
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "has_video?" do
|
|
56
|
+
assert article.has_video?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
test "video?" do
|
|
60
|
+
refute article.video?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test "word_count" do
|
|
64
|
+
assert_equal 3197, article.word_count
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
test "resolved_id" do
|
|
68
|
+
assert_equal 229279689, article.resolved_id
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
test "thumbnail" do
|
|
72
|
+
assert_equal "https://example.com/image.png", article.thumbnail
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
test "time_added" do
|
|
76
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 12), article.time_added
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
test "time_added is nil if field not present" do
|
|
80
|
+
parsed_response.delete("time_added")
|
|
81
|
+
assert_nil article.time_added
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
test "time_updated" do
|
|
85
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 13), article.time_updated
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
test "time_updated is nil if field not present" do
|
|
89
|
+
parsed_response.delete("time_updated")
|
|
90
|
+
assert_nil article.time_updated
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
test "time_read" do
|
|
94
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 14), article.time_read
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
test "time_read is nil if field is not present" do
|
|
98
|
+
parsed_response.delete("time_read")
|
|
99
|
+
assert_nil article.time_read
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
test "favorited?" do
|
|
103
|
+
assert article.favorited?
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
test "time_favorited" do
|
|
107
|
+
assert_equal Time.utc(2021, 4, 3, 1, 23, 15), article.time_favorited
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
test "time_favorited is nil if field not present" do
|
|
111
|
+
parsed_response.delete("time_favorited")
|
|
112
|
+
assert_nil article.time_favorited
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
test "read?" do
|
|
116
|
+
assert article.read?
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
test "read_url" do
|
|
120
|
+
assert_equal "https://getpocket.com/read/229279689", article.read_url
|
|
121
|
+
end
|
|
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
|
+
|
|
145
|
+
private
|
|
146
|
+
|
|
147
|
+
def article
|
|
148
|
+
@article ||= Pocket::Article.new(parsed_response)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def parsed_response
|
|
152
|
+
@parsed_response ||= JSON.parse(File.read("test/fixtures/retreive.json"))
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pocket-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Turadg Aleahmad
|
|
8
8
|
- Jason Ng PT
|
|
9
|
-
|
|
9
|
+
- Andy Waite
|
|
10
|
+
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
12
|
-
date:
|
|
13
|
+
date: 2021-04-03 00:00:00.000000000 Z
|
|
13
14
|
dependencies:
|
|
14
15
|
- !ruby/object:Gem::Dependency
|
|
15
16
|
name: sinatra
|
|
@@ -40,67 +41,109 @@ dependencies:
|
|
|
40
41
|
- !ruby/object:Gem::Version
|
|
41
42
|
version: '0'
|
|
42
43
|
- !ruby/object:Gem::Dependency
|
|
43
|
-
name:
|
|
44
|
+
name: rake
|
|
44
45
|
requirement: !ruby/object:Gem::Requirement
|
|
45
46
|
requirements:
|
|
46
47
|
- - ">="
|
|
47
48
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '0
|
|
49
|
-
type: :
|
|
49
|
+
version: '0'
|
|
50
|
+
type: :development
|
|
50
51
|
prerelease: false
|
|
51
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
53
|
requirements:
|
|
53
54
|
- - ">="
|
|
54
55
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: '0
|
|
56
|
+
version: '0'
|
|
56
57
|
- !ruby/object:Gem::Dependency
|
|
57
|
-
name:
|
|
58
|
+
name: standard
|
|
58
59
|
requirement: !ruby/object:Gem::Requirement
|
|
59
60
|
requirements:
|
|
60
|
-
- - "
|
|
61
|
+
- - ">="
|
|
61
62
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '0
|
|
63
|
-
type: :
|
|
63
|
+
version: '0'
|
|
64
|
+
type: :development
|
|
64
65
|
prerelease: false
|
|
65
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
67
|
requirements:
|
|
67
|
-
- - "
|
|
68
|
+
- - ">="
|
|
68
69
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '0
|
|
70
|
+
version: '0'
|
|
70
71
|
- !ruby/object:Gem::Dependency
|
|
71
|
-
name:
|
|
72
|
+
name: test-unit
|
|
72
73
|
requirement: !ruby/object:Gem::Requirement
|
|
73
74
|
requirements:
|
|
74
75
|
- - ">="
|
|
75
76
|
- !ruby/object:Gem::Version
|
|
76
|
-
version:
|
|
77
|
-
|
|
77
|
+
version: '0'
|
|
78
|
+
type: :development
|
|
79
|
+
prerelease: false
|
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">="
|
|
78
83
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: '
|
|
84
|
+
version: '0'
|
|
85
|
+
- !ruby/object:Gem::Dependency
|
|
86
|
+
name: simplecov
|
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
type: :development
|
|
93
|
+
prerelease: false
|
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
- !ruby/object:Gem::Dependency
|
|
100
|
+
name: faraday
|
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - ">="
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '0.7'
|
|
80
106
|
type: :runtime
|
|
81
107
|
prerelease: false
|
|
82
108
|
version_requirements: !ruby/object:Gem::Requirement
|
|
83
109
|
requirements:
|
|
84
110
|
- - ">="
|
|
85
111
|
- !ruby/object:Gem::Version
|
|
86
|
-
version:
|
|
87
|
-
|
|
112
|
+
version: '0.7'
|
|
113
|
+
- !ruby/object:Gem::Dependency
|
|
114
|
+
name: faraday_middleware
|
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
88
118
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
119
|
+
version: '0'
|
|
120
|
+
type: :runtime
|
|
121
|
+
prerelease: false
|
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: '0'
|
|
90
127
|
- !ruby/object:Gem::Dependency
|
|
91
|
-
name:
|
|
128
|
+
name: multi_json
|
|
92
129
|
requirement: !ruby/object:Gem::Requirement
|
|
93
130
|
requirements:
|
|
131
|
+
- - "~>"
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: '1.0'
|
|
94
134
|
- - ">="
|
|
95
135
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.
|
|
136
|
+
version: 1.0.3
|
|
97
137
|
type: :runtime
|
|
98
138
|
prerelease: false
|
|
99
139
|
version_requirements: !ruby/object:Gem::Requirement
|
|
100
140
|
requirements:
|
|
141
|
+
- - "~>"
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '1.0'
|
|
101
144
|
- - ">="
|
|
102
145
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 0.
|
|
146
|
+
version: 1.0.3
|
|
104
147
|
description: A Ruby wrapper for the Pocket API v3 (Add, Modify and Retrieve)
|
|
105
148
|
email:
|
|
106
149
|
- turadg@aleahmad.net
|
|
@@ -109,9 +152,13 @@ executables: []
|
|
|
109
152
|
extensions: []
|
|
110
153
|
extra_rdoc_files: []
|
|
111
154
|
files:
|
|
155
|
+
- ".github/workflows/changelog-checker.yml"
|
|
156
|
+
- ".github/workflows/tests.yml"
|
|
112
157
|
- ".gitignore"
|
|
113
158
|
- ".yardopts"
|
|
159
|
+
- CHANGELOG.md
|
|
114
160
|
- Gemfile
|
|
161
|
+
- Gemfile.lock
|
|
115
162
|
- LICENSE.md
|
|
116
163
|
- README.md
|
|
117
164
|
- Rakefile
|
|
@@ -120,6 +167,8 @@ files:
|
|
|
120
167
|
- lib/faraday/raise_pocket_error.rb
|
|
121
168
|
- lib/pocket-ruby.rb
|
|
122
169
|
- lib/pocket/api.rb
|
|
170
|
+
- lib/pocket/article.rb
|
|
171
|
+
- lib/pocket/author.rb
|
|
123
172
|
- lib/pocket/client.rb
|
|
124
173
|
- lib/pocket/client/add.rb
|
|
125
174
|
- lib/pocket/client/modify.rb
|
|
@@ -130,10 +179,14 @@ files:
|
|
|
130
179
|
- lib/pocket/oauth.rb
|
|
131
180
|
- lib/pocket/version.rb
|
|
132
181
|
- pocket-ruby.gemspec
|
|
182
|
+
- test/fixtures/retreive.json
|
|
183
|
+
- test/pocket/article_test.rb
|
|
184
|
+
- test/pocket/version_test.rb
|
|
185
|
+
- test/test_helper.rb
|
|
133
186
|
homepage: https://github.com/turadg/pocket-ruby
|
|
134
187
|
licenses: []
|
|
135
188
|
metadata: {}
|
|
136
|
-
post_install_message:
|
|
189
|
+
post_install_message:
|
|
137
190
|
rdoc_options: []
|
|
138
191
|
require_paths:
|
|
139
192
|
- lib
|
|
@@ -148,9 +201,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
148
201
|
- !ruby/object:Gem::Version
|
|
149
202
|
version: 1.3.6
|
|
150
203
|
requirements: []
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
signing_key:
|
|
204
|
+
rubygems_version: 3.0.3
|
|
205
|
+
signing_key:
|
|
154
206
|
specification_version: 4
|
|
155
207
|
summary: Ruby wrapper for the Pocket API v3
|
|
156
|
-
test_files:
|
|
208
|
+
test_files:
|
|
209
|
+
- test/fixtures/retreive.json
|
|
210
|
+
- test/pocket/article_test.rb
|
|
211
|
+
- test/pocket/version_test.rb
|
|
212
|
+
- test/test_helper.rb
|