instapaper_full 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/instapaper_full.gemspec +2 -4
- data/lib/instapaper_full/version.rb +1 -1
- data/lib/instapaper_full.rb +11 -7
- data/test/http_responses/bookmarks_list_success.txt +7 -9
- data/test/instapaper_api_test.rb +10 -8
- metadata +50 -62
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5cac752e322aa9aab3bd5ef4991218f1060eb8e7
|
4
|
+
data.tar.gz: 0762e53da6b808ccec3e07407b98055ff8479bd7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 302604d7241c5b98bdcebd5b0ee25af93e98bcdf0d5093d4bd6088dbcd7b54f82888804764876b5b27ccec2a492e84b448139af7ae4d5ee1915874dd7d022efe
|
7
|
+
data.tar.gz: cca48a568c3058bc5f067433f1acf26e4724c3bbe4ee93d0b34525c3cc02650a9f49d8853e0fdd811c25f816ff5b0e40ec2171623133fad6c311f819132a4008
|
data/instapaper_full.gemspec
CHANGED
@@ -19,11 +19,9 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency("faraday"
|
23
|
-
s.add_dependency("faraday_middleware"
|
22
|
+
s.add_dependency("faraday")
|
23
|
+
s.add_dependency("faraday_middleware")
|
24
24
|
s.add_dependency("simple_oauth", "~> 0.1")
|
25
|
-
s.add_dependency("multi_json", "~> 1.0.4")
|
26
|
-
s.add_dependency("yajl-ruby", "~> 1.1.0")
|
27
25
|
|
28
26
|
s.add_development_dependency("rake")
|
29
27
|
s.add_development_dependency("test-unit", "~> 2.4.2")
|
data/lib/instapaper_full.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'errors'
|
2
2
|
require 'json'
|
3
|
-
require 'faraday
|
4
|
-
require '
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
5
5
|
|
6
6
|
module InstapaperFull
|
7
7
|
class API
|
@@ -13,8 +13,8 @@ module InstapaperFull
|
|
13
13
|
def connection(options = {})
|
14
14
|
options.merge!({
|
15
15
|
:proxy => @options[:proxy],
|
16
|
-
:ssl => {:verify =>
|
17
|
-
:url => "https://www.instapaper.com/api/1/"
|
16
|
+
:ssl => { :verify => @options.fetch(:verify, true) },
|
17
|
+
:url => "https://www.instapaper.com/api/1.1/"
|
18
18
|
})
|
19
19
|
|
20
20
|
oauth_params = {
|
@@ -28,6 +28,7 @@ module InstapaperFull
|
|
28
28
|
end
|
29
29
|
|
30
30
|
Faraday.new(options) do |builder|
|
31
|
+
builder.use Faraday::Request::Multipart
|
31
32
|
builder.use Faraday::Request::OAuth, oauth_params
|
32
33
|
builder.use Faraday::Request::UrlEncoded
|
33
34
|
builder.adapter Faraday.default_adapter
|
@@ -64,13 +65,16 @@ module InstapaperFull
|
|
64
65
|
r.body = params unless params.empty?
|
65
66
|
end
|
66
67
|
|
67
|
-
|
68
|
+
begin
|
68
69
|
JSON.parse(result.body).tap do |d|
|
69
|
-
|
70
|
+
# Errors are always returned as an array with a single element.
|
71
|
+
# bookmarks/list is the only method which returns a Hash, not an
|
72
|
+
# Array.
|
73
|
+
if d.kind_of?(Array) && error = d.find { |e| e['type'] == 'error' }
|
70
74
|
raise InstapaperFull::API::Error.new(error['error_code'], error['message'])
|
71
75
|
end
|
72
76
|
end
|
73
|
-
|
77
|
+
rescue JSON::ParserError
|
74
78
|
raise InstapaperFull::API::Error.new(-1, result.body) if result.status != 200
|
75
79
|
result.body
|
76
80
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
HTTP/1.1 200 OK
|
2
|
-
Date: Thu, 01 Dec 2011 16:33:47 GMT
|
3
|
-
Server: Apache
|
4
|
-
P3P: CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
|
5
|
-
X-Robots-Tag: noindex
|
6
2
|
Cache-Control: no-cache
|
3
|
+
Content-Encoding: gzip
|
4
|
+
Content-Type: text/html; charset=UTF-8
|
5
|
+
Date: Wed, 16 Jul 2014 12:05:08 GMT
|
7
6
|
Pragma: no-cache
|
7
|
+
Server: nginx/1.4.7
|
8
8
|
X-Powered-By: a lot of coffee and Phish
|
9
|
-
|
10
|
-
Connection:
|
11
|
-
Transfer-Encoding: chunked
|
12
|
-
Content-Type: application/json
|
9
|
+
Content-Length: 2920
|
10
|
+
Connection: Close
|
13
11
|
|
14
|
-
|
12
|
+
{"highlights": [], "bookmarks": [{"hash": "Oem9Y0ss", "description": "", "bookmark_id": 490545991, "private_source": "", "title": "Instapaper", "url": "https://www.instapaper.com/save", "progress_timestamp": 0, "time": 1403122533, "progress": 0.0, "starred": "0", "type": "bookmark"}, {"hash": "aRf4tjQu", "description": "", "bookmark_id": 365382704, "private_source": "", "title": "http://www.aeonmagazine.com/world-views/ross-andersen-human-extinction/", "url": "http://www.aeonmagazine.com/world-views/ross-andersen-human-extinction/", "progress_timestamp": 1363614925, "time": 1384157323, "progress": 0.184269, "starred": "0", "type": "bookmark"}], "user": {"username": "tom@tomtaylor.co.uk", "user_id": 1, "type": "user", "subscription_is_active": "0"}}
|
data/test/instapaper_api_test.rb
CHANGED
@@ -5,43 +5,43 @@ class InstapaperAPITest < Test::Unit::TestCase
|
|
5
5
|
include AssetHelpers
|
6
6
|
|
7
7
|
def stub_successful_authentication
|
8
|
-
stub_request(:post, "https://www.instapaper.com/api/1/oauth/access_token").to_return(
|
8
|
+
stub_request(:post, "https://www.instapaper.com/api/1.1/oauth/access_token").to_return(
|
9
9
|
http_response('access_token_success')
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
13
13
|
def stub_failed_authentication
|
14
|
-
stub_request(:post, "https://www.instapaper.com/api/1/oauth/access_token").to_return(
|
14
|
+
stub_request(:post, "https://www.instapaper.com/api/1.1/oauth/access_token").to_return(
|
15
15
|
http_response('access_token_failure')
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
19
|
def stub_successful_verify_credentials
|
20
|
-
stub_request(:post, "https://www.instapaper.com/api/1/account/verify_credentials").to_return(
|
20
|
+
stub_request(:post, "https://www.instapaper.com/api/1.1/account/verify_credentials").to_return(
|
21
21
|
http_response('verify_credentials_success')
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
25
25
|
def stub_successful_bookmarks_list
|
26
|
-
stub_request(:post, "https://www.instapaper.com/api/1/bookmarks/list").to_return(
|
26
|
+
stub_request(:post, "https://www.instapaper.com/api/1.1/bookmarks/list").to_return(
|
27
27
|
http_response('bookmarks_list_success')
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
31
|
def stub_failed_bookmarks_add
|
32
|
-
stub_request(:post, "https://www.instapaper.com/api/1/bookmarks/add").to_return(
|
32
|
+
stub_request(:post, "https://www.instapaper.com/api/1.1/bookmarks/add").to_return(
|
33
33
|
http_response('bookmarks_add_failure')
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
37
37
|
def stub_successful_bookmarks_get_text
|
38
|
-
stub_request(:post, "https://www.instapaper.com/api/1/bookmarks/get_text").
|
38
|
+
stub_request(:post, "https://www.instapaper.com/api/1.1/bookmarks/get_text").
|
39
39
|
with(:body => {"bookmark_id"=>"1"}).
|
40
40
|
to_return(http_response('bookmarks_get_text_success'))
|
41
41
|
end
|
42
42
|
|
43
43
|
def stub_failed_bookmarks_get_text
|
44
|
-
stub_request(:post, "https://www.instapaper.com/api/1/bookmarks/get_text").
|
44
|
+
stub_request(:post, "https://www.instapaper.com/api/1.1/bookmarks/get_text").
|
45
45
|
with(:body => {"bookmark_id"=>"2"}).
|
46
46
|
to_return(http_response('bookmarks_get_text_failure'))
|
47
47
|
end
|
@@ -75,7 +75,9 @@ class InstapaperAPITest < Test::Unit::TestCase
|
|
75
75
|
def test_successful_bookmarks_list
|
76
76
|
stub_successful_bookmarks_list
|
77
77
|
list = authenticated_client.bookmarks_list
|
78
|
-
|
78
|
+
assert list.has_key?('user')
|
79
|
+
assert list.has_key?('bookmarks')
|
80
|
+
assert list.has_key?('highlights')
|
79
81
|
end
|
80
82
|
|
81
83
|
def test_failed_bookmarks_add
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instapaper_full
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Biddulph
|
@@ -10,96 +9,92 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: faraday
|
17
|
-
requirement:
|
18
|
-
none: false
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0
|
20
|
+
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
|
-
version_requirements:
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
26
28
|
- !ruby/object:Gem::Dependency
|
27
29
|
name: faraday_middleware
|
28
|
-
requirement:
|
29
|
-
none: false
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
34
|
+
version: '0'
|
34
35
|
type: :runtime
|
35
36
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: simple_oauth
|
39
|
-
requirement: &70362390468680 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
38
|
requirements:
|
42
|
-
- -
|
39
|
+
- - ">="
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
version: '0
|
45
|
-
type: :runtime
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *70362390468680
|
41
|
+
version: '0'
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
50
|
-
requirement:
|
51
|
-
none: false
|
43
|
+
name: simple_oauth
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
52
45
|
requirements:
|
53
|
-
- - ~>
|
46
|
+
- - "~>"
|
54
47
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
48
|
+
version: '0.1'
|
56
49
|
type: :runtime
|
57
50
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: yajl-ruby
|
61
|
-
requirement: &70362390467080 !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
52
|
requirements:
|
64
|
-
- - ~>
|
53
|
+
- - "~>"
|
65
54
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
67
|
-
type: :runtime
|
68
|
-
prerelease: false
|
69
|
-
version_requirements: *70362390467080
|
55
|
+
version: '0.1'
|
70
56
|
- !ruby/object:Gem::Dependency
|
71
57
|
name: rake
|
72
|
-
requirement:
|
73
|
-
none: false
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
74
59
|
requirements:
|
75
|
-
- -
|
60
|
+
- - ">="
|
76
61
|
- !ruby/object:Gem::Version
|
77
62
|
version: '0'
|
78
63
|
type: :development
|
79
64
|
prerelease: false
|
80
|
-
version_requirements:
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
81
70
|
- !ruby/object:Gem::Dependency
|
82
71
|
name: test-unit
|
83
|
-
requirement:
|
84
|
-
none: false
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
85
73
|
requirements:
|
86
|
-
- - ~>
|
74
|
+
- - "~>"
|
87
75
|
- !ruby/object:Gem::Version
|
88
76
|
version: 2.4.2
|
89
77
|
type: :development
|
90
78
|
prerelease: false
|
91
|
-
version_requirements:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 2.4.2
|
92
84
|
- !ruby/object:Gem::Dependency
|
93
85
|
name: webmock
|
94
|
-
requirement:
|
95
|
-
none: false
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
96
87
|
requirements:
|
97
|
-
- - ~>
|
88
|
+
- - "~>"
|
98
89
|
- !ruby/object:Gem::Version
|
99
90
|
version: 1.7.8
|
100
91
|
type: :development
|
101
92
|
prerelease: false
|
102
|
-
version_requirements:
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.7.8
|
103
98
|
description: See http://www.instapaper.com/api/full
|
104
99
|
email:
|
105
100
|
- mb@hackdiary.com
|
@@ -108,7 +103,7 @@ executables: []
|
|
108
103
|
extensions: []
|
109
104
|
extra_rdoc_files: []
|
110
105
|
files:
|
111
|
-
- .gitignore
|
106
|
+
- ".gitignore"
|
112
107
|
- Gemfile
|
113
108
|
- LICENSE
|
114
109
|
- README.md
|
@@ -129,33 +124,26 @@ files:
|
|
129
124
|
- test/test_helper.rb
|
130
125
|
homepage: https://github.com/mattb/instapaper_full
|
131
126
|
licenses: []
|
127
|
+
metadata: {}
|
132
128
|
post_install_message:
|
133
129
|
rdoc_options: []
|
134
130
|
require_paths:
|
135
131
|
- lib
|
136
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
133
|
requirements:
|
139
|
-
- -
|
134
|
+
- - ">="
|
140
135
|
- !ruby/object:Gem::Version
|
141
136
|
version: '0'
|
142
|
-
segments:
|
143
|
-
- 0
|
144
|
-
hash: 3203290908794437357
|
145
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
-
none: false
|
147
138
|
requirements:
|
148
|
-
- -
|
139
|
+
- - ">="
|
149
140
|
- !ruby/object:Gem::Version
|
150
141
|
version: '0'
|
151
|
-
segments:
|
152
|
-
- 0
|
153
|
-
hash: 3203290908794437357
|
154
142
|
requirements: []
|
155
143
|
rubyforge_project: instapaper_full
|
156
|
-
rubygems_version:
|
144
|
+
rubygems_version: 2.2.2
|
157
145
|
signing_key:
|
158
|
-
specification_version:
|
146
|
+
specification_version: 4
|
159
147
|
summary: Wrapper for the Instapaper Full Developer API
|
160
148
|
test_files:
|
161
149
|
- test/asset_helpers.rb
|