yam-contacts 1.2.4.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,50 @@
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
+ mailru:
42
+ username: <changeme>
43
+ password: <changeme>
44
+ contacts:
45
+ -
46
+ name: "FirstName1 LastName1"
47
+ email_address: "firstname1@example.com"
48
+ -
49
+ name: "FirstName2 LastName2"
50
+ 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 '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__) + "/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,39 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../test_helper"
3
+ require 'contacts'
4
+
5
+ class MailruContactImporterTest < ContactImporterTestCase
6
+ def setup
7
+ super
8
+ @account = TestAccounts[:mailru]
9
+ end
10
+
11
+ def test_successful_login
12
+ Contacts.new(:mailru, @account.username, @account.password)
13
+ end
14
+
15
+ def test_importer_fails_with_invalid_password
16
+ assert_raise(Contacts::AuthenticationError) do
17
+ Contacts.new(:mailru, @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(:mailru, @account.username, "")
24
+ end
25
+ end
26
+
27
+ def test_importer_fails_with_blank_username
28
+ assert_raise(Contacts::AuthenticationError) do
29
+ Contacts.new(:mailru, "", @account.password)
30
+ end
31
+ end
32
+
33
+ def test_fetch_contacts
34
+ contacts = Contacts.new(:mailru, @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,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yam-contacts
3
+ version: !ruby/object:Gem::Version
4
+ hash: 93
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 4
10
+ - 1
11
+ version: 1.2.4.1
12
+ platform: ruby
13
+ authors:
14
+ - Lucas Carlson
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-10-17 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: json
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 17
31
+ segments:
32
+ - 1
33
+ - 1
34
+ - 1
35
+ version: 1.1.1
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: gdata
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 17
47
+ segments:
48
+ - 1
49
+ - 1
50
+ - 1
51
+ version: 1.1.1
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ description: A universal interface to grab contact list information from various providers including Yahoo, AOL, Gmail, Hotmail, and Plaxo.
55
+ email: lucas@rufy.com
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files: []
61
+
62
+ files:
63
+ - lib/contacts/gmail.rb
64
+ - lib/contacts/base.rb
65
+ - lib/contacts/mailru.rb
66
+ - lib/contacts/hotmail.rb
67
+ - lib/contacts/plaxo.rb
68
+ - lib/contacts/json_picker.rb
69
+ - lib/contacts/aol.rb
70
+ - lib/contacts/yahoo.rb
71
+ - lib/contacts.rb
72
+ - README
73
+ - LICENSE
74
+ - Rakefile
75
+ - test/unit/test_accounts_test.rb
76
+ - test/unit/mailru_contact_importer_test.rb
77
+ - test/unit/hotmail_contact_importer_test.rb
78
+ - test/unit/gmail_contact_importer_test.rb
79
+ - test/unit/yahoo_csv_contact_importer_test.rb
80
+ - test/unit/aol_contact_importer_test.rb
81
+ - test/test_helper.rb
82
+ - test/example_accounts.yml
83
+ - test/test_suite.rb
84
+ - examples/grab_contacts.rb
85
+ has_rdoc: true
86
+ homepage: http://github.com/yammer/contacts
87
+ licenses: []
88
+
89
+ post_install_message:
90
+ rdoc_options: []
91
+
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ requirements: []
113
+
114
+ rubyforge_project:
115
+ rubygems_version: 1.5.3
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: A universal interface to grab contact list information from various providers including Yahoo, AOL, Gmail, Hotmail, and Plaxo.
119
+ test_files:
120
+ - test/unit/test_accounts_test.rb
121
+ - test/unit/mailru_contact_importer_test.rb
122
+ - test/unit/hotmail_contact_importer_test.rb
123
+ - test/unit/gmail_contact_importer_test.rb
124
+ - test/unit/yahoo_csv_contact_importer_test.rb
125
+ - test/unit/aol_contact_importer_test.rb
126
+ - test/test_helper.rb
127
+ - test/example_accounts.yml
128
+ - test/test_suite.rb
129
+ - examples/grab_contacts.rb