liangzan-contacts 1.2.12 → 1.2.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/contacts.rb +1 -0
  2. data/lib/contacts/gmx.rb +62 -0
  3. metadata +10 -9
data/lib/contacts.rb CHANGED
@@ -10,3 +10,4 @@ require 'yahoo'
10
10
  require 'plaxo'
11
11
  require 'aol'
12
12
  require 'mailru'
13
+ require 'gmx'
@@ -0,0 +1,62 @@
1
+ class Contacts
2
+ class Gmx < Base
3
+ LOGIN_URL = "https://service.gmx.net/de/cgi/login"
4
+ ADDRESS_BOOK_URL = "https://service.gmx.net/de/cgi/g.fcgi/addressbook/cab?cc=subnavi_adressbuch&sid="
5
+ EXPORT_URL = "https://adressbuch.gmx.net/exportcontacts"
6
+
7
+ attr_accessor :cookies, :sid
8
+
9
+ def real_connect
10
+
11
+ postdata = "AREA=1&EXT=redirect&EXT2=&dlevel=c&id=%s&p=%s&uinguserid=__uuid__" % [
12
+ CGI.escape(login),
13
+ CGI.escape(password)
14
+ ]
15
+
16
+ data, resp, self.cookies, forward = post(LOGIN_URL, postdata, "")
17
+
18
+ if data.index("lose/password")
19
+ raise AuthenticationError, "Username and password do not match"
20
+ elsif !forward.nil? && forward.index("login-failed")
21
+ raise AuthenticationError, "Username and password do not match"
22
+ elsif cookies == "" or data == ""
23
+ raise ConnectionError, PROTOCOL_ERROR
24
+ end
25
+
26
+ data, resp, self.cookies, forward = get(forward, self.cookies)
27
+
28
+ self.sid = data.match(/sid=([a-z0-9\.]+)/)[1]
29
+ end
30
+
31
+ def contacts
32
+ data, resp, cookies, forward = get(ADDRESS_BOOK_URL + self.sid, self.cookies)
33
+ data, resp, cookies, forward = get(forward, self.cookies)
34
+
35
+ session = forward.match(/session=([^&]+)/)[1]
36
+
37
+ postdata = "language=eng&raw_format=csv_Outlook2003&what=PERSON&session=" + session
38
+
39
+ data, resp, cookies, forward = post(EXPORT_URL, postdata, self.cookies)
40
+
41
+ @contacts = []
42
+
43
+ CSV.parse(data) do |row|
44
+ @contacts << ["#{row[2]} #{row[0]}", row[9]] unless header_row?(row)
45
+ end
46
+
47
+ @contacts
48
+ end
49
+
50
+ def skip_gzip?
51
+ false
52
+ end
53
+
54
+ private
55
+
56
+ def header_row?(row)
57
+ row[0] == 'Last Name'
58
+ end
59
+ end
60
+
61
+ TYPES[:gmx] = Gmx
62
+ end
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.12
4
+ version: 1.2.13
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-14 00:00:00.000000000Z
16
+ date: 2012-03-16 00:00:00.000000000Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: json
20
- requirement: &4670300 !ruby/object:Gem::Requirement
20
+ requirement: &14981960 !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: *4670300
28
+ version_requirements: *14981960
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: gdata_19
31
- requirement: &4669020 !ruby/object:Gem::Requirement
31
+ requirement: &14980420 !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: *4669020
39
+ version_requirements: *14980420
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: nokogiri
42
- requirement: &4667900 !ruby/object:Gem::Requirement
42
+ requirement: &14979580 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
45
  - - ~>
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: 1.5.0
48
48
  type: :runtime
49
49
  prerelease: false
50
- version_requirements: *4667900
50
+ version_requirements: *14979580
51
51
  description: A universal interface to grab contact list information from various providers
52
52
  including Yahoo, AOL, Gmail, Hotmail, and Plaxo. Now supporting Ruby 1.9.
53
53
  email: zan@liangzan.net
@@ -63,6 +63,7 @@ files:
63
63
  - lib/contacts/mailru.rb
64
64
  - lib/contacts/aol.rb
65
65
  - lib/contacts/json_picker.rb
66
+ - lib/contacts/gmx.rb
66
67
  - lib/contacts.rb
67
68
  - examples/grab_contacts.rb
68
69
  - LICENSE
@@ -91,5 +92,5 @@ rubyforge_project:
91
92
  rubygems_version: 1.8.10
92
93
  signing_key:
93
94
  specification_version: 3
94
- summary: grab contacts from Yahoo, AOL, Gmail, Hotmail, and Plaxo
95
+ summary: grab contacts from Yahoo, AOL, Gmail, Hotmail, Plaxo and GMX
95
96
  test_files: []