graybook 1.0.24 → 1.1.0

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.
Files changed (73) hide show
  1. data/{CHANGES.md → CHANGELOG} +13 -2
  2. data/README +94 -0
  3. data/Rakefile +3 -22
  4. data/VERSION +1 -1
  5. data/VERSION.yml +2 -2
  6. data/VERSION_NAME +1 -1
  7. data/lib/graybook/importer/aol.rb +11 -11
  8. data/lib/graybook/importer/gmail.rb +20 -20
  9. data/lib/graybook/importer/hotmail.rb +2 -4
  10. data/lib/graybook/importer/page_scraper.rb +4 -2
  11. data/lib/graybook/importer/yahoo.rb +12 -12
  12. data/lib/graybook.rb +20 -21
  13. metadata +9 -102
  14. data/README.md +0 -66
  15. data/debug_graybook.rb +0 -10
  16. data/lib/graybook/exporter/vcf.rb +0 -45
  17. data/lib/graybook/exporter/xml.rb +0 -28
  18. data/lib/graybook/importer/csv.rb +0 -74
  19. data/lib/graybook/importer/freenet.rb +0 -62
  20. data/lib/graybook/importer/gmx.rb +0 -68
  21. data/lib/graybook/importer/web.de.rb +0 -67
  22. data/test/config/credentials.yml.example +0 -9
  23. data/test/fixtures/aol_application_page.html +0 -566
  24. data/test/fixtures/aol_bad_login_response_stage_3.html +0 -565
  25. data/test/fixtures/aol_contacts.html +0 -102
  26. data/test/fixtures/aol_login_response_stage_1.html +0 -158
  27. data/test/fixtures/aol_login_response_stage_2.html +0 -559
  28. data/test/fixtures/aol_login_response_stage_3.html +0 -48
  29. data/test/fixtures/aol_login_response_stage_4.html +0 -404
  30. data/test/fixtures/aol_login_response_stage_5.html +0 -404
  31. data/test/fixtures/aol_new_contacts.html +0 -431
  32. data/test/fixtures/gmail.csv +0 -3
  33. data/test/fixtures/gmail_bad_login_response_stage_2.html +0 -560
  34. data/test/fixtures/gmail_contacts.html +0 -228
  35. data/test/fixtures/gmail_login_response_stage_1.html +0 -556
  36. data/test/fixtures/gmail_login_response_stage_2.html +0 -1
  37. data/test/fixtures/gmail_login_response_stage_2a.html +0 -1
  38. data/test/fixtures/gmail_login_response_stage_3.html +0 -249
  39. data/test/fixtures/gmail_redirect_body.html +0 -10
  40. data/test/fixtures/hotmail_bad_login_response_stage_2.html +0 -31
  41. data/test/fixtures/hotmail_contacts.html +0 -262
  42. data/test/fixtures/hotmail_login_response_stage_1.html +0 -31
  43. data/test/fixtures/hotmail_login_response_stage_2.html +0 -1
  44. data/test/fixtures/hotmail_login_response_stage_3.html +0 -519
  45. data/test/fixtures/hotmail_scrape_first_page.html +0 -77
  46. data/test/fixtures/hotmail_scrape_response_stage_1.html +0 -90
  47. data/test/fixtures/hotmail_scrape_response_stage_2.html +0 -77
  48. data/test/fixtures/hotmail_scrape_response_stage_3.html +0 -0
  49. data/test/fixtures/yahoo_bad_login_response_stage_2.html +0 -443
  50. data/test/fixtures/yahoo_contacts.csv +0 -3
  51. data/test/fixtures/yahoo_contacts_not_logged_in.html +0 -432
  52. data/test/fixtures/yahoo_contacts_stage_1.html +0 -399
  53. data/test/fixtures/yahoo_login_response_stage_1.html +0 -433
  54. data/test/fixtures/yahoo_login_response_stage_2.html +0 -16
  55. data/test/fixtures/yahoo_no_user_response_stage_2.html +0 -574
  56. data/test/freenet_importer_test.rb +0 -53
  57. data/test/gmx_importer_test.rb +0 -53
  58. data/test/scripts/live_test.rb +0 -25
  59. data/test/test_graybook.rb +0 -60
  60. data/test/test_graybook_exporter_base.rb +0 -16
  61. data/test/test_graybook_exporter_vcf.rb +0 -52
  62. data/test/test_graybook_exporter_xml.rb +0 -16
  63. data/test/test_graybook_importer_aol.rb +0 -108
  64. data/test/test_graybook_importer_base.rb +0 -24
  65. data/test/test_graybook_importer_csv.rb +0 -60
  66. data/test/test_graybook_importer_gmail.rb +0 -116
  67. data/test/test_graybook_importer_hotmail.rb +0 -165
  68. data/test/test_graybook_importer_page_scraper.rb +0 -51
  69. data/test/test_graybook_importer_yahoo.rb +0 -137
  70. data/test/test_helper.rb +0 -71
  71. data/test/web.de_importer_test.rb +0 -53
  72. data/vendor/plugins/graybook/lib/autotest/discover.rb +0 -3
  73. data/vendor/plugins/graybook/lib/autotest/graybook.rb +0 -27
@@ -1,5 +1,16 @@
1
- ==1.0.24
2
-
1
+ ==1.1.0 / 2009-10-01
2
+
3
+ * Removed the completely outdates tests (will write new tests next patch)
4
+ * Restricted importers to the following:
5
+ * AOL/AIM
6
+ * Yahoo
7
+ * Hotmail/Live/MSN
8
+ * Google Mail
9
+ * Restricted exporters to just basic.
10
+ * Got rid of exception raising and instead implemented Problem, a child
11
+ of Exception that returns true on .nil? This is to pass error
12
+ messages back all the way through the .get function to whatever it
13
+ originated from (e.g. Rails).
3
14
  * Fixed Hotmail contact regexp to reflect new site.
4
15
 
5
16
  ==1.0.22 / 2009-09-30
data/README ADDED
@@ -0,0 +1,94 @@
1
+ ,-------------------------,
2
+ | |,
3
+ (=========================||
4
+ (=========================||
5
+ (=========================||
6
+ | __, ,_ __, ||
7
+ | / | / | / | | | ||
8
+ | \_/|/ |_/\_/|_/ \_/|/ ||
9
+ | /| /| ||
10
+ | \| \| ||
11
+ | _ _ ||
12
+ | | | | | ||
13
+ | | | __ __ | | ||
14
+ | |/ \_/ \_/ \_|/_) ||
15
+ | \_/ \__/ \__/ | \_/ ||
16
+ (=========================||
17
+ (=========================||
18
+ (=========================||
19
+ | ||
20
+ |_________________________'|
21
+ '-------------------------'
22
+
23
+ Description:
24
+ ------------
25
+
26
+ Pulls contact lists from EVERYWHERE! (Some sites not included.)
27
+ Originally based on Blackbook, but heavily modified and simplified.
28
+
29
+ Features:
30
+ ---------
31
+
32
+ The current list of supported services and file types:
33
+
34
+ Services:
35
+ - AOL/AIM
36
+ - Yahoo
37
+ - Hotmail/Live/MSN
38
+ - Google Mail
39
+
40
+ Synopsis:
41
+ ---------
42
+
43
+ Returns an array of hashes containing a name key and an email key can
44
+ be used as is oreasily be converted into a JSON that can be iterated
45
+ though.
46
+
47
+ >> contacts = Graybook.get :service,
48
+ :username => 'username@service.com',
49
+ :password => 'supersecret'
50
+ => [{:name => 'john doe', :email => 'male@unknown.com'},
51
+ {:named => 'jane doe', :email => 'female@unknown.com'}]
52
+
53
+ Requirements:
54
+ -------------
55
+
56
+ * Mechanize >= 0.7.0 for page scraping
57
+
58
+ Install:
59
+ --------
60
+
61
+ 1. gem install gemcutter
62
+ 1. gem tumble
63
+ 2. gem install graybook
64
+
65
+ Thanks:
66
+ -------
67
+
68
+ Big thanks to the peoples of Contentfree for making Blackbook.
69
+ More thanks to everyone else who maintained working forks of Blackbook.
70
+
71
+ License:
72
+ --------
73
+
74
+ Copyright (c) 2009, kojul.com
75
+ Copyright (c) 2007, Contentfree
76
+
77
+ Permission is hereby granted, free of charge, to any person obtaining
78
+ a copy of this software and associated documentation files (the
79
+ 'Software'), to deal in the Software without restriction, including
80
+ without limitation the rights to use, copy, modify, merge, publish,
81
+ distribute, sublicense, and/or sell copies of the Software, and to
82
+ permit persons to whom the Software is furnished to do so, subject to
83
+ the following conditions:
84
+
85
+ The above copyright notice and this permission notice shall be
86
+ included in all copies or substantial portions of the Software.
87
+
88
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
89
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
90
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
91
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
92
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
93
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
94
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,39 +1,20 @@
1
1
  # -*- ruby -*-
2
2
 
3
3
  require 'rubygems'
4
- require 'hoe'
5
4
  $LOAD_PATH.unshift 'lib'
6
5
  require 'graybook'
7
6
 
8
- begin
9
- require 'rcov/rcovtask'
10
- rescue LoadError
11
- end
12
-
13
- begin
14
- Rcov::RcovTask.new do |t|
15
- t.test_files = FileList['test/test*.rb']
16
- t.verbose = true
17
- #t.rcov_opts << "--exclude rcov.rb,hpricot.rb,hpricot/.*\.rb"
18
- end
19
- rescue NameError
20
- end
21
-
22
- require 'rubygems'
23
-
24
7
  begin
25
8
  require 'jeweler'
26
9
  Jeweler::Tasks.new do |s|
27
10
  s.name = "graybook"
28
- s.summary = "It does things. Like import contacts from EVERYWHERE."
11
+ s.summary = "It does things. Like import contacts from EVERYWHERE. (Some sites may be excluded)"
29
12
  s.email = "kojul@kojul.com"
30
13
  s.homepage = "http://github.com/kojul/gray"
31
- s.description = "It does things. Like import contacts from EVERYWHERE."
32
- s.authors = ["kojul"]
14
+ s.description = "Graybook is used to import email contact lists from popular webmail sites. Currently supported are AOL/AIM, Yahoo, Hotmail/Live/MSN, and Google Mail (although not Google Apps Mail yet)."
15
+ s.authors = ["kojul", "Contentfree"]
33
16
  s.add_dependency('hpricot', '>= 0.7.0')
34
17
  s.add_dependency('mechanize', '>= 0.7.0')
35
- s.add_dependency('hoe', '>= 1.5.0')
36
- s.add_dependency('fastercsv', '>= 1.2.0')
37
18
  end
38
19
  rescue LoadError
39
20
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.24
1
+ 1.1.0
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 0
4
- :patch: 24
3
+ :minor: 1
4
+ :patch: 0
data/VERSION_NAME CHANGED
@@ -1 +1 @@
1
- Gray Gorilla
1
+ Gray Grouper
@@ -11,7 +11,7 @@ class Graybook::Importer::Aol < Graybook::Importer::PageScraper
11
11
  def =~( options )
12
12
  options && options[:username] =~ /@(aol|aim)\.com$/i ? true : false
13
13
  end
14
-
14
+
15
15
  ##
16
16
  # Login process:
17
17
  # - Get mail.aol.com which redirects to a page containing a javascript redirect
@@ -29,36 +29,36 @@ class Graybook::Importer::Aol < Graybook::Importer::PageScraper
29
29
 
30
30
  case page.body
31
31
  when /Invalid Screen Name or Password. Please try again./
32
- raise( Graybook::BadCredentialsError, "That username and password was not accepted. Please check them and try again." )
32
+ return Problem.new("Username and password were not accepted. Please check them and try again.")
33
33
  when /Terms of Service/
34
- raise( Graybook::LegacyAccount, "Your AOL account is not setup for WebMail. Please signup: http://webmail.aol.com")
34
+ return Problem.new("Your AOL account is not setup for WebMail. Please signup: http://webmail.aol.com")
35
35
  end
36
36
 
37
37
  # aol bumps to a wait page while logging in. if we can't scrape out the js then its a bad login
38
38
  extractor = proc { |var_name| page.body.scan(/var\s*#{var_name}\s*=\s*\"(.*?)\"\s*;/).first.first }
39
-
39
+
40
40
  base_uri = extractor.call( 'gSuccessPath' )
41
- raise( Graybook::BadCredentialsError, "You do not appear to be signed in." ) unless base_uri
41
+ return Problem.new("An error occurred. Please try again.") unless base_uri
42
42
  page = agent.get base_uri
43
43
  end
44
-
44
+
45
45
  ##
46
46
  # must login to prepare
47
47
 
48
48
  def prepare
49
49
  login
50
50
  end
51
-
51
+
52
52
  ##
53
53
  # The url to scrape contacts from has to be put together from the Auth cookie
54
54
  # and a known uri that hosts their contact service. An array of hashes with
55
55
  # :name and :email keys is returned.
56
56
 
57
- def scrape_contacts
57
+ def scrape_contacts
58
58
  unless auth_cookie = agent.cookies.find{|c| c.name =~ /^Auth/}
59
- raise( Graybook::BadCredentialsError, "Must be authenticated to access contacts." )
59
+ return Problem.new("An error occurred. Please try again.")
60
60
  end
61
-
61
+
62
62
  # jump through the hoops of formulating a request to get printable contacts
63
63
  uri = agent.current_page.uri.dup
64
64
  inputs = agent.current_page.search("//input")
@@ -82,6 +82,6 @@ class Graybook::Importer::Aol < Graybook::Importer::PageScraper
82
82
  }
83
83
  end
84
84
  end
85
-
85
+
86
86
  Graybook.register :aol, self
87
87
  end
@@ -9,11 +9,11 @@ class Graybook::Importer::Gmail < Graybook::Importer::PageScraper
9
9
  RETRY_THRESHOLD = 5
10
10
  ##
11
11
  # Matches this importer to an user's name/address
12
-
12
+
13
13
  def =~(options = {})
14
14
  options && options[:username] =~ /@(gmail|googlemail).com$/i ? true : false
15
15
  end
16
-
16
+
17
17
  def import(*args)
18
18
  # GMail depends on Hpricot for some reason...
19
19
  parser = WWW::Mechanize.html_parser
@@ -22,41 +22,41 @@ class Graybook::Importer::Gmail < Graybook::Importer::PageScraper
22
22
  WWW::Mechanize.html_parser = parser
23
23
  end
24
24
  end
25
-
25
+
26
26
  ##
27
27
  # login to gmail
28
28
 
29
- def login
29
+ def login
30
30
  page = agent.get('http://mail.google.com/mail/')
31
31
  form = page.forms.first
32
32
  form.Email = options[:username]
33
33
  form.Passwd = options[:password]
34
34
  page = agent.submit(form,form.buttons.first)
35
-
36
- raise( Graybook::BadCredentialsError, "That username and password was not accepted. Please check them and try again." ) if page.body =~ /Username and password do not match/
37
-
35
+
36
+ return Problem.new("Username and password were not accepted. Please check them and try again.") if page.body =~ /Username and password do not match/
37
+
38
38
  if page.search('//meta').first.attributes['content'] =~ /url='?(http.+?)'?$/i
39
39
  page = agent.get $1
40
40
  end
41
41
  end
42
-
42
+
43
43
  ##
44
44
  # prepare this importer
45
45
 
46
46
  def prepare
47
47
  login
48
48
  end
49
-
49
+
50
50
  ##
51
51
  # scrape gmail contacts for this importer
52
52
 
53
- def scrape_contacts
54
- unless agent.cookies.find { |c|
55
- c.name == 'GAUSR' && c.value.match(/mail(.*?):#{options[:username]}/)
53
+ def scrape_contacts
54
+ unless agent.cookies.find { |c|
55
+ c.name == 'GAUSR' && c.value.match(/mail(.*?):#{options[:username]}/)
56
56
  }
57
- raise( Graybook::BadCredentialsError, "Must be authenticated to access contacts." )
57
+ return Problem.new("Username and password were not accepted. Please check them and try again.")
58
58
  end
59
-
59
+
60
60
  page = agent.get('http://mail.google.com/mail/h/?v=cl&pnl=a')
61
61
  title = page.search("//title").inner_text
62
62
  if title == 'Redirecting'
@@ -64,22 +64,22 @@ class Graybook::Importer::Gmail < Graybook::Importer::PageScraper
64
64
  url = redirect_text.match(/url='(http.*)'/i)[1]
65
65
  page = agent.get(url)
66
66
  end
67
-
67
+
68
68
  contact_rows = page.search("//input[@name='c']/../..")
69
69
  contact_rows.collect do |row|
70
70
  columns = row/"td"
71
71
  email = columns[2].inner_html.gsub( /(\n|&nbsp;)/, '' ) # email
72
- clean_email = email[/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/]
73
-
72
+ clean_email = email[/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/]
73
+
74
74
  unless clean_email.empty?
75
75
  columns = row/"td"
76
- {
76
+ {
77
77
  :name => ( columns[1] / "b" / "a" ).inner_html.strip, # name
78
78
  :email => clean_email
79
- }
79
+ }
80
80
  end
81
81
  end.compact
82
82
  end
83
-
83
+
84
84
  Graybook.register(:gmail, self)
85
85
  end
@@ -51,8 +51,7 @@ class Graybook::Importer::Hotmail < Graybook::Importer::PageScraper
51
51
  # Check for login success
52
52
  if page.body =~ /The e-mail address or password is incorrect/ ||
53
53
  page.body =~ /Sign in failed\./
54
- raise( Graybook::BadCredentialsError,
55
- "That username and password was not accepted. Please check them and try again." )
54
+ return Problem.new("Username and password were not accepted. Please check them and try again.")
56
55
  end
57
56
 
58
57
  @first_page = agent.get( page.body.scan(/http\:\/\/[^"]+/).first )
@@ -68,12 +67,11 @@ class Graybook::Importer::Hotmail < Graybook::Importer::PageScraper
68
67
  ##
69
68
  # Scrape contacts for Hotmail
70
69
  # Seems like a POST to directly fetch CSV contacts from options.aspx?subsection=26&n=
71
- # raises an end of file error in Net::HTTP via Mechanize.
72
70
  # Seems like Hotmail addresses are now hosted on Windows Live.
73
71
 
74
72
  def scrape_contacts
75
73
  unless agent.cookies.find{|c| c.name == 'MSPPre' && c.value == options[:username]}
76
- raise( Graybook::BadCredentialsError, "Must be authenticated to access contacts." )
74
+ return Problem.new("Username and password were not accepted. Please check them and try again.")
77
75
  end
78
76
 
79
77
  page = agent.get('http://mail.live.com/')
@@ -60,8 +60,10 @@ class Graybook::Importer::PageScraper < Graybook::Importer::Base
60
60
 
61
61
  def fetch_contacts!
62
62
  create_agent
63
- prepare
64
- scrape_contacts
63
+ prep = prepare
64
+ return prep if prep.nil?
65
+ cont = scrape_contacts
66
+ return cont if cont.nil?
65
67
  end
66
68
 
67
69
  ##
@@ -12,7 +12,7 @@ class Graybook::Importer::Yahoo < Graybook::Importer::PageScraper
12
12
  def =~(options = {})
13
13
  options && options[:username] =~ /@yahoo.co(m|\.uk)$/i ? true : false
14
14
  end
15
-
15
+
16
16
  ##
17
17
  # login for Yahoo!
18
18
 
@@ -22,42 +22,42 @@ class Graybook::Importer::Yahoo < Graybook::Importer::PageScraper
22
22
  form.login = options[:username].split("@").first
23
23
  form.passwd = options[:password]
24
24
  page = agent.submit(form, form.buttons.first)
25
-
25
+
26
26
  if page.body =~ /Invalid ID or password./ || page.body =~ /This ID is not yet taken./
27
- raise Graybook::BadCredentialsError, "That username and password was not accepted. Please check them and try again."
27
+ return Problem.new("Username and password were not accepted. Please check them and try again.")
28
28
  end
29
-
29
+
30
30
  true
31
31
  end
32
-
32
+
33
33
  ##
34
34
  # prepare the importer
35
35
 
36
36
  def prepare
37
37
  login
38
38
  end
39
-
39
+
40
40
  ##
41
41
  # scrape yahoo contacts
42
42
 
43
43
  def scrape_contacts
44
44
  page = agent.get("http://address.yahoo.com/?1=&VPC=import_export")
45
45
  if page.body =~ /To access Yahoo! Address Book\.\.\..*Sign in./m
46
- raise( Graybook::BadCredentialsError, "Must be authenticated to access contacts." )
46
+ return Problem.new("Username and password were not accepted. Please check them and try again.")
47
47
  end
48
48
  form = page.forms.last
49
49
  csv = agent.submit(form, form.buttons[2]) # third button is Yahoo-format CSV
50
-
50
+
51
51
  contact_rows = FasterCSV.parse(csv.body)
52
52
  labels = contact_rows.shift # TODO: Actually use the labels to find the indexes of the data we want
53
53
  contact_rows.collect do |row|
54
54
  next if !row[7].empty? && options[:username] =~ /^#{Regexp.escape(row[7])}/ # Don't collect self
55
55
  {
56
- :name => "#{row[0]} #{row[2]}".to_s,
57
- :email => (row[4] || "#{row[7]}@yahoo.com") # email is a field in the data, but will be blank for Yahoo users so we create their email address
58
- }
56
+ :name => "#{row[0]} #{row[2]}".to_s,
57
+ :email => (row[4] || "#{row[7]}@yahoo.com") # email is a field in the data, but will be blank for Yahoo users so we create their email address
58
+ }
59
59
  end
60
60
  end
61
-
61
+
62
62
  Graybook.register(:yahoo, self)
63
63
  end
data/lib/graybook.rb CHANGED
@@ -4,15 +4,17 @@ require 'rubygems'
4
4
 
5
5
  class Graybook
6
6
  include ::Singleton
7
- VERSION = '1.0.24'
8
-
9
- class GraybookError < ::StandardError; end
10
- class BadCredentialsError < GraybookError; end
11
- class LegacyAccount < GraybookError; end
12
-
7
+ VERSION = '1.1.0'
8
+
9
+ class Problem < Exception
10
+ def nil?
11
+ true
12
+ end
13
+ end
14
+
13
15
  attr_accessor :importers
14
16
  attr_accessor :exporters
15
-
17
+
16
18
  def self.get( *args )
17
19
  instance.get( *args )
18
20
  end
@@ -24,39 +26,36 @@ class Graybook
24
26
  when Exporter::Base
25
27
  instance.exporters[name.to_sym] = adapter
26
28
  else
27
- raise ArgumentError, "Unknown adapter"
29
+ return nil
28
30
  end
29
31
  end
30
-
31
- # Sends the vcards from the import to whatever is handling the export
32
+
32
33
  def export( importer, exporter, options )
33
34
  exporter.export importer.import( options )
34
35
  end
35
-
36
+
36
37
  # Searches registered importers for one that will handle the given options
37
38
  def find_importer( options )
38
39
  importers.each{ |key, importer| return importer if importer =~ options }
39
40
  nil
40
41
  end
41
-
42
+
42
43
  # Fetches contacts from various services or filetypes. The default is to return an array
43
44
  # of hashes - Graybook's internal format
44
- #
45
+ #
45
46
  # Handles several different calls:
46
47
  # get( :username => 'something@gmail.com', :password => 'whatever' )
47
- # get( :as => :xml, :username => 'something@gmail.com', :password => 'whatever' )
48
- # get( :csv, :file => #<File:/path/to/file.csv> )
49
48
  def get( *args )
50
49
  options = args.last.is_a?(Hash) ? args.pop : {}
51
- to_format = exporters[ options[:as] || :basic ]
50
+ to_format = exporters[:basic]
52
51
  source = (importers[args.first.to_sym] rescue nil) || find_importer(options)
53
52
 
54
- raise ArgumentError, "Unknown exporter" unless to_format
55
- raise ArgumentError, "Unknown source" unless source
56
-
53
+ return nil unless to_format
54
+ return nil unless source
55
+
57
56
  export source, to_format, options
58
57
  end
59
-
58
+
60
59
  def initialize
61
60
  self.importers = {}
62
61
  self.exporters = {}
@@ -78,6 +77,6 @@ end
78
77
  class Object
79
78
  def blank?
80
79
  respond_to?(:empty?) ? empty? : !self
81
- end
80
+ end
82
81
  end
83
82
 
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graybook
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.24
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojul
8
+ - Contentfree
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
@@ -32,112 +33,33 @@ dependencies:
32
33
  - !ruby/object:Gem::Version
33
34
  version: 0.7.0
34
35
  version:
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.5.0
44
- version:
45
- - !ruby/object:Gem::Dependency
46
- name: fastercsv
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 1.2.0
54
- version:
55
- description: It does things. Like import contacts from EVERYWHERE.
36
+ description: Graybook is used to import email contact lists from popular webmail sites. Currently supported are AOL/AIM, Yahoo, Hotmail/Live/MSN, and Google Mail (although not Google Apps Mail yet).
56
37
  email: kojul@kojul.com
57
38
  executables: []
58
39
 
59
40
  extensions: []
60
41
 
61
42
  extra_rdoc_files:
62
- - README.md
43
+ - README
63
44
  files:
64
45
  - .gitignore
65
- - CHANGES.md
46
+ - CHANGELOG
66
47
  - Manifest.txt
67
- - README.md
48
+ - README
68
49
  - Rakefile
69
50
  - VERSION
70
51
  - VERSION.yml
71
52
  - VERSION_NAME
72
- - debug_graybook.rb
73
53
  - init.rb
74
54
  - lib/graybook.rb
75
55
  - lib/graybook/exporter/base.rb
76
- - lib/graybook/exporter/vcf.rb
77
- - lib/graybook/exporter/xml.rb
78
56
  - lib/graybook/importer/aol.rb
79
57
  - lib/graybook/importer/base.rb
80
- - lib/graybook/importer/csv.rb
81
- - lib/graybook/importer/freenet.rb
82
58
  - lib/graybook/importer/gmail.rb
83
- - lib/graybook/importer/gmx.rb
84
59
  - lib/graybook/importer/hotmail.rb
85
60
  - lib/graybook/importer/page_scraper.rb
86
- - lib/graybook/importer/web.de.rb
87
61
  - lib/graybook/importer/yahoo.rb
88
- - test/config/credentials.yml.example
89
- - test/fixtures/aol_application_page.html
90
- - test/fixtures/aol_bad_login_response_stage_3.html
91
- - test/fixtures/aol_contacts.html
92
- - test/fixtures/aol_login_response_stage_1.html
93
- - test/fixtures/aol_login_response_stage_2.html
94
- - test/fixtures/aol_login_response_stage_3.html
95
- - test/fixtures/aol_login_response_stage_4.html
96
- - test/fixtures/aol_login_response_stage_5.html
97
- - test/fixtures/aol_new_contacts.html
98
- - test/fixtures/gmail.csv
99
- - test/fixtures/gmail_bad_login_response_stage_2.html
100
- - test/fixtures/gmail_contacts.html
101
- - test/fixtures/gmail_login_response_stage_1.html
102
- - test/fixtures/gmail_login_response_stage_2.html
103
- - test/fixtures/gmail_login_response_stage_2a.html
104
- - test/fixtures/gmail_login_response_stage_3.html
105
- - test/fixtures/gmail_redirect_body.html
106
- - test/fixtures/hotmail_bad_login_response_stage_2.html
107
- - test/fixtures/hotmail_contacts.html
108
- - test/fixtures/hotmail_login_response_stage_1.html
109
- - test/fixtures/hotmail_login_response_stage_2.html
110
- - test/fixtures/hotmail_login_response_stage_3.html
111
- - test/fixtures/hotmail_scrape_first_page.html
112
- - test/fixtures/hotmail_scrape_response_stage_1.html
113
- - test/fixtures/hotmail_scrape_response_stage_2.html
114
- - test/fixtures/hotmail_scrape_response_stage_3.html
115
- - test/fixtures/yahoo_bad_login_response_stage_2.html
116
- - test/fixtures/yahoo_contacts.csv
117
- - test/fixtures/yahoo_contacts_not_logged_in.html
118
- - test/fixtures/yahoo_contacts_stage_1.html
119
- - test/fixtures/yahoo_login_response_stage_1.html
120
- - test/fixtures/yahoo_login_response_stage_2.html
121
- - test/fixtures/yahoo_no_user_response_stage_2.html
122
- - test/freenet_importer_test.rb
123
- - test/gmx_importer_test.rb
124
- - test/scripts/live_test.rb
125
- - test/test_graybook.rb
126
- - test/test_graybook_exporter_base.rb
127
- - test/test_graybook_exporter_vcf.rb
128
- - test/test_graybook_exporter_xml.rb
129
- - test/test_graybook_importer_aol.rb
130
- - test/test_graybook_importer_base.rb
131
- - test/test_graybook_importer_csv.rb
132
- - test/test_graybook_importer_gmail.rb
133
- - test/test_graybook_importer_hotmail.rb
134
- - test/test_graybook_importer_page_scraper.rb
135
- - test/test_graybook_importer_yahoo.rb
136
- - test/test_helper.rb
137
- - test/web.de_importer_test.rb
138
62
  - updater.rb
139
- - vendor/plugins/graybook/lib/autotest/discover.rb
140
- - vendor/plugins/graybook/lib/autotest/graybook.rb
141
63
  has_rdoc: true
142
64
  homepage: http://github.com/kojul/gray
143
65
  licenses: []
@@ -165,21 +87,6 @@ rubyforge_project:
165
87
  rubygems_version: 1.3.5
166
88
  signing_key:
167
89
  specification_version: 3
168
- summary: It does things. Like import contacts from EVERYWHERE.
169
- test_files:
170
- - test/freenet_importer_test.rb
171
- - test/gmx_importer_test.rb
172
- - test/scripts/live_test.rb
173
- - test/test_graybook.rb
174
- - test/test_graybook_exporter_base.rb
175
- - test/test_graybook_exporter_vcf.rb
176
- - test/test_graybook_exporter_xml.rb
177
- - test/test_graybook_importer_aol.rb
178
- - test/test_graybook_importer_base.rb
179
- - test/test_graybook_importer_csv.rb
180
- - test/test_graybook_importer_gmail.rb
181
- - test/test_graybook_importer_hotmail.rb
182
- - test/test_graybook_importer_page_scraper.rb
183
- - test/test_graybook_importer_yahoo.rb
184
- - test/test_helper.rb
185
- - test/web.de_importer_test.rb
90
+ summary: It does things. Like import contacts from EVERYWHERE. (Some sites may be excluded)
91
+ test_files: []
92
+