linkedin-idkmybffjill 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Gemfile +16 -0
  2. data/LICENSE +20 -0
  3. data/README.markdown +74 -0
  4. data/Rakefile +70 -0
  5. data/VERSION +1 -0
  6. data/examples/authenticate.rb +21 -0
  7. data/examples/network.rb +12 -0
  8. data/examples/profile.rb +14 -0
  9. data/examples/status.rb +9 -0
  10. data/lib/linked_in/api_standard_profile_request.rb +17 -0
  11. data/lib/linked_in/base.rb +13 -0
  12. data/lib/linked_in/birthdate.rb +21 -0
  13. data/lib/linked_in/client.rb +267 -0
  14. data/lib/linked_in/company.rb +11 -0
  15. data/lib/linked_in/connections.rb +19 -0
  16. data/lib/linked_in/country.rb +9 -0
  17. data/lib/linked_in/education.rb +44 -0
  18. data/lib/linked_in/error.rb +21 -0
  19. data/lib/linked_in/group.rb +35 -0
  20. data/lib/linked_in/location.rb +13 -0
  21. data/lib/linked_in/message.rb +31 -0
  22. data/lib/linked_in/network.rb +15 -0
  23. data/lib/linked_in/people.rb +21 -0
  24. data/lib/linked_in/person.rb +7 -0
  25. data/lib/linked_in/position.rb +49 -0
  26. data/lib/linked_in/profile.rb +54 -0
  27. data/lib/linked_in/recipient.rb +7 -0
  28. data/lib/linked_in/recipients.rb +14 -0
  29. data/lib/linked_in/update.rb +19 -0
  30. data/lib/linked_in/url_resource.rb +29 -0
  31. data/lib/linkedin.rb +97 -0
  32. data/test/client_test.rb +179 -0
  33. data/test/fixtures/blank.xml +0 -0
  34. data/test/fixtures/connections.xml +3733 -0
  35. data/test/fixtures/error.xml +7 -0
  36. data/test/fixtures/mailbox_items.xml +13 -0
  37. data/test/fixtures/network_status_with_group.xml +44 -0
  38. data/test/fixtures/network_statuses.xml +299 -0
  39. data/test/fixtures/picture_updates.xml +117 -0
  40. data/test/fixtures/profile.xml +9 -0
  41. data/test/fixtures/profile_full.xml +3849 -0
  42. data/test/fixtures/profile_with_positions.xml +79 -0
  43. data/test/fixtures/search.xml +538 -0
  44. data/test/fixtures/status.xml +2 -0
  45. data/test/oauth_test.rb +117 -0
  46. data/test/test_helper.rb +54 -0
  47. metadata +214 -0
@@ -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,54 @@
1
+ require 'test/unit'
2
+
3
+ require 'pathname'
4
+ require 'rubygems'
5
+
6
+ gem 'mocha', '>= 0.9.4'
7
+ gem 'shoulda', '>= 2.10.1'
8
+ gem 'jnunemaker-matchy', '0.4.0'
9
+ gem 'fakeweb', '>= 1.2.5'
10
+ # gem 'redgreen'
11
+
12
+ require 'mocha'
13
+ require 'shoulda'
14
+ require 'matchy'
15
+ require 'fakeweb'
16
+ # require 'redgreen'
17
+
18
+ FakeWeb.allow_net_connect = false
19
+
20
+ dir = (Pathname(__FILE__).dirname + '../lib').expand_path
21
+ require dir + 'linkedin'
22
+
23
+ class Test::Unit::TestCase
24
+ end
25
+
26
+ def fixture_file(filename)
27
+ return '' if filename == ''
28
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
29
+ File.read(file_path)
30
+ end
31
+
32
+ def linkedin_url(url)
33
+ url =~ /^http/ ? url : "https://api.linkedin.com#{url}"
34
+ end
35
+
36
+ def stub_get(url, filename, status=nil)
37
+ options = {:body => fixture_file(filename)}
38
+ options.merge!({:status => status}) unless status.nil?
39
+
40
+ FakeWeb.register_uri(:get, linkedin_url(url), options)
41
+ end
42
+
43
+ def stub_post(url, filename)
44
+ FakeWeb.register_uri(:post, linkedin_url(url), :body => fixture_file(filename))
45
+ end
46
+
47
+ def stub_put(url, filename)
48
+ FakeWeb.register_uri(:put, linkedin_url(url), :body => fixture_file(filename))
49
+ end
50
+
51
+ def stub_delete(url, filename)
52
+ FakeWeb.register_uri(:delete, linkedin_url(url), :body => fixture_file(filename))
53
+
54
+ end
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linkedin-idkmybffjill
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 9
10
+ version: 0.1.9
11
+ platform: ruby
12
+ authors:
13
+ - Wynn Netherland, idkmybffjill
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-26 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: crack
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 0
48
+ - 1
49
+ - 4
50
+ version: 0.1.4
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: shoulda
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 37
62
+ segments:
63
+ - 2
64
+ - 10
65
+ - 1
66
+ version: 2.10.1
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: jnunemaker-matchy
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - "="
76
+ - !ruby/object:Gem::Version
77
+ hash: 15
78
+ segments:
79
+ - 0
80
+ - 4
81
+ - 0
82
+ version: 0.4.0
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: mocha
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 51
94
+ segments:
95
+ - 0
96
+ - 9
97
+ - 4
98
+ version: 0.9.4
99
+ type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: fakeweb
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 21
110
+ segments:
111
+ - 1
112
+ - 2
113
+ - 5
114
+ version: 1.2.5
115
+ type: :development
116
+ version_requirements: *id006
117
+ description: Ruby wrapper for the LinkedIn API
118
+ email: wynn.netherland@gmail.com
119
+ executables: []
120
+
121
+ extensions: []
122
+
123
+ extra_rdoc_files:
124
+ - LICENSE
125
+ - README.markdown
126
+ files:
127
+ - Gemfile
128
+ - LICENSE
129
+ - README.markdown
130
+ - Rakefile
131
+ - VERSION
132
+ - lib/linked_in/api_standard_profile_request.rb
133
+ - lib/linked_in/base.rb
134
+ - lib/linked_in/birthdate.rb
135
+ - lib/linked_in/client.rb
136
+ - lib/linked_in/company.rb
137
+ - lib/linked_in/connections.rb
138
+ - lib/linked_in/country.rb
139
+ - lib/linked_in/education.rb
140
+ - lib/linked_in/error.rb
141
+ - lib/linked_in/group.rb
142
+ - lib/linked_in/location.rb
143
+ - lib/linked_in/message.rb
144
+ - lib/linked_in/network.rb
145
+ - lib/linked_in/people.rb
146
+ - lib/linked_in/person.rb
147
+ - lib/linked_in/position.rb
148
+ - lib/linked_in/profile.rb
149
+ - lib/linked_in/recipient.rb
150
+ - lib/linked_in/recipients.rb
151
+ - lib/linked_in/update.rb
152
+ - lib/linked_in/url_resource.rb
153
+ - lib/linkedin.rb
154
+ - test/client_test.rb
155
+ - test/fixtures/blank.xml
156
+ - test/fixtures/connections.xml
157
+ - test/fixtures/error.xml
158
+ - test/fixtures/mailbox_items.xml
159
+ - test/fixtures/network_status_with_group.xml
160
+ - test/fixtures/network_statuses.xml
161
+ - test/fixtures/picture_updates.xml
162
+ - test/fixtures/profile.xml
163
+ - test/fixtures/profile_full.xml
164
+ - test/fixtures/profile_with_positions.xml
165
+ - test/fixtures/search.xml
166
+ - test/fixtures/status.xml
167
+ - test/oauth_test.rb
168
+ - test/test_helper.rb
169
+ - examples/authenticate.rb
170
+ - examples/network.rb
171
+ - examples/profile.rb
172
+ - examples/status.rb
173
+ has_rdoc: true
174
+ homepage: http://github.com/idkmybffjill/linkedin
175
+ licenses: []
176
+
177
+ post_install_message:
178
+ rdoc_options:
179
+ - --charset=UTF-8
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
190
+ version: "0"
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ hash: 3
197
+ segments:
198
+ - 0
199
+ version: "0"
200
+ requirements: []
201
+
202
+ rubyforge_project:
203
+ rubygems_version: 1.3.7
204
+ signing_key:
205
+ specification_version: 3
206
+ summary: Ruby wrapper for the LinkedIn API
207
+ test_files:
208
+ - test/client_test.rb
209
+ - test/oauth_test.rb
210
+ - test/test_helper.rb
211
+ - examples/authenticate.rb
212
+ - examples/network.rb
213
+ - examples/profile.rb
214
+ - examples/status.rb