liangzan-contacts 1.2.16 → 1.2.17

Sign up to get free protection for your applications and to get access to all the features.
data/lib/contacts.rb CHANGED
@@ -15,4 +15,4 @@ require 'web_de'
15
15
  require 'seznam'
16
16
  require 'onelt'
17
17
  require 'inbox_lt'
18
- require 'tmobile_de'
18
+ require 'tonline_de'
data/lib/contacts/aol.rb CHANGED
@@ -2,6 +2,7 @@ class Contacts
2
2
  require 'hpricot' if RUBY_VERSION < '1.9'
3
3
  require 'csv'
4
4
  class Aol < Base
5
+ DETECTED_DOMAINS = [ /aol.com/i ]
5
6
  URL = "http://www.aol.com/"
6
7
  LOGIN_URL = "https://my.screenname.aol.com/_cqr/login/login.psp"
7
8
  LOGIN_REFERER_URL = "http://webmail.aol.com/"
data/lib/contacts/base.rb CHANGED
@@ -11,6 +11,8 @@ class Contacts
11
11
  TYPES = {}
12
12
 
13
13
  class Base
14
+ DETECTED_DOMAINS = []
15
+
14
16
  def initialize(login, password, options={})
15
17
  @login = login
16
18
  @password = password
@@ -212,18 +214,36 @@ class Contacts
212
214
  end
213
215
  end
214
216
 
215
- def self.guess(login, password, options={})
217
+ def self.get_email_domain(email)
218
+ name, domain = email.split('@')
219
+ domain
220
+ end
221
+
222
+ def self.guess_importer(email, options={})
216
223
  if keys = options[:types]
217
224
  types = TYPES.select{|k, v| keys.include?(k)}
218
- end
225
+ end
219
226
  types ||= TYPES
220
227
 
221
- types.inject([]) do |a, t|
222
- begin
223
- a + t[1].new(login, password, options).contacts
224
- rescue AuthenticationError
225
- a
226
- end
227
- end.uniq
228
+ email_domain = get_email_domain(email)
229
+
230
+ types.values.find do |klass|
231
+ klass::DETECTED_DOMAINS.any? { |m| email_domain.match(m) }
232
+ end
233
+ end
234
+
235
+ def self.guess(email, password, options={})
236
+ klass = guess_importer(email, options)
237
+
238
+ return if klass.nil?
239
+
240
+ a = []
241
+
242
+ begin
243
+ a = klass.new(email, password, options).contacts
244
+ rescue AuthenticationError
245
+ end
246
+
247
+ return a
228
248
  end
229
249
  end
@@ -3,6 +3,7 @@ require 'gdata'
3
3
  class Contacts
4
4
  class Gmail < Base
5
5
 
6
+ DETECTED_DOMAINS = [ /gmail.com/i, /googlemail.com/i ]
6
7
  CONTACTS_SCOPE = 'http://www.google.com/m8/feeds/'
7
8
  CONTACTS_FEED = CONTACTS_SCOPE + 'contacts/default/full/?max-results=1000'
8
9
 
data/lib/contacts/gmx.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  class Contacts
2
2
  class Gmx < Base
3
+ DETECTED_DOMAINS = [ /gmx.de/i, /gmx.at/i, /gmx.ch/i, /gmx.net/i ]
3
4
  LOGIN_URL = "https://service.gmx.net/de/cgi/login"
4
5
  ADDRESS_BOOK_URL = "https://service.gmx.net/de/cgi/g.fcgi/addressbook/cab?cc=subnavi_adressbuch&sid="
5
6
  EXPORT_URL = "https://adressbuch.gmx.net/exportcontacts"
@@ -4,6 +4,7 @@ require 'nokogiri'
4
4
 
5
5
  class Contacts
6
6
  class Hotmail < Base
7
+ DETECTED_DOMAINS = [ /hotmail/i, /live/i, /msn/i, /chaishop/i ]
7
8
  URL = "https://login.live.com/login.srf?id=2"
8
9
  CONTACT_LIST_URL = "https://mail.live.com/mail/GetContacts.aspx"
9
10
  PROTOCOL_ERROR = "Hotmail has changed its protocols, please upgrade this library first. If that does not work, report this error at http://rubyforge.org/forum/?group_id=2693"
@@ -1,5 +1,6 @@
1
1
  class Contacts
2
2
  class InboxLt < Base
3
+ DETECTED_DOMAINS = [ /inbox\.lt/i ]
3
4
  URL = "http://www.inbox.lt/?language=lt"
4
5
  LOGIN_URL = "https://login.inbox.lt/redirect.php"
5
6
  ADDRESS_BOOK_URL = "http://mail.inbox.lt/horde/turba/?char=&sort=name&page=%d"
@@ -2,6 +2,7 @@ require 'csv'
2
2
 
3
3
  class Contacts
4
4
  class Mailru < Base
5
+ DETECTED_DOMAINS = [ /list\.ru/i, /inbox\.ru/i, /bk\.ru/i, /mail\.ru/i ]
5
6
  LOGIN_URL = "https://auth.mail.ru/cgi-bin/auth"
6
7
  ADDRESS_BOOK_URL = "http://e.mail.ru/cgi-bin/abexport/addressbook.csv"
7
8
 
@@ -1,5 +1,6 @@
1
1
  class Contacts
2
2
  class Onelt < Base
3
+ DETECTED_DOMAINS = [ /one\.lt/i ]
3
4
  LOGIN_URL = "http://w33.one.lt/logonSubsite.do?subsite=pastas"
4
5
  EMAIL_URL = "http://email.one.lt/"
5
6
  ADDRESS_BOOK_URL = "http://email.one.lt/index.html?screen=RedirectServer&pane=contacts"
@@ -1,5 +1,6 @@
1
1
  class Contacts
2
2
  class Seznam < Base
3
+ DETECTED_DOMAINS = [ /seznam\.cz/i, /email\.cz/i, /post\.cz/i, /spoluzaci\.cz/i, /stream\.cz/i, /firmy\.cz/i, ]
3
4
  LOGIN_URL = "https://login.szn.cz/loginProcess"
4
5
  ADDRESS_BOOK_URL = "http://email.seznam.cz/abookCsvExport?sessionId=&charset=utf-8&eof=windows&export=nameLast&export=nameFirst&export=nick&export=email"
5
6
 
@@ -1,8 +1,9 @@
1
1
  class Contacts
2
- class TmobileDe < Base
2
+ class TonlineDe < Base
3
+ DETECTED_DOMAINS = [ /t-mobile\.de/i, /t-online\.de/i ]
3
4
  URL = "https://email.t-online.de/V4-0-4-0/srv-bin/aaa?method=deliverLoginBox"
4
5
  ADDRESS_BOOK_URL = "https://email.t-online.de/V4-0-4-0/srv-bin/addressbook?method=exportAdressbook&p%5Bformat%5D=CSV&p%5Bliid%5D="
5
- PROTOCOL_ERROR = "t-mobile.de has changed its protocols"
6
+ PROTOCOL_ERROR = "t-online.de has changed its protocols"
6
7
 
7
8
  attr_accessor :cookies, :tid
8
9
 
@@ -74,5 +75,5 @@ class Contacts
74
75
  end
75
76
  end
76
77
 
77
- TYPES[:tmobile_de] = TmobileDe
78
+ TYPES[:tonline_de] = TonlineDe
78
79
  end
@@ -1,5 +1,6 @@
1
1
  class Contacts
2
2
  class WebDe < Base
3
+ DETECTED_DOMAINS = [ /web\.de/i ]
3
4
  LOGIN_URL = "https://uas2.uilogin.de/centrallogin-3.1/login"
4
5
  ADDRESS_BOOK_URL = "https://mm.web.de/contacts"
5
6
 
@@ -1,5 +1,6 @@
1
1
  class Contacts
2
2
  class Yahoo < Base
3
+ DETECTED_DOMAINS = [ /yahoo/i, /ymail/i, /rocketmail/i ]
3
4
  URL = "http://mail.yahoo.com/"
4
5
  LOGIN_URL = "https://login.yahoo.com/config/login"
5
6
  ADDRESS_BOOK_URL = "http://address.mail.yahoo.com/?.rand=430244936"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liangzan-contacts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.16
4
+ version: 1.2.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,11 +13,11 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-03-20 00:00:00.000000000Z
16
+ date: 2012-03-26 00:00:00.000000000Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: json
20
- requirement: &8908780 !ruby/object:Gem::Requirement
20
+ requirement: &10538000 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ~>
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: 1.6.5
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *8908780
28
+ version_requirements: *10538000
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: gdata_19
31
- requirement: &8907780 !ruby/object:Gem::Requirement
31
+ requirement: &10536780 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ~>
@@ -36,10 +36,10 @@ dependencies:
36
36
  version: 1.1.3
37
37
  type: :runtime
38
38
  prerelease: false
39
- version_requirements: *8907780
39
+ version_requirements: *10536780
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: nokogiri
42
- requirement: &8906900 !ruby/object:Gem::Requirement
42
+ requirement: &10535740 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
45
  - - ~>
@@ -47,22 +47,22 @@ dependencies:
47
47
  version: 1.5.0
48
48
  type: :runtime
49
49
  prerelease: false
50
- version_requirements: *8906900
50
+ version_requirements: *10535740
51
51
  description: A universal interface to grab contact list information from Yahoo, AOL,
52
- Gmail, Hotmail, Plaxo, GMX.net, Web.de, inbox.it, sezname.cz, tmobile.de. Now supporting
52
+ Gmail, Hotmail, Plaxo, GMX.net, Web.de, inbox.lt, seznam.cz, t-online.de. Now supporting
53
53
  Ruby 1.9.
54
54
  email: zan@liangzan.net
55
55
  executables: []
56
56
  extensions: []
57
57
  extra_rdoc_files: []
58
58
  files:
59
+ - lib/contacts/tonline_de.rb
59
60
  - lib/contacts/inbox_lt.rb
60
61
  - lib/contacts/base.rb
61
62
  - lib/contacts/web_de.rb
62
63
  - lib/contacts/gmail.rb
63
64
  - lib/contacts/plaxo.rb
64
65
  - lib/contacts/onelt.rb
65
- - lib/contacts/tmobile_de.rb
66
66
  - lib/contacts/yahoo.rb
67
67
  - lib/contacts/seznam.rb
68
68
  - lib/contacts/hotmail.rb
@@ -98,6 +98,6 @@ rubyforge_project:
98
98
  rubygems_version: 1.8.10
99
99
  signing_key:
100
100
  specification_version: 3
101
- summary: grab contacts from Yahoo, AOL, Gmail, Hotmail, Plaxo, GMX.net, Web.de, inbox.it,
102
- seznam.cz, tmobile.de
101
+ summary: grab contacts from Yahoo, AOL, Gmail, Hotmail, Plaxo, GMX.net, Web.de, inbox.lt,
102
+ seznam.cz, t-online.de
103
103
  test_files: []