muck-contacts 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ Bundler.require(:default, :test) if defined?(Bundler)
5
+
6
+ dir = File.dirname(__FILE__)
7
+ $LOAD_PATH.unshift(dir + "/../lib/")
8
+ require 'test/unit'
9
+ require 'contacts'
10
+ require 'yaml'
11
+ require 'shoulda'
12
+
13
+ class ContactImporterTestCase < Test::Unit::TestCase
14
+ # Add more helper methods to be used by all tests here...
15
+ def default_test
16
+ assert true
17
+ end
18
+ end
19
+
20
+ class TestAccounts
21
+ def self.[](type)
22
+ load[type]
23
+ end
24
+
25
+ def self.load(file = File.dirname(__FILE__) + "/accounts.yml")
26
+ raise "/test/accounts.yml file not found, please create, see /test/example_accounts.yml for information" unless File.exist?(file)
27
+
28
+ accounts = {}
29
+ YAML::load(File.open(file)).each do |type, contents|
30
+ contacts = contents["contacts"].collect {|contact| [contact["name"], (contact["email_address"] || contact["account_id"])]} if contents["contacts"]
31
+ accounts[type.to_sym] = Account.new(type.to_sym, contents["username"], contents["password"], contacts, contents["app_id"], contents["app_secret"])
32
+ end
33
+ accounts
34
+ end
35
+
36
+ Account = Struct.new :type, :username, :password, :contacts, :app_id, :app_secret
37
+ end
@@ -0,0 +1,34 @@
1
+ dir = File.dirname(__FILE__)
2
+ require 'ruby-debug'
3
+ require File.join(".", dir, "..", "test_helper.rb")
4
+ require 'contacts'
5
+
6
+ class AolContactImporterTest < ContactImporterTestCase
7
+ def setup
8
+ super
9
+ @account = TestAccounts[:aolImporter]
10
+ end
11
+
12
+ def test_successful_login
13
+ Contacts.new(:aolImporter, @account.username, @account.password)
14
+ end
15
+
16
+ def test_importer_fails_with_blank_password
17
+ assert_raise(Contacts::AuthenticationError) do
18
+ Contacts.new(:aolImporter, @account.username, "")
19
+ end
20
+ end
21
+
22
+ def test_importer_fails_with_blank_username
23
+ assert_raise(Contacts::AuthenticationError) do
24
+ Contacts.new(:aolImporter, "", @account.password)
25
+ end
26
+ end
27
+
28
+ def test_fetch_contacts
29
+ contacts = Contacts.new(:aolImporter, @account.username, @account.password).contacts
30
+ @account.contacts.each do |contact|
31
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+ require 'contacts'
4
+
5
+ class FacebookContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:facebook]
9
+ end
10
+
11
+ def test_successful_login
12
+ Contacts.new(:facebook, @account.username, @account.password)
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:facebook, @account.username, "wrong_password")
18
+ end
19
+ end
20
+
21
+ def test_importer_fails_with_blank_password
22
+ assert_raise(Contacts::AuthenticationError) do
23
+ Contacts.new(:facebook, @account.username, "")
24
+ end
25
+ end
26
+
27
+ def test_importer_fails_with_blank_username
28
+ assert_raise(Contacts::AuthenticationError) do
29
+ Contacts.new(:facebook, "", @account.password, "")
30
+ end
31
+ end
32
+
33
+ def test_fetch_contacts
34
+ contacts = Contacts.new(:facebook, @account.username, @account.password).contacts
35
+ @account.contacts.each do |contact|
36
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+ require 'contacts'
4
+
5
+ class GmailContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:gmail]
9
+ end
10
+
11
+ def test_successful_login
12
+ Contacts.new(:gmail, @account.username, @account.password)
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:gmail, @account.username, "wrong_password")
18
+ end
19
+ end
20
+
21
+ def test_importer_fails_with_blank_password
22
+ assert_raise(Contacts::AuthenticationError) do
23
+ Contacts.new(:gmail, @account.username, "")
24
+ end
25
+ end
26
+
27
+ def test_importer_fails_with_blank_username
28
+ assert_raise(Contacts::AuthenticationError) do
29
+ Contacts.new(:gmail, "", @account.password)
30
+ end
31
+ end
32
+
33
+ def test_fetch_contacts
34
+ contacts = Contacts.new(:gmail, @account.username, @account.password).contacts
35
+ @account.contacts.each do |contact|
36
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+ require 'contacts'
4
+
5
+ class HotmailContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:hotmail]
9
+ end
10
+
11
+ def test_successful_login
12
+ Contacts.new(:hotmail, @account.username, @account.password)
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_msn_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:hotmail, "test@msn.com","wrong_password")
18
+ end
19
+ end
20
+
21
+ def test_importer_fails_with_invalid_password
22
+ assert_raise(Contacts::AuthenticationError) do
23
+ Contacts.new(:hotmail, @account.username,"wrong_password")
24
+ end
25
+ end
26
+
27
+ def test_fetch_contacts
28
+ contacts = Contacts.new(:hotmail, @account.username, @account.password).contacts
29
+ @account.contacts.each do |contact|
30
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
31
+ end
32
+ end
33
+
34
+ # Since the hotmail scraper doesn't read names, test email
35
+ def test_fetch_email
36
+ contacts = Contacts.new(:hotmail, @account.username, @account.password).contacts
37
+ @account.contacts.each do |contact|
38
+ assert contacts.any?{|book_contact| book_contact.last == contact.last }, "Could not find: #{contact.inspect} in #{contacts.inspect}"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,39 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+ require 'contacts'
4
+
5
+ class LinkedInContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:linked_in]
9
+ end
10
+
11
+ def test_successful_login
12
+ Contacts.new(:linked_in, @account.username, @account.password, "", {:app_id => @account.app_id, :app_secret => @account.app_secret})
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:linked_in, @account.username, "wrong_password", "", {:app_id => @account.app_id, :app_secret => @account.app_secret})
18
+ end
19
+ end
20
+
21
+ def test_importer_fails_with_blank_password
22
+ assert_raise(Contacts::AuthenticationError) do
23
+ Contacts.new(:linked_in, @account.username, "", "", {:app_id => @account.app_id, :app_secret => @account.app_secret})
24
+ end
25
+ end
26
+
27
+ def test_importer_fails_with_blank_username
28
+ assert_raise(Contacts::AuthenticationError) do
29
+ Contacts.new(:linked_in, "", @account.password, "", {:app_id => @account.app_id, :app_secret => @account.app_secret})
30
+ end
31
+ end
32
+
33
+ def test_fetch_contacts
34
+ contacts = Contacts.new(:linked_in, @account.username, @account.password, "", {:app_id => @account.app_id, :app_secret => @account.app_secret}).contacts
35
+ @account.contacts.each do |contact|
36
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,40 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+ require 'contacts'
4
+
5
+ class MailruContactImporterTest < ContactImporterTestCase
6
+ # TODO don't know enough russian to sign up for an account
7
+ # def setup
8
+ #super
9
+ #@account = TestAccounts[:mailru]
10
+ #end
11
+
12
+ #def test_successful_login
13
+ #Contacts.new(:mailru, @account.username, @account.password)
14
+ #end
15
+
16
+ #def test_importer_fails_with_invalid_password
17
+ #assert_raise(Contacts::AuthenticationError) do
18
+ #Contacts.new(:mailru, @account.username, "wrong_password")
19
+ #end
20
+ #end
21
+
22
+ #def test_importer_fails_with_blank_password
23
+ #assert_raise(Contacts::AuthenticationError) do
24
+ #Contacts.new(:mailru, @account.username, "")
25
+ #end
26
+ #end
27
+
28
+ #def test_importer_fails_with_blank_username
29
+ #assert_raise(Contacts::AuthenticationError) do
30
+ #Contacts.new(:mailru, "", @account.password)
31
+ #end
32
+ #end
33
+
34
+ #def test_fetch_contacts
35
+ #contacts = Contacts.new(:mailru, @account.username, @account.password).contacts
36
+ #@account.contacts.each do |contact|
37
+ #assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
38
+ #end
39
+ #end
40
+ end
@@ -0,0 +1,24 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+
4
+ class OutlookTest < ContactImporterTestCase
5
+ # TODO don't have these files atm
6
+ # context 'An instance of Outlook' do
7
+ #should 'open file properly' do
8
+ #outlookobject = Contacts.new(:outlook, File.open(File.dirname(__FILE__) + '/../outlook_fullname.csv'))
9
+ #assert_not_nil outlookobject
10
+ #end
11
+
12
+ #should 'get contacts from file with Full Name' do
13
+ #outlookobject = Contacts.new(:outlook, File.open(File.dirname(__FILE__) + '/../outlook_fullname.csv'))
14
+ #contacts = outlookobject.contacts
15
+ #assert_not_nil contacts
16
+ #end
17
+
18
+ #should 'get contacts from file with split up names' do
19
+ #outlookobject = Contacts.new(:outlook, File.open(File.dirname(__FILE__) + '/../outlook_splitname.csv'))
20
+ #contacts = outlookobject.contacts
21
+ #assert_not_nil contacts
22
+ #end
23
+ #end
24
+ end
@@ -0,0 +1,23 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+
4
+ class TestAccountsTest < ContactImporterTestCase
5
+ def test_test_accounts_loads_data_from_example_accounts_file
6
+ account = TestAccounts.load(File.dirname(__FILE__) + "/../example_accounts.yml")[:gmail]
7
+
8
+ assert_equal :gmail, account.type
9
+ assert_equal "<changeme>", account.username
10
+ assert_equal "<changeme>", account.password
11
+ assert_equal [["FirstName1 LastName1", "firstname1@example.com"], ["FirstName2 LastName2", "firstname2@example.com"]], account.contacts
12
+ end
13
+
14
+ def test_test_accounts_blows_up_if_file_doesnt_exist
15
+ assert_raise(RuntimeError) do
16
+ TestAccounts.load("file_that_does_not_exist.yml")
17
+ end
18
+ end
19
+
20
+ def test_we_can_load_from_account_file
21
+ assert_not_nil TestAccounts[:gmail].username
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+
4
+ class VcfTest < ContactImporterTestCase
5
+ # TODO need vcard file
6
+ # context 'An instance of Vcf' do
7
+ #should 'open file properly' do
8
+ #vcfobject = Contacts.new(:vcf, File.open(File.dirname(__FILE__) + '/../vCards.vcf'))
9
+ #assert_not_nil vcfobject
10
+ #end
11
+
12
+ #should 'get contacts from file' do
13
+ #vcfobject = Contacts.new(:vcf, File.open(File.dirname(__FILE__) + '/../vCards.vcf'))
14
+ #contacts = vcfobject.contacts
15
+ #assert_not_nil contacts
16
+ #end
17
+ # end
18
+ end
@@ -0,0 +1,35 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(".", dir, "..", "test_helper.rb")
3
+ require 'contacts'
4
+
5
+ class YahooContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:yahoo]
9
+ end
10
+
11
+ def test_a_successful_login
12
+ Contacts.new(:yahoo, @account.username, @account.password)
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:yahoo, @account.username, "wrong_password")
18
+ end
19
+ # run the "successful" login test to ensure we reset yahoo's failed login lockout counter
20
+ # See http://www.pivotaltracker.com/story/show/138210
21
+ # yahoo needs some time to unset the failed login state, apparently...
22
+ # ...1 sec and 5 secs still failed sporadically
23
+ sleep 10
24
+ assert_nothing_raised do
25
+ Contacts.new(:yahoo, @account.username, @account.password)
26
+ end
27
+ end
28
+
29
+ def test_a_fetch_contacts
30
+ contacts = Contacts.new(:yahoo, @account.username, @account.password).contacts
31
+ @account.contacts.each do |contact|
32
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: muck-contacts
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 6
9
+ - 1
10
+ version: 2.6.1
11
+ platform: ruby
12
+ authors:
13
+ - Rob Kaufman
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-21 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 17
27
+ segments:
28
+ - 1
29
+ - 1
30
+ - 1
31
+ version: 1.1.1
32
+ name: json
33
+ prerelease: false
34
+ type: :runtime
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ name: gdata
47
+ prerelease: false
48
+ type: :runtime
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ name: gdata19
61
+ prerelease: false
62
+ type: :runtime
63
+ requirement: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - "="
69
+ - !ruby/object:Gem::Version
70
+ hash: 59
71
+ segments:
72
+ - 0
73
+ - 8
74
+ - 2
75
+ version: 0.8.2
76
+ name: hpricot
77
+ prerelease: false
78
+ type: :runtime
79
+ requirement: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ name: encryptor
91
+ prerelease: false
92
+ type: :runtime
93
+ requirement: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ version_requirements: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 15
101
+ segments:
102
+ - 0
103
+ - 4
104
+ - 0
105
+ version: 0.4.0
106
+ name: oauth
107
+ prerelease: false
108
+ type: :runtime
109
+ requirement: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ version_requirements: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ name: jeweler
121
+ prerelease: false
122
+ type: :development
123
+ requirement: *id007
124
+ description: A universal interface to grab contact list information from various providers including Outlook, Address Book, Yahoo, AOL, Gmail, Hotmail, and Plaxo.
125
+ email: rob@notch8.com
126
+ executables: []
127
+
128
+ extensions: []
129
+
130
+ extra_rdoc_files:
131
+ - LICENSE
132
+ - README
133
+ files:
134
+ - Gemfile
135
+ - LICENSE
136
+ - README
137
+ - Rakefile
138
+ - VERSION
139
+ - contacts.gemspec
140
+ - cruise_config.rb
141
+ - examples/grab_contacts.rb
142
+ - geminstaller.yml
143
+ - lib/contacts.rb
144
+ - lib/contacts/aol_importer.rb
145
+ - lib/contacts/base.rb
146
+ - lib/contacts/facebook.rb
147
+ - lib/contacts/gmail.rb
148
+ - lib/contacts/hotmail.rb
149
+ - lib/contacts/json_picker.rb
150
+ - lib/contacts/linked_in.rb
151
+ - lib/contacts/mailru.rb
152
+ - lib/contacts/outlook.rb
153
+ - lib/contacts/plaxo.rb
154
+ - lib/contacts/vcf.rb
155
+ - lib/contacts/yahoo.rb
156
+ - test/example_accounts.yml
157
+ - test/test_helper.rb
158
+ - test/unit/aol_contact_importer_test.rb
159
+ - test/unit/facebook_contact_importer_test.rb
160
+ - test/unit/gmail_contact_importer_test.rb
161
+ - test/unit/hotmail_contact_importer_test.rb
162
+ - test/unit/linked_in_contact_importer_test.rb
163
+ - test/unit/mailru_contact_importer_test.rb
164
+ - test/unit/outlook_test.rb
165
+ - test/unit/test_accounts_test.rb
166
+ - test/unit/vcf_test.rb
167
+ - test/unit/yahoo_csv_contact_importer_test.rb
168
+ homepage: http://github.com/tatemae/contacts
169
+ licenses:
170
+ - MIT
171
+ post_install_message:
172
+ rdoc_options: []
173
+
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ hash: 3
182
+ segments:
183
+ - 0
184
+ version: "0"
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ none: false
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ hash: 3
191
+ segments:
192
+ - 0
193
+ version: "0"
194
+ requirements: []
195
+
196
+ rubyforge_project:
197
+ rubygems_version: 1.8.10
198
+ signing_key:
199
+ specification_version: 3
200
+ summary: A universal interface to grab contact list information from various providers including Outlook, Address Book, Yahoo, AOL, Gmail, Hotmail, and Plaxo.
201
+ test_files: []
202
+