pocket-ruby 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -11,7 +11,7 @@ spec/reports
11
11
  test/tmp
12
12
  test/version_tmp
13
13
  tmp
14
-
14
+ Gemfile.lock
15
15
  # YARD artifacts
16
16
  .yardoc
17
17
  _yardoc
data/README.md CHANGED
@@ -1,2 +1,21 @@
1
1
  pocket-ruby
2
- ===========
2
+ ===========
3
+
4
+ [![Code Climate](https://codeclimate.com/github/turadg/pocket-ruby.png)](https://codeclimate.com/github/turadg/pocket-ruby) [![Gem Version](https://badge.fury.io/rb/pocket-ruby.png)](http://badge.fury.io/rb/pocket-ruby)
5
+
6
+ Ruby API for v3 of the [Pocket API](http://getpocket.com/developer/docs/overview) (formerly Read It Later)
7
+
8
+ # Usage
9
+
10
+ Just clone the repo here and refer to the demo-server.rb file for examples on how to interact with the Pocket API.
11
+
12
+ ```sh
13
+ git clone
14
+ cd pocket-ruby
15
+ bundle install
16
+ ruby demo-server.rb
17
+ ```
18
+
19
+ Pocket-Ruby can be installed via the gem, ```gem install pocket-ruby```
20
+
21
+ Or via bundler, ```gem 'pocket-ruby', '~> 0.0.5'```
data/demo-server.rb CHANGED
@@ -18,11 +18,11 @@ end
18
18
  get "/" do
19
19
  puts "GET /"
20
20
  puts "session: #{session}"
21
-
21
+
22
22
  if session[:access_token]
23
23
  '
24
- <a href="/add?url=http://geknowm.com">Add Geknowm</a>
25
- <a href="/retrieve">Retrieve items</a>
24
+ <a href="/add?url=http://getpocket.com">Add Pocket Homepage</a>
25
+ <a href="/retrieve">Retrieve single item</a>
26
26
  '
27
27
  else
28
28
  '<a href="/oauth/connect">Connect with Pocket</a>'
@@ -42,21 +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
- access_token = Pocket.get_access_token(session[:code], :redirect_uri => CALLBACK_URL)
46
- session[:access_token] = access_token
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
+ # Alternative method to get the access token directly
50
+ #session[:access_token] = Pocket.get_access_token(session[:code])
51
+ puts session[:access_token]
47
52
  puts "session: #{session}"
48
53
  redirect "/"
49
54
  end
50
55
 
51
56
  get '/add' do
52
57
  client = Pocket.client(:access_token => session[:access_token])
53
- info = client.add :url => 'http://geknowm.com'
58
+ info = client.add :url => 'http://getpocket.com'
54
59
  "<pre>#{info}</pre>"
55
60
  end
56
61
 
57
62
  get "/retrieve" do
58
63
  client = Pocket.client(:access_token => session[:access_token])
59
- info = client.retrieve :detailType => :complete
64
+ info = client.retrieve(:detailType => :complete, :count => 1)
60
65
 
61
66
  # html = "<h1>#{user.username}'s recent photos</h1>"
62
67
  # for media_item in client.user_recent_media
@@ -26,7 +26,7 @@ module Faraday
26
26
  end
27
27
 
28
28
  def response_values(env)
29
- {:status => env.status, :headers => env.response_headers, :body => env.body}
29
+ {:status => env[:status], :headers => env[:response_headers], :body => env[:body]}
30
30
  end
31
31
  end
32
32
  end
data/lib/pocket/oauth.rb CHANGED
@@ -27,6 +27,15 @@ module Pocket
27
27
  access_token = results['access_token']
28
28
  end
29
29
 
30
+ # Return result from authorization
31
+ def get_result(code, options={})
32
+ params = access_token_params.merge(options)
33
+
34
+ params = access_token_params.merge(:code => code).merge(options)
35
+ response = connection.post 'oauth/authorize', params
36
+ results = Hash[URI.decode_www_form(response.body)]
37
+ end
38
+
30
39
  private
31
40
 
32
41
  def access_token_params
@@ -1,3 +1,3 @@
1
1
  module Pocket
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
data/pocket-ruby.gemspec CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |s|
8
8
  s.add_runtime_dependency('faraday_middleware', '~> 0.8')
9
9
  s.add_runtime_dependency('multi_json', '>= 1.0.3', '~> 1.0')
10
10
  s.add_runtime_dependency('hashie', '>= 0.4.0')
11
- s.authors = ["Turadg Aleahmad"]
11
+ s.authors = ["Turadg Aleahmad","Jason Ng PT"]
12
12
  s.description = %q{A Ruby wrapper for the Pocket API v3 (Add, Modify and Retrieve)}
13
- s.email = ['turadg@aleahmad.net']
13
+ s.email = ['turadg@aleahmad.net',"me@jasonngpt.com"]
14
14
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
15
  s.files = `git ls-files`.split("\n")
16
- s.homepage = 'https://github.com/Geknowm/pocket-ruby'
16
+ s.homepage = 'https://github.com/turadg/pocket-ruby'
17
17
  s.name = 'pocket-ruby'
18
18
  s.platform = Gem::Platform::RUBY
19
19
  s.require_paths = ['lib']
metadata CHANGED
@@ -1,50 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pocket-ruby
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.0.5
4
5
  prerelease:
5
- version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Turadg Aleahmad
9
+ - Jason Ng PT
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-01-18 00:00:00.000000000 Z
13
+ date: 2014-04-01 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
16
+ name: sinatra
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
16
19
  requirements:
17
20
  - - ~>
18
21
  - !ruby/object:Gem::Version
19
22
  version: 1.3.3
20
- none: false
21
- name: sinatra
22
23
  type: :development
23
24
  prerelease: false
24
- requirement: !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ~>
27
29
  - !ruby/object:Gem::Version
28
30
  version: 1.3.3
29
- none: false
30
31
  - !ruby/object:Gem::Dependency
31
- version_requirements: !ruby/object:Gem::Requirement
32
+ name: multi_xml
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
32
35
  requirements:
33
36
  - - ! '>='
34
37
  - !ruby/object:Gem::Version
35
38
  version: '0'
36
- none: false
37
- name: multi_xml
38
39
  type: :development
39
40
  prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
41
43
  requirements:
42
44
  - - ! '>='
43
45
  - !ruby/object:Gem::Version
44
46
  version: '0'
45
- none: false
46
47
  - !ruby/object:Gem::Dependency
47
- version_requirements: !ruby/object:Gem::Requirement
48
+ name: faraday
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
48
51
  requirements:
49
52
  - - ! '>='
50
53
  - !ruby/object:Gem::Version
@@ -52,11 +55,10 @@ dependencies:
52
55
  - - <
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0.9'
55
- none: false
56
- name: faraday
57
58
  type: :runtime
58
59
  prerelease: false
59
- requirement: !ruby/object:Gem::Requirement
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
60
62
  requirements:
61
63
  - - ! '>='
62
64
  - !ruby/object:Gem::Version
@@ -64,25 +66,26 @@ dependencies:
64
66
  - - <
65
67
  - !ruby/object:Gem::Version
66
68
  version: '0.9'
67
- none: false
68
69
  - !ruby/object:Gem::Dependency
69
- version_requirements: !ruby/object:Gem::Requirement
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ none: false
70
73
  requirements:
71
74
  - - ~>
72
75
  - !ruby/object:Gem::Version
73
76
  version: '0.8'
74
- none: false
75
- name: faraday_middleware
76
77
  type: :runtime
77
78
  prerelease: false
78
- requirement: !ruby/object:Gem::Requirement
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
79
81
  requirements:
80
82
  - - ~>
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0.8'
83
- none: false
84
85
  - !ruby/object:Gem::Dependency
85
- version_requirements: !ruby/object:Gem::Requirement
86
+ name: multi_json
87
+ requirement: !ruby/object:Gem::Requirement
88
+ none: false
86
89
  requirements:
87
90
  - - ! '>='
88
91
  - !ruby/object:Gem::Version
@@ -90,11 +93,10 @@ dependencies:
90
93
  - - ~>
91
94
  - !ruby/object:Gem::Version
92
95
  version: '1.0'
93
- none: false
94
- name: multi_json
95
96
  type: :runtime
96
97
  prerelease: false
97
- requirement: !ruby/object:Gem::Requirement
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ none: false
98
100
  requirements:
99
101
  - - ! '>='
100
102
  - !ruby/object:Gem::Version
@@ -102,26 +104,26 @@ dependencies:
102
104
  - - ~>
103
105
  - !ruby/object:Gem::Version
104
106
  version: '1.0'
105
- none: false
106
107
  - !ruby/object:Gem::Dependency
107
- version_requirements: !ruby/object:Gem::Requirement
108
+ name: hashie
109
+ requirement: !ruby/object:Gem::Requirement
110
+ none: false
108
111
  requirements:
109
112
  - - ! '>='
110
113
  - !ruby/object:Gem::Version
111
114
  version: 0.4.0
112
- none: false
113
- name: hashie
114
115
  type: :runtime
115
116
  prerelease: false
116
- requirement: !ruby/object:Gem::Requirement
117
+ version_requirements: !ruby/object:Gem::Requirement
118
+ none: false
117
119
  requirements:
118
120
  - - ! '>='
119
121
  - !ruby/object:Gem::Version
120
122
  version: 0.4.0
121
- none: false
122
123
  description: A Ruby wrapper for the Pocket API v3 (Add, Modify and Retrieve)
123
124
  email:
124
125
  - turadg@aleahmad.net
126
+ - me@jasonngpt.com
125
127
  executables: []
126
128
  extensions: []
127
129
  extra_rdoc_files: []
@@ -129,7 +131,6 @@ files:
129
131
  - .gitignore
130
132
  - .yardopts
131
133
  - Gemfile
132
- - Gemfile.lock
133
134
  - LICENSE.md
134
135
  - README.md
135
136
  - Rakefile
@@ -148,24 +149,24 @@ files:
148
149
  - lib/pocket/oauth.rb
149
150
  - lib/pocket/version.rb
150
151
  - pocket-ruby.gemspec
151
- homepage: https://github.com/Geknowm/pocket-ruby
152
+ homepage: https://github.com/turadg/pocket-ruby
152
153
  licenses: []
153
154
  post_install_message:
154
155
  rdoc_options: []
155
156
  require_paths:
156
157
  - lib
157
158
  required_ruby_version: !ruby/object:Gem::Requirement
159
+ none: false
158
160
  requirements:
159
161
  - - ! '>='
160
162
  - !ruby/object:Gem::Version
161
163
  version: '0'
162
- none: false
163
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
+ none: false
164
166
  requirements:
165
167
  - - ! '>='
166
168
  - !ruby/object:Gem::Version
167
169
  version: 1.3.6
168
- none: false
169
170
  requirements: []
170
171
  rubyforge_project: pocket-ruby
171
172
  rubygems_version: 1.8.23
@@ -173,4 +174,3 @@ signing_key:
173
174
  specification_version: 3
174
175
  summary: Ruby wrapper for the Pocket API v3
175
176
  test_files: []
176
- has_rdoc:
data/Gemfile.lock DELETED
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pocket-ruby (0.0.3)
5
- faraday (>= 0.7, < 0.9)
6
- faraday_middleware (~> 0.8)
7
- hashie (>= 0.4.0)
8
- multi_json (~> 1.0, >= 1.0.3)
9
-
10
- GEM
11
- remote: http://rubygems.org/
12
- specs:
13
- addressable (2.3.2)
14
- bluecloth (2.0.11)
15
- coderay (1.0.8)
16
- crack (0.3.1)
17
- diff-lcs (1.1.3)
18
- faraday (0.8.4)
19
- multipart-post (~> 1.1)
20
- faraday_middleware (0.9.0)
21
- faraday (>= 0.7.4, < 0.9)
22
- hashie (1.2.0)
23
- method_source (0.8.1)
24
- multi_json (1.3.7)
25
- multi_xml (0.5.1)
26
- multipart-post (1.1.5)
27
- pry (0.9.10)
28
- coderay (~> 1.0.5)
29
- method_source (~> 0.8)
30
- slop (~> 3.3.1)
31
- rack (1.4.1)
32
- rack-protection (1.2.0)
33
- rack
34
- rspec (2.12.0)
35
- rspec-core (~> 2.12.0)
36
- rspec-expectations (~> 2.12.0)
37
- rspec-mocks (~> 2.12.0)
38
- rspec-core (2.12.0)
39
- rspec-expectations (2.12.0)
40
- diff-lcs (~> 1.1.3)
41
- rspec-mocks (2.12.0)
42
- sinatra (1.3.3)
43
- rack (~> 1.3, >= 1.3.6)
44
- rack-protection (~> 1.2)
45
- tilt (~> 1.3, >= 1.3.3)
46
- slop (3.3.3)
47
- tilt (1.3.3)
48
- webmock (1.9.0)
49
- addressable (>= 2.2.7)
50
- crack (>= 0.1.7)
51
-
52
- PLATFORMS
53
- ruby
54
-
55
- DEPENDENCIES
56
- bluecloth (~> 2.0.11)
57
- multi_xml
58
- pocket-ruby!
59
- pry (~> 0.9.10)
60
- rspec (~> 2.4)
61
- sinatra (~> 1.3.3)
62
- webmock (~> 1.6)