im_contacts 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,101 @@
1
+ gmail:
2
+ username: <changeme>
3
+ password: <changeme>
4
+ contacts:
5
+ -
6
+ name: "FirstName1 LastName1"
7
+ email_address: "firstname1@example.com"
8
+ -
9
+ name: "FirstName2 LastName2"
10
+ email_address: "firstname2@example.com"
11
+ yahoo:
12
+ username: <changeme>
13
+ password: <changeme>
14
+ contacts:
15
+ -
16
+ name: "FirstName1 LastName1"
17
+ email_address: "firstname1@example.com"
18
+ -
19
+ name: "FirstName2 LastName2"
20
+ email_address: "firstname2@example.com"
21
+ hotmail:
22
+ username: <changeme>
23
+ password: <changeme>
24
+ contacts:
25
+ -
26
+ name: "FirstName1 LastName1"
27
+ email_address: "firstname1@example.com"
28
+ -
29
+ name: "FirstName2 LastName2"
30
+ email_address: "firstname2@example.com"
31
+ aol:
32
+ username: <changeme>
33
+ password: <changeme>
34
+ contacts:
35
+ -
36
+ name: "FirstName1 LastName1"
37
+ email_address: "firstname1@example.com"
38
+ -
39
+ name: "FirstName2 LastName2"
40
+ email_address: "firstname2@example.com"
41
+
42
+ wy163:
43
+ username: <changeme>
44
+ password: <changeme>
45
+ contacts:
46
+ -
47
+ name: "FirstName1 LastName1"
48
+ email_address: "firstname1@example.com"
49
+ -
50
+ name: "FirstName2 LastName2"
51
+ email_address: "firstname2@example.com"
52
+ wy126:
53
+ username: <changeme>
54
+ password: <changeme>
55
+ contacts:
56
+ -
57
+ name: "FirstName1 LastName1"
58
+ email_address: "firstname1@example.com"
59
+ -
60
+ name: "FirstName2 LastName2"
61
+ email_address: "firstname2@example.com"
62
+ yeah:
63
+ username: <changeme>
64
+ password: <changeme>
65
+ contacts:
66
+ -
67
+ name: "FirstName1 LastName1"
68
+ email_address: "firstname1@example.com"
69
+ -
70
+ name: "FirstName2 LastName2"
71
+ email_address: "firstname2@example.com"
72
+ sina_cn:
73
+ username: <changeme>
74
+ password: <changeme>
75
+ contacts:
76
+ -
77
+ name: "FirstName1 LastName1"
78
+ email_address: "firstname1@example.com"
79
+ -
80
+ name: "FirstName2 LastName2"
81
+ email_address: "firstname2@example.com"
82
+ sina_com:
83
+ username: <changeme>
84
+ password: <changeme>
85
+ contacts:
86
+ -
87
+ name: "FirstName1 LastName1"
88
+ email_address: "firstname1@example.com"
89
+ -
90
+ name: "FirstName2 LastName2"
91
+ email_address: "firstname2@example.com"
92
+ sohu:
93
+ username: <changeme>
94
+ password: <changeme>
95
+ contacts:
96
+ -
97
+ name: "FirstName1 LastName1"
98
+ email_address: "firstname1@example.com"
99
+ -
100
+ name: "FirstName2 LastName2"
101
+ email_address: "firstname2@example.com"
@@ -0,0 +1,31 @@
1
+ dir = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift(dir + "/../lib/")
3
+ require 'test/unit'
4
+ require 'im_contacts'
5
+ require 'yaml'
6
+
7
+ class ContactImporterTestCase < Test::Unit::TestCase
8
+ # Add more helper methods to be used by all tests here...
9
+ def default_test
10
+ assert true
11
+ end
12
+ end
13
+
14
+ class TestAccounts
15
+ def self.[](type)
16
+ load[type]
17
+ end
18
+
19
+ def self.load(file = File.dirname(__FILE__) + "/example_accounts.yml")
20
+ raise "/test/accounts.yml file not found, please create, see /test/example_accounts.yml for information" unless File.exist?(file)
21
+
22
+ accounts = {}
23
+ YAML::load(File.open(file)).each do |type, contents|
24
+ contacts = contents["contacts"].collect {|contact| [contact["name"], contact["email_address"]]}
25
+ accounts[type.to_sym] = Account.new(type.to_sym, contents["username"], contents["password"], contacts)
26
+ end
27
+ accounts
28
+ end
29
+
30
+ Account = Struct.new :type, :username, :password, :contacts
31
+ end
@@ -0,0 +1,4 @@
1
+ dir = File.dirname(__FILE__)
2
+ Dir["#{dir}/**/*_test.rb"].each do |file|
3
+ require file
4
+ end
@@ -0,0 +1,39 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../test_helper"
3
+ require 'contacts'
4
+
5
+ class AolContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:aol]
9
+ end
10
+
11
+ def test_successful_login
12
+ Contacts.new(:aol, @account.username, @account.password)
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:aol, @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(:aol, @account.username, "")
24
+ end
25
+ end
26
+
27
+ def test_importer_fails_with_blank_username
28
+ assert_raise(Contacts::AuthenticationError) do
29
+ Contacts.new(:aol, "", @account.password)
30
+ end
31
+ end
32
+
33
+ def test_fetch_contacts
34
+ contacts = Contacts.new(:aol, @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 "#{dir}/../test_helper"
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 "#{dir}/../test_helper"
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_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:hotmail, @account.username,"wrong_password")
18
+ end
19
+ end
20
+
21
+ def test_fetch_contacts
22
+ contacts = Contacts.new(:hotmail, @account.username, @account.password).contacts
23
+ @account.contacts.each do |contact|
24
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
25
+ end
26
+ end
27
+
28
+ def test_importer_fails_with_invalid_msn_password
29
+ assert_raise(Contacts::AuthenticationError) do
30
+ Contacts.new(:hotmail, "test@msn.com","wrong_password")
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,60 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../test_helper"
3
+ require 'contacts'
4
+ class NetEaseContactImporterTest < ContactImporterTestCase
5
+ def setup
6
+ super
7
+ @wy163 = TestAccounts[:wy163]
8
+ @wy126 = TestAccounts[:wy126]
9
+ @yeah = TestAccounts[:yeah]
10
+ @accounts = [@wy163,@wy126,@yeah]
11
+ end
12
+
13
+ def test_successful_login
14
+ @accounts.each do |account|
15
+ Contacts.new(:net_ease, account.username, account.password)
16
+ end
17
+ end
18
+
19
+ def test_importer_fails_with_invalid_password
20
+ @accounts.each do |account|
21
+ assert_raise(Contacts::AuthenticationError) do
22
+ Contacts.new(:net_ease, account.username, "wrong_password")
23
+ end
24
+ end
25
+ end
26
+
27
+ def test_importer_fails_with_blank_password
28
+ @accounts.each do |account|
29
+ assert_raise(Contacts::AuthenticationError) do
30
+ Contacts.new(:net_ease, account.username, "")
31
+ end
32
+ end
33
+ end
34
+
35
+ def test_importer_fails_with_blank_username
36
+ @accounts.each do |account|
37
+ assert_raise(Contacts::MailServerError) do
38
+ Contacts.new(:net_ease, "", account.password)
39
+ end
40
+ end
41
+ end
42
+
43
+ def test_importer_fails_with_invalid_username
44
+ @accounts.each do |account|
45
+ assert_raise(Contacts::MailServerError) do
46
+ Contacts.new(:net_ease, "error_username", account.password)
47
+ end
48
+ end
49
+ end
50
+
51
+ def test_fetch_contacts
52
+ @accounts.each do |account|
53
+ contacts = Contacts.new(:net_ease, account.username, account.password).contacts
54
+ account.contacts.each do |contact|
55
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
56
+ end
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,59 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../test_helper"
3
+ require 'contacts'
4
+ class SinaContactImporterTest < ContactImporterTestCase
5
+ def setup
6
+ super
7
+ @sina_cn = TestAccounts[:sina_cn]
8
+ @sina_com = TestAccounts[:sina_com]
9
+ @accounts = [@sina_cn,@sina_com]
10
+ end
11
+
12
+ def test_successful_login
13
+ @accounts.each do |account|
14
+ Contacts.new(:sina, account.username, account.password)
15
+ end
16
+ end
17
+
18
+ def test_importer_fails_with_invalid_password
19
+ @accounts.each do |account|
20
+ assert_raise(Contacts::AuthenticationError) do
21
+ Contacts.new(:sina, account.username, "wrong_password")
22
+ end
23
+ end
24
+ end
25
+
26
+ def test_importer_fails_with_blank_password
27
+ @accounts.each do |account|
28
+ assert_raise(Contacts::AuthenticationError) do
29
+ Contacts.new(:sina, account.username, "")
30
+ end
31
+ end
32
+ end
33
+
34
+ def test_importer_fails_with_blank_username
35
+ @accounts.each do |account|
36
+ assert_raise(Contacts::MailServerError) do
37
+ Contacts.new(:sina, "", account.password)
38
+ end
39
+ end
40
+ end
41
+
42
+ def test_importer_fails_with_invalid_username
43
+ @accounts.each do |account|
44
+ assert_raise(Contacts::MailServerError) do
45
+ Contacts.new(:sina, "error_username", account.password)
46
+ end
47
+ end
48
+ end
49
+
50
+ def test_fetch_contacts
51
+ @accounts.each do |account|
52
+ contacts = Contacts.new(:sina, account.username, account.password).contacts
53
+ account.contacts.each do |contact|
54
+ assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}"
55
+ end
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,39 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../test_helper"
3
+ require 'contacts'
4
+
5
+ class SohuContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:sohu]
9
+ end
10
+
11
+ def test_successful_login
12
+ Contacts.new(:sohu, @account.username, @account.password)
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:sohu, @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(:sohu, @account.username, "")
24
+ end
25
+ end
26
+
27
+ def test_importer_fails_with_blank_username
28
+ assert_raise(Contacts::AuthenticationError) do
29
+ Contacts.new(:sohu, "", @account.password)
30
+ end
31
+ end
32
+
33
+ def test_fetch_contacts
34
+ contacts = Contacts.new(:sohu, @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,23 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../test_helper"
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,35 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../test_helper"
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,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: im_contacts
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 7
10
+ version: 1.2.7
11
+ platform: ruby
12
+ authors:
13
+ - Mike Liang
14
+ autorequire: contacts
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 13
29
+ segments:
30
+ - 0
31
+ - 4
32
+ - 1
33
+ version: 0.4.1
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: gdata19
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 103
45
+ segments:
46
+ - 0
47
+ - 1
48
+ - 9
49
+ - 2
50
+ version: 0.1.9.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: " A universal interface to grab contact list information from various providers including Yahoo, AOL, Gmail, Hotmail, 126, 163, Yeah, Sohu, Sina and Plaxo.It is extended from contacts gem.\n"
54
+ email:
55
+ - liangwenke.com@gmail.com
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files: []
61
+
62
+ files:
63
+ - lib/contacts/aol.rb
64
+ - lib/contacts/base.rb
65
+ - lib/contacts/gmail.rb
66
+ - lib/contacts/hash_ext.rb
67
+ - lib/contacts/hotmail.rb
68
+ - lib/contacts/json_picker.rb
69
+ - lib/contacts/net_ease.rb
70
+ - lib/contacts/plaxo.rb
71
+ - lib/contacts/sina.rb
72
+ - lib/contacts/sohu.rb
73
+ - lib/contacts/yahoo.rb
74
+ - lib/im_contacts.rb
75
+ - test/example_accounts.yml
76
+ - test/test_helper.rb
77
+ - test/test_suite.rb
78
+ - test/unit/aol_contact_importer_test.rb
79
+ - test/unit/gmail_contact_importer_test.rb
80
+ - test/unit/hotmail_contact_importer_test.rb
81
+ - test/unit/net_ease_contact_importer_test.rb
82
+ - test/unit/sina_contact_importer_test.rb
83
+ - test/unit/sohu_contact_importer_test.rb
84
+ - test/unit/test_accounts_test.rb
85
+ - test/unit/yahoo_csv_contact_importer_test.rb
86
+ - LICENSE
87
+ - Rakefile
88
+ - README
89
+ - examples/grab_contacts.rb
90
+ homepage: http://github.com/liangwenke/im_contacts
91
+ licenses: []
92
+
93
+ post_install_message:
94
+ rdoc_options: []
95
+
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ requirements:
117
+ - A json parser, the gdata ruby gem
118
+ rubyforge_project:
119
+ rubygems_version: 1.8.10
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: A universal interface to grab contact list information from various providers including Yahoo, AOL, Gmail, Hotmail, 126, 163, Yeah, Sohu, Sina and Plaxo.It is extended from contacts gem.
123
+ test_files: []
124
+