holetse-linkedin 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <current-status>New blog post: What makes a good API wrapper? http://wynnnetherland.com/2009/11/what-makes-a-good-api-wrapper/</current-status>
@@ -0,0 +1,117 @@
1
+ require 'test_helper'
2
+
3
+ class OAuthTest < Test::Unit::TestCase
4
+ should "initialize with consumer token and secret" do
5
+ linkedin = LinkedIn::Client.new('token', 'secret')
6
+
7
+ linkedin.ctoken.should == 'token'
8
+ linkedin.csecret.should == 'secret'
9
+ end
10
+
11
+ should "set authorization path to '/uas/oauth/authorize' by default" do
12
+ linkedin = LinkedIn::Client.new('token', 'secret')
13
+ linkedin.consumer.options[:authorize_path].should == '/uas/oauth/authorize'
14
+ end
15
+
16
+ should "have a consumer" do
17
+ consumer = mock('oauth consumer')
18
+ options = {
19
+ :request_token_path => "/uas/oauth/requestToken",
20
+ :access_token_path => "/uas/oauth/accessToken",
21
+ :authorize_path => "/uas/oauth/authorize",
22
+ :site => 'https://api.linkedin.com'
23
+ }
24
+ OAuth::Consumer.expects(:new).with('token', 'secret', options).returns(consumer)
25
+ linkedin = LinkedIn::Client.new('token', 'secret')
26
+
27
+ linkedin.consumer.should == consumer
28
+ end
29
+
30
+ should "have a request token from the consumer" do
31
+ options = {
32
+ :request_token_path => "/uas/oauth/requestToken",
33
+ :access_token_path => "/uas/oauth/accessToken",
34
+ :authorize_path => "/uas/oauth/authorize",
35
+ :site => 'https://api.linkedin.com'
36
+ }
37
+ consumer = mock('oauth consumer')
38
+ request_token = mock('request token')
39
+ consumer.expects(:get_request_token).returns(request_token)
40
+ OAuth::Consumer.expects(:new).with('token', 'secret', options).returns(consumer)
41
+ linkedin = LinkedIn::Client.new('token', 'secret')
42
+
43
+ linkedin.request_token.should == request_token
44
+ end
45
+
46
+ context "set_callback_url" do
47
+ should "clear request token and set the callback url" do
48
+ consumer = mock('oauth consumer')
49
+ request_token = mock('request token')
50
+ options = {
51
+ :request_token_path => "/uas/oauth/requestToken",
52
+ :access_token_path => "/uas/oauth/accessToken",
53
+ :authorize_path => "/uas/oauth/authorize",
54
+ :site => 'https://api.linkedin.com'
55
+ }
56
+ OAuth::Consumer.
57
+ expects(:new).
58
+ with('token', 'secret', options).
59
+ returns(consumer)
60
+
61
+ linkedin = LinkedIn::Client.new('token', 'secret')
62
+
63
+ consumer.
64
+ expects(:get_request_token).
65
+ with({:oauth_callback => 'http://myapp.com/oauth_callback'})
66
+
67
+ linkedin.set_callback_url('http://myapp.com/oauth_callback')
68
+ end
69
+ end
70
+
71
+ should "be able to create access token from request token, request secret and verifier" do
72
+ linkedin = LinkedIn::Client.new('token', 'secret')
73
+ consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
74
+ linkedin.stubs(:consumer).returns(consumer)
75
+
76
+ access_token = mock('access token', :token => 'atoken', :secret => 'asecret')
77
+ request_token = mock('request token')
78
+ request_token.
79
+ expects(:get_access_token).
80
+ with(:oauth_verifier => 'verifier').
81
+ returns(access_token)
82
+
83
+ OAuth::RequestToken.
84
+ expects(:new).
85
+ with(consumer, 'rtoken', 'rsecret').
86
+ returns(request_token)
87
+
88
+ linkedin.authorize_from_request('rtoken', 'rsecret', 'verifier')
89
+ linkedin.access_token.class.should be(OAuth::AccessToken)
90
+ linkedin.access_token.token.should == 'atoken'
91
+ linkedin.access_token.secret.should == 'asecret'
92
+ end
93
+
94
+ should "be able to create access token from access token and secret" do
95
+ linkedin = LinkedIn::Client.new('token', 'secret')
96
+ consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
97
+ linkedin.stubs(:consumer).returns(consumer)
98
+
99
+ linkedin.authorize_from_access('atoken', 'asecret')
100
+ linkedin.access_token.class.should be(OAuth::AccessToken)
101
+ linkedin.access_token.token.should == 'atoken'
102
+ linkedin.access_token.secret.should == 'asecret'
103
+ end
104
+
105
+ should "be able to configure consumer token and consumer secret without passing to initialize" do
106
+ LinkedIn.configure do |config|
107
+ config.token = 'consumer_token'
108
+ config.secret = 'consumer_secret'
109
+ end
110
+
111
+ linkedin = LinkedIn::Client.new
112
+ linkedin.ctoken.should == 'consumer_token'
113
+ linkedin.csecret.should == 'consumer_secret'
114
+ end
115
+
116
+
117
+ end
@@ -0,0 +1,51 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'rubygems'
4
+
5
+ gem 'thoughtbot-shoulda', '>= 2.10.1'
6
+ gem 'jnunemaker-matchy', '0.4.0'
7
+ gem 'mocha', '0.9.4'
8
+ gem 'fakeweb', '>= 1.2.5'
9
+
10
+ require 'shoulda'
11
+ require 'matchy'
12
+ require 'mocha'
13
+ require 'fakeweb'
14
+
15
+ FakeWeb.allow_net_connect = false
16
+
17
+ dir = (Pathname(__FILE__).dirname + '../lib').expand_path
18
+ require dir + 'linkedin'
19
+
20
+ class Test::Unit::TestCase
21
+ end
22
+
23
+ def fixture_file(filename)
24
+ return '' if filename == ''
25
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
26
+ File.read(file_path)
27
+ end
28
+
29
+ def linkedin_url(url)
30
+ url =~ /^http/ ? url : "https://api.linkedin.com#{url}"
31
+ end
32
+
33
+ def stub_get(url, filename, status=nil)
34
+ options = {:body => fixture_file(filename)}
35
+ options.merge!({:status => status}) unless status.nil?
36
+
37
+ FakeWeb.register_uri(:get, linkedin_url(url), options)
38
+ end
39
+
40
+ def stub_post(url, filename)
41
+ FakeWeb.register_uri(:post, linkedin_url(url), :body => fixture_file(filename))
42
+ end
43
+
44
+ def stub_put(url, filename)
45
+ FakeWeb.register_uri(:put, linkedin_url(url), :body => fixture_file(filename))
46
+ end
47
+
48
+ def stub_delete(url, filename)
49
+ FakeWeb.register_uri(:delete, linkedin_url(url), :body => fixture_file(filename))
50
+
51
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: holetse-linkedin
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 8
10
+ version: 0.1.8
11
+ platform: ruby
12
+ authors:
13
+ - Wynn Netherland
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-14 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: oauth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 25
30
+ segments:
31
+ - 0
32
+ - 3
33
+ - 5
34
+ version: 0.3.5
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: roxml
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 5
46
+ segments:
47
+ - 3
48
+ - 1
49
+ - 3
50
+ version: 3.1.3
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: crack
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 19
62
+ segments:
63
+ - 0
64
+ - 1
65
+ - 4
66
+ version: 0.1.4
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: thoughtbot-shoulda
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 37
78
+ segments:
79
+ - 2
80
+ - 10
81
+ - 1
82
+ version: 2.10.1
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: jnunemaker-matchy
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - "="
92
+ - !ruby/object:Gem::Version
93
+ hash: 15
94
+ segments:
95
+ - 0
96
+ - 4
97
+ - 0
98
+ version: 0.4.0
99
+ type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: mocha
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - "="
108
+ - !ruby/object:Gem::Version
109
+ hash: 51
110
+ segments:
111
+ - 0
112
+ - 9
113
+ - 4
114
+ version: 0.9.4
115
+ type: :development
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ name: fakeweb
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 21
126
+ segments:
127
+ - 1
128
+ - 2
129
+ - 5
130
+ version: 1.2.5
131
+ type: :development
132
+ version_requirements: *id007
133
+ description: Ruby wrapper for the LinkedIn API
134
+ email: wynn.netherland@gmail.com
135
+ executables: []
136
+
137
+ extensions: []
138
+
139
+ extra_rdoc_files:
140
+ - LICENSE
141
+ - README.markdown
142
+ files:
143
+ - LICENSE
144
+ - README.markdown
145
+ - Rakefile
146
+ - VERSION
147
+ - lib/linked_in/api_standard_profile_request.rb
148
+ - lib/linked_in/client.rb
149
+ - lib/linked_in/company.rb
150
+ - lib/linked_in/connections.rb
151
+ - lib/linked_in/country.rb
152
+ - lib/linked_in/education.rb
153
+ - lib/linked_in/error.rb
154
+ - lib/linked_in/group.rb
155
+ - lib/linked_in/location.rb
156
+ - lib/linked_in/network.rb
157
+ - lib/linked_in/people.rb
158
+ - lib/linked_in/position.rb
159
+ - lib/linked_in/profile.rb
160
+ - lib/linked_in/update.rb
161
+ - lib/linked_in/url_resource.rb
162
+ - lib/linkedin.rb
163
+ - test/client_test.rb
164
+ - test/fixtures/blank.xml
165
+ - test/fixtures/connections.xml
166
+ - test/fixtures/error.xml
167
+ - test/fixtures/network_status_with_group.xml
168
+ - test/fixtures/network_statuses.xml
169
+ - test/fixtures/picture_updates.xml
170
+ - test/fixtures/profile.xml
171
+ - test/fixtures/profile_full.xml
172
+ - test/fixtures/profile_with_positions.xml
173
+ - test/fixtures/search.xml
174
+ - test/fixtures/status.xml
175
+ - test/oauth_test.rb
176
+ - test/test_helper.rb
177
+ - examples/authenticate.rb
178
+ - examples/network.rb
179
+ - examples/profile.rb
180
+ - examples/status.rb
181
+ has_rdoc: true
182
+ homepage: http://github.com/pengwynn/linkedin
183
+ licenses: []
184
+
185
+ post_install_message:
186
+ rdoc_options:
187
+ - --charset=UTF-8
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ hash: 3
196
+ segments:
197
+ - 0
198
+ version: "0"
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ hash: 3
205
+ segments:
206
+ - 0
207
+ version: "0"
208
+ requirements: []
209
+
210
+ rubyforge_project:
211
+ rubygems_version: 1.3.7
212
+ signing_key:
213
+ specification_version: 3
214
+ summary: Ruby wrapper for the LinkedIn API
215
+ test_files:
216
+ - test/client_test.rb
217
+ - test/oauth_test.rb
218
+ - test/test_helper.rb
219
+ - examples/authenticate.rb
220
+ - examples/network.rb
221
+ - examples/profile.rb
222
+ - examples/status.rb