kulesa-contacts 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +18 -0
- data/README.markdown +111 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/kulesa-contacts.gemspec +104 -0
- data/lib/contacts.rb +90 -0
- data/lib/contacts/consumer.rb +123 -0
- data/lib/contacts/google.rb +85 -0
- data/lib/contacts/oauth_consumer.rb +71 -0
- data/lib/contacts/railtie.rb +14 -0
- data/lib/contacts/util.rb +24 -0
- data/lib/contacts/version.rb +10 -0
- data/lib/contacts/windows_live.rb +192 -0
- data/lib/contacts/yahoo.rb +89 -0
- data/spec/config/contacts.yml +15 -0
- data/spec/contact_spec.rb +29 -0
- data/spec/feeds/google-many.xml +76 -0
- data/spec/feeds/wl_contacts.xml +29 -0
- data/spec/feeds/yh_contacts.txt +241 -0
- data/spec/gmail/google_spec.rb +54 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/windows_live/windows_live_spec.rb +44 -0
- data/spec/yahoo/yahoo_spec.rb +52 -0
- metadata +213 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contacts/google'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
describe Contacts::Google do
|
6
|
+
before(:each) do
|
7
|
+
config = YAML.load_file(File.expand_path("../../config/contacts.yml", __FILE__))
|
8
|
+
Contacts.configure(config["test"])
|
9
|
+
@google = Contacts::Google.new
|
10
|
+
fake_responses
|
11
|
+
end
|
12
|
+
|
13
|
+
context "return_url" do
|
14
|
+
it "should allow the return url to be set in the config" do
|
15
|
+
@google.return_url.should_not == nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "authentication_url" do
|
20
|
+
it "should return an authentication url" do
|
21
|
+
@google.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the return url from configuration if the return url is not set" do
|
25
|
+
@google.authentication_url().length.should_not == 0
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "authorize" do
|
30
|
+
it "should set the access token if the authoriztion is granted" do
|
31
|
+
@google.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
32
|
+
@google.authorize({})
|
33
|
+
@google.access_token.should_not == nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "contacts" do
|
38
|
+
it "should return an array of contacts (all users with email addresses)" do
|
39
|
+
@google.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
40
|
+
@google.authorize({})
|
41
|
+
contacts = @google.contacts
|
42
|
+
contacts.should_not == nil
|
43
|
+
contacts.length.should == 3
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return multiple email addresses for user with multiple email addresses" do
|
47
|
+
@google.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
48
|
+
@google.authorize({})
|
49
|
+
contacts = @google.contacts
|
50
|
+
contacts[1].emails.length.should == 2
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/spec/rcov.opts
ADDED
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fake_web'
|
2
|
+
|
3
|
+
FakeWeb.allow_net_connect = false
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
end
|
7
|
+
|
8
|
+
def fake_responses
|
9
|
+
FakeWeb.register_uri(:post, 'https://www.google.com/accounts/OAuthGetRequestToken', :body => 'oauth_token=faketoken&oauth_token_secret=faketokensecret')
|
10
|
+
FakeWeb.register_uri(:post, 'https://www.google.com/accounts/OAuthGetAccessToken', :body => 'oauth_token=fake&oauth_token_secret=fake')
|
11
|
+
FakeWeb.register_uri(:get, 'https://www.google.com/m8/feeds/contacts/default/thin?max-results=200', :body => feeds('google-many.xml'))
|
12
|
+
FakeWeb.register_uri(:post, 'https://api.login.yahoo.com/oauth/v2/get_request_token', :body => 'oauth_token=faketoken&oauth_token_secret=faketokensecret')
|
13
|
+
FakeWeb.register_uri(:post, 'https://api.login.yahoo.com/oauth/v2/get_token', :body => 'oauth_token=fake&oauth_token_secret=fake&xoauth_yahoo_guid=tester')
|
14
|
+
FakeWeb.register_uri(:get, 'http://social.yahooapis.com/v1/user/tester/contacts?count=200&sort=asc&sort-fields=email&format=json', :body => feeds('yh_contacts.txt'))
|
15
|
+
FakeWeb.register_uri(:get, 'https://livecontacts.services.live.com/users/@L@/rest/invitationsbyemail', :body => feeds('wl_contacts.xml'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def feeds(*path)
|
19
|
+
File.join(File.dirname(__FILE__), "feeds", path)
|
20
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contacts/windows_live'
|
3
|
+
|
4
|
+
describe Contacts::WindowsLive do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
config = YAML.load_file(File.expand_path("../../config/contacts.yml", __FILE__))
|
8
|
+
Contacts.configure(config["test"])
|
9
|
+
@wl = Contacts::WindowsLive.new
|
10
|
+
@wl.delegation_token = "fake_token"
|
11
|
+
@wl.token_expires_at = Time.now+1
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
context "return_url" do
|
16
|
+
it "should allow the return url to be set in the config" do
|
17
|
+
@wl.return_url.should_not == nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return the return url from configuration if the return url is not set" do
|
21
|
+
@wl.authentication_url().length.should_not == 0
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
context "authentication_url" do
|
27
|
+
it "should return an authentication url" do
|
28
|
+
@wl.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "contacts" do
|
33
|
+
it "should return an array of contacts (all users with email addresses)" do
|
34
|
+
contacts = @wl.contacts
|
35
|
+
contacts.should_not == nil
|
36
|
+
contacts.length.should == 3
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should contain a single name which is a join of the first and last name fields" do
|
40
|
+
contacts = @wl.contacts
|
41
|
+
contacts[1].name.should == "Rafael Timbo"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contacts/yahoo'
|
3
|
+
|
4
|
+
describe Contacts::Yahoo do
|
5
|
+
before(:each) do
|
6
|
+
config = YAML.load_file(File.expand_path("../../config/contacts.yml", __FILE__))
|
7
|
+
Contacts.configure(config["test"])
|
8
|
+
@yahoo = Contacts::Yahoo.new
|
9
|
+
fake_responses
|
10
|
+
end
|
11
|
+
|
12
|
+
context "return_url" do
|
13
|
+
it "should allow the return url to be set in the config" do
|
14
|
+
@yahoo.return_url.should_not == nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "authentication_url" do
|
19
|
+
it "should return an authentication url" do
|
20
|
+
@yahoo.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return the return url from configuration if the return url is not set" do
|
24
|
+
@yahoo.authentication_url().length.should_not == 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "authorize" do
|
29
|
+
it "should set the access token if the authoriztion is granted" do
|
30
|
+
@yahoo.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
31
|
+
@yahoo.authorize({})
|
32
|
+
@yahoo.access_token.should_not == nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "contacts" do
|
37
|
+
it "should return an array of contacts (all users with email addresses)" do
|
38
|
+
@yahoo.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
39
|
+
@yahoo.authorize({})
|
40
|
+
contacts = @yahoo.contacts
|
41
|
+
contacts.should_not == nil
|
42
|
+
contacts.length.should == 3
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return multiple email addresses for user with multiple email addresses" do
|
46
|
+
@yahoo.authentication_url("http://browser.zen.turingstudio.com/test").length.should_not == 0
|
47
|
+
@yahoo.authorize({})
|
48
|
+
contacts = @yahoo.contacts
|
49
|
+
contacts[1].emails.length.should == 2
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kulesa-contacts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mislav Marohnic
|
9
|
+
- George Odata
|
10
|
+
- Julian Countu
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2011-06-03 00:00:00 +04:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: httparty
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: "0"
|
26
|
+
type: :runtime
|
27
|
+
prerelease: false
|
28
|
+
version_requirements: *id001
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: hpricot
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "0"
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: *id002
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: nokogiri
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: *id003
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: oauth
|
53
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - "="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 0.4.0
|
59
|
+
type: :runtime
|
60
|
+
prerelease: false
|
61
|
+
version_requirements: *id004
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: json
|
64
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: *id005
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rspec
|
75
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ~>
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.1.0
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: *id006
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: bundler
|
86
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.0.0
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: *id007
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: jeweler
|
97
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.5.1
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: *id008
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
name: rcov
|
108
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: "0"
|
114
|
+
type: :development
|
115
|
+
prerelease: false
|
116
|
+
version_requirements: *id009
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: mocha
|
119
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: "0"
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: *id010
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: fakeweb
|
130
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: *id011
|
139
|
+
description: Import users' contacts lists from Google, Yahoo!, and Windows Live.
|
140
|
+
email: kulesa@gmail.com
|
141
|
+
executables: []
|
142
|
+
|
143
|
+
extensions: []
|
144
|
+
|
145
|
+
extra_rdoc_files:
|
146
|
+
- LICENSE
|
147
|
+
- README.markdown
|
148
|
+
files:
|
149
|
+
- .gitmodules
|
150
|
+
- Gemfile
|
151
|
+
- Gemfile.lock
|
152
|
+
- LICENSE
|
153
|
+
- README.markdown
|
154
|
+
- Rakefile
|
155
|
+
- VERSION
|
156
|
+
- kulesa-contacts.gemspec
|
157
|
+
- lib/contacts.rb
|
158
|
+
- lib/contacts/consumer.rb
|
159
|
+
- lib/contacts/google.rb
|
160
|
+
- lib/contacts/oauth_consumer.rb
|
161
|
+
- lib/contacts/railtie.rb
|
162
|
+
- lib/contacts/util.rb
|
163
|
+
- lib/contacts/version.rb
|
164
|
+
- lib/contacts/windows_live.rb
|
165
|
+
- lib/contacts/yahoo.rb
|
166
|
+
- spec/config/contacts.yml
|
167
|
+
- spec/contact_spec.rb
|
168
|
+
- spec/feeds/google-many.xml
|
169
|
+
- spec/feeds/wl_contacts.xml
|
170
|
+
- spec/feeds/yh_contacts.txt
|
171
|
+
- spec/gmail/google_spec.rb
|
172
|
+
- spec/rcov.opts
|
173
|
+
- spec/spec.opts
|
174
|
+
- spec/spec_helper.rb
|
175
|
+
- spec/windows_live/windows_live_spec.rb
|
176
|
+
- spec/yahoo/yahoo_spec.rb
|
177
|
+
has_rdoc: true
|
178
|
+
homepage: https://github.com/kulesa/contacts
|
179
|
+
licenses:
|
180
|
+
- MIT
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
hash: 4052709528021806906
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
version: "0"
|
195
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
none: false
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: "0"
|
201
|
+
requirements: []
|
202
|
+
|
203
|
+
rubyforge_project:
|
204
|
+
rubygems_version: 1.6.2
|
205
|
+
signing_key:
|
206
|
+
specification_version: 3
|
207
|
+
summary: Import users' contacts lists from Google, Yahoo!, and Windows Live.
|
208
|
+
test_files:
|
209
|
+
- spec/contact_spec.rb
|
210
|
+
- spec/gmail/google_spec.rb
|
211
|
+
- spec/spec_helper.rb
|
212
|
+
- spec/windows_live/windows_live_spec.rb
|
213
|
+
- spec/yahoo/yahoo_spec.rb
|