briancollins-blackbook 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CHANGES.markdown +44 -0
  2. data/Manifest.txt +59 -0
  3. data/README.markdown +74 -0
  4. data/VERSION.yml +4 -0
  5. data/lib/blackbook.rb +83 -0
  6. data/lib/blackbook/exporter/base.rb +16 -0
  7. data/lib/blackbook/exporter/vcf.rb +45 -0
  8. data/lib/blackbook/exporter/xml.rb +28 -0
  9. data/lib/blackbook/importer/aol.rb +94 -0
  10. data/lib/blackbook/importer/base.rb +39 -0
  11. data/lib/blackbook/importer/csv.rb +68 -0
  12. data/lib/blackbook/importer/freenet.rb +62 -0
  13. data/lib/blackbook/importer/gmail.rb +73 -0
  14. data/lib/blackbook/importer/gmx.rb +68 -0
  15. data/lib/blackbook/importer/hotmail.rb +128 -0
  16. data/lib/blackbook/importer/page_scraper.rb +52 -0
  17. data/lib/blackbook/importer/web.de.rb +67 -0
  18. data/lib/blackbook/importer/yahoo.rb +73 -0
  19. data/test/config/credentials.yml.example +9 -0
  20. data/test/fixtures/aol_application_page.html +566 -0
  21. data/test/fixtures/aol_bad_login_response_stage_3.html +565 -0
  22. data/test/fixtures/aol_contacts.html +102 -0
  23. data/test/fixtures/aol_login_response_stage_1.html +158 -0
  24. data/test/fixtures/aol_login_response_stage_2.html +559 -0
  25. data/test/fixtures/aol_login_response_stage_3.html +48 -0
  26. data/test/fixtures/aol_login_response_stage_4.html +404 -0
  27. data/test/fixtures/aol_new_contacts.html +431 -0
  28. data/test/fixtures/gmail.csv +3 -0
  29. data/test/fixtures/gmail_bad_login_response_stage_2.html +560 -0
  30. data/test/fixtures/gmail_contacts.html +228 -0
  31. data/test/fixtures/gmail_login_response_stage_1.html +556 -0
  32. data/test/fixtures/gmail_login_response_stage_2.html +1 -0
  33. data/test/fixtures/gmail_login_response_stage_2a.html +1 -0
  34. data/test/fixtures/gmail_login_response_stage_3.html +249 -0
  35. data/test/fixtures/gmail_redirect_body.html +10 -0
  36. data/test/fixtures/hotmail_bad_login_response_stage_2.html +31 -0
  37. data/test/fixtures/hotmail_contacts.html +262 -0
  38. data/test/fixtures/hotmail_login_response_stage_1.html +31 -0
  39. data/test/fixtures/hotmail_login_response_stage_2.html +1 -0
  40. data/test/fixtures/hotmail_login_response_stage_3.html +519 -0
  41. data/test/fixtures/hotmail_scrape_first_page.html +77 -0
  42. data/test/fixtures/hotmail_scrape_response_stage_1.html +90 -0
  43. data/test/fixtures/hotmail_scrape_response_stage_2.html +77 -0
  44. data/test/fixtures/hotmail_scrape_response_stage_3.html +0 -0
  45. data/test/fixtures/yahoo_bad_login_response_stage_2.html +443 -0
  46. data/test/fixtures/yahoo_contacts.csv +3 -0
  47. data/test/fixtures/yahoo_contacts_not_logged_in.html +432 -0
  48. data/test/fixtures/yahoo_contacts_stage_1.html +399 -0
  49. data/test/fixtures/yahoo_login_response_stage_1.html +433 -0
  50. data/test/fixtures/yahoo_login_response_stage_2.html +16 -0
  51. data/test/fixtures/yahoo_no_user_response_stage_2.html +574 -0
  52. data/test/freenet_importer_test.rb +53 -0
  53. data/test/gmx_importer_test.rb +53 -0
  54. data/test/scripts/live_test.rb +25 -0
  55. data/test/test_blackbook.rb +60 -0
  56. data/test/test_blackbook_exporter_base.rb +16 -0
  57. data/test/test_blackbook_exporter_vcf.rb +52 -0
  58. data/test/test_blackbook_exporter_xml.rb +16 -0
  59. data/test/test_blackbook_importer_aol.rb +108 -0
  60. data/test/test_blackbook_importer_base.rb +24 -0
  61. data/test/test_blackbook_importer_csv.rb +60 -0
  62. data/test/test_blackbook_importer_gmail.rb +116 -0
  63. data/test/test_blackbook_importer_hotmail.rb +165 -0
  64. data/test/test_blackbook_importer_page_scraper.rb +51 -0
  65. data/test/test_blackbook_importer_yahoo.rb +137 -0
  66. data/test/test_helper.rb +71 -0
  67. data/test/web.de_importer_test.rb +53 -0
  68. metadata +128 -0
@@ -0,0 +1,71 @@
1
+ require 'ruby-debug'
2
+
3
+ module TestHelper
4
+
5
+ def fixture_path(name)
6
+ "#{File.dirname(__FILE__)}/fixtures/#{name}"
7
+ end
8
+
9
+ def load_fixture(file)
10
+ IO.readlines(fixture_path(file))
11
+ end
12
+
13
+ def fixture_file(name)
14
+ File.new fixture_path(name)
15
+ end
16
+
17
+ end
18
+
19
+ module Net #:nodoc:
20
+ class HTTP #:nodoc:
21
+
22
+ extend TestHelper
23
+
24
+ RESPONSES = {}
25
+
26
+ def self.responses=(r)
27
+ RESPONSES.clear
28
+ r.each{|k,v| RESPONSES[k] = v}
29
+ end
30
+
31
+
32
+ alias :old_net_http_request :request
33
+
34
+ def request(req, body = nil, &block)
35
+ prot = use_ssl ? "https" : "http"
36
+ uri_cls = use_ssl ? URI::HTTPS : URI::HTTP
37
+ query = req.path.split('?',2)
38
+ opts = {:host => self.address,
39
+ :port => self.port, :path => query[0]}
40
+ opts[:query] = query[1] if query[1]
41
+ uri = uri_cls.build(opts)
42
+ raise ArgumentError.new("#{req.method} method to #{uri} not being handled in testing")
43
+ end
44
+
45
+ def connect
46
+ raise ArgumentError.new("connect not being handled in testing")
47
+ end
48
+ end
49
+ end
50
+
51
+ plugin_root = "#{ File.dirname(__FILE__) }/.."
52
+
53
+ require 'rubygems'
54
+ require 'mocha'
55
+
56
+ module BlackbookExtensions
57
+ module TestHelper
58
+ class Credentials
59
+ attr_accessor :network, :config
60
+
61
+ def initialize(network)
62
+ self.network = network.to_s
63
+ self.config = YAML.load_file( File.join(File.dirname(__FILE__), "config/credentials.yml") )
64
+ end
65
+
66
+ def get
67
+ [ self.config[self.network]["username"], self.config[self.network]["password"] ]
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ context "The Web.de importer" do
4
+
5
+ setup do
6
+ @username, @password = BlackbookExtensions::TestHelper::Credentials.new(:webde).get
7
+
8
+ @importer = Blackbook::Importer::WebDE.new
9
+ @importer.create_agent
10
+ end
11
+
12
+ specify "should match emails" do
13
+ @importer.=~(nil).should.not.be
14
+ @importer.=~({}).should.not.be
15
+ @importer.=~({ 'username' => "john@foo.com" }).should.not.be
16
+ @importer.=~({ :username => "john@foo.com" }).should.not.be
17
+ @importer.=~({ :username => "john" }).should.not.be
18
+ @importer.=~({ :username => "john@web.de" }).should.be
19
+ @importer.=~({ :username => "JOHN@WEB.DE" }).should.be
20
+ end
21
+
22
+ specify "should be able to login with correct credentials" do
23
+ should.not.raise Exception do
24
+ login(@username, @password)
25
+ end
26
+ end
27
+
28
+ specify "should raise BadCredentialsError on login with wrong credentials" do
29
+ should.raise Blackbook::BadCredentialsError do
30
+ login
31
+ end
32
+ end
33
+
34
+ specify "should raise BadCredentialsError on login with correct username and wrong password" do
35
+ should.raise Blackbook::BadCredentialsError do
36
+ login(@username)
37
+ end
38
+ end
39
+
40
+ specify "should able to get contacts" do
41
+ login(@username, @password)
42
+
43
+ contacts = @importer.scrape_contacts
44
+ contacts.should.not.be.empty
45
+ contacts.should.be.all { |contact| contact.is_a? Hash }
46
+ end
47
+
48
+ private
49
+ def login(username = "foo", password = "bar")
50
+ @importer.options = { :username => username, :password => password }
51
+ @importer.login
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: briancollins-blackbook
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.15
5
+ platform: ruby
6
+ authors:
7
+ - Rany Keddo
8
+ - Brian Cardarella
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-03-31 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: TODO
18
+ email: bcardarella@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - CHANGES.markdown
27
+ - Manifest.txt
28
+ - README.markdown
29
+ - VERSION.yml
30
+ - lib/blackbook
31
+ - lib/blackbook/exporter
32
+ - lib/blackbook/exporter/base.rb
33
+ - lib/blackbook/exporter/vcf.rb
34
+ - lib/blackbook/exporter/xml.rb
35
+ - lib/blackbook/importer
36
+ - lib/blackbook/importer/aol.rb
37
+ - lib/blackbook/importer/base.rb
38
+ - lib/blackbook/importer/csv.rb
39
+ - lib/blackbook/importer/freenet.rb
40
+ - lib/blackbook/importer/gmail.rb
41
+ - lib/blackbook/importer/gmx.rb
42
+ - lib/blackbook/importer/hotmail.rb
43
+ - lib/blackbook/importer/page_scraper.rb
44
+ - lib/blackbook/importer/web.de.rb
45
+ - lib/blackbook/importer/yahoo.rb
46
+ - lib/blackbook.rb
47
+ - test/config
48
+ - test/config/credentials.yml.example
49
+ - test/fixtures
50
+ - test/fixtures/aol_application_page.html
51
+ - test/fixtures/aol_bad_login_response_stage_3.html
52
+ - test/fixtures/aol_contacts.html
53
+ - test/fixtures/aol_login_response_stage_1.html
54
+ - test/fixtures/aol_login_response_stage_2.html
55
+ - test/fixtures/aol_login_response_stage_3.html
56
+ - test/fixtures/aol_login_response_stage_4.html
57
+ - test/fixtures/aol_new_contacts.html
58
+ - test/fixtures/gmail.csv
59
+ - test/fixtures/gmail_bad_login_response_stage_2.html
60
+ - test/fixtures/gmail_contacts.html
61
+ - test/fixtures/gmail_login_response_stage_1.html
62
+ - test/fixtures/gmail_login_response_stage_2.html
63
+ - test/fixtures/gmail_login_response_stage_2a.html
64
+ - test/fixtures/gmail_login_response_stage_3.html
65
+ - test/fixtures/gmail_redirect_body.html
66
+ - test/fixtures/hotmail_bad_login_response_stage_2.html
67
+ - test/fixtures/hotmail_contacts.html
68
+ - test/fixtures/hotmail_login_response_stage_1.html
69
+ - test/fixtures/hotmail_login_response_stage_2.html
70
+ - test/fixtures/hotmail_login_response_stage_3.html
71
+ - test/fixtures/hotmail_scrape_first_page.html
72
+ - test/fixtures/hotmail_scrape_response_stage_1.html
73
+ - test/fixtures/hotmail_scrape_response_stage_2.html
74
+ - test/fixtures/hotmail_scrape_response_stage_3.html
75
+ - test/fixtures/yahoo_bad_login_response_stage_2.html
76
+ - test/fixtures/yahoo_contacts.csv
77
+ - test/fixtures/yahoo_contacts_not_logged_in.html
78
+ - test/fixtures/yahoo_contacts_stage_1.html
79
+ - test/fixtures/yahoo_login_response_stage_1.html
80
+ - test/fixtures/yahoo_login_response_stage_2.html
81
+ - test/fixtures/yahoo_no_user_response_stage_2.html
82
+ - test/freenet_importer_test.rb
83
+ - test/gmx_importer_test.rb
84
+ - test/scripts
85
+ - test/scripts/live_test.rb
86
+ - test/test_blackbook.rb
87
+ - test/test_blackbook_exporter_base.rb
88
+ - test/test_blackbook_exporter_vcf.rb
89
+ - test/test_blackbook_exporter_xml.rb
90
+ - test/test_blackbook_importer_aol.rb
91
+ - test/test_blackbook_importer_base.rb
92
+ - test/test_blackbook_importer_csv.rb
93
+ - test/test_blackbook_importer_gmail.rb
94
+ - test/test_blackbook_importer_hotmail.rb
95
+ - test/test_blackbook_importer_page_scraper.rb
96
+ - test/test_blackbook_importer_yahoo.rb
97
+ - test/test_helper.rb
98
+ - test/web.de_importer_test.rb
99
+ has_rdoc: true
100
+ homepage: http://github.com/bcardarella/blackbook
101
+ licenses:
102
+ post_install_message:
103
+ rdoc_options:
104
+ - --inline-source
105
+ - --charset=UTF-8
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ version:
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ version:
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.3.5
124
+ signing_key:
125
+ specification_version: 2
126
+ summary: TODO
127
+ test_files: []
128
+