liangzan-contacts 1.2.7 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +4 -0
  2. data/lib/contacts/hotmail.rb +14 -4
  3. metadata +17 -6
data/README.rdoc CHANGED
@@ -10,6 +10,10 @@ Contacts is a universal interface to grab contact list information from various
10
10
 
11
11
  $ gem install liangzan-contacts
12
12
 
13
+ or on the _Gemfile_
14
+
15
+ gem 'liangzan-contacts', '~>1.2.8', :require => 'contacts'
16
+
13
17
  == Background
14
18
 
15
19
  For a long time, the only way to get a list of contacts from your free online email accounts was with proprietary PHP scripts that would cost you $50. The act of grabbing that list is a simple matter of screen scrapping and this library gives you all the functionality you need. Thanks to the generosity of the highly popular Rails website MOG (http://mog.com) for allowing this library to be released open-source to the world. It is easy to extend this library to add new free email providers, so please contact the author if you would like to help.
@@ -1,11 +1,13 @@
1
1
  require 'csv'
2
+ require 'rubygems'
3
+ require 'nokogiri'
2
4
 
3
5
  class Contacts
4
6
  class Hotmail < Base
5
7
  URL = "https://login.live.com/login.srf?id=2"
6
- CONTACT_LIST_URL = "https://col115.mail.live.com/mail/GetContacts.aspx"
8
+ CONTACT_LIST_URL = "https://mail.live.com/mail/GetContacts.aspx"
7
9
  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"
8
- PWDPAD = ""
10
+ PWDPAD = "IfYouAreReadingThisYouHaveTooMuchFreeTime"
9
11
 
10
12
  def real_connect
11
13
 
@@ -58,9 +60,9 @@ class Contacts
58
60
  def contacts(options = {})
59
61
  if @contacts.nil? && connected?
60
62
  url = URI.parse(contact_list_url)
61
- data, resp, cookies, forward = get(CONTACT_LIST_URL, @cookies )
63
+ data, resp, cookies, forward = get(get_contact_list_url, @cookies )
62
64
 
63
- @contacts = CSV.parse(data, {:headers => true}).map do |row|
65
+ @contacts = CSV.parse(data, {:headers => true, :col_sep => data[7]}).map do |row|
64
66
  name = ""
65
67
  name = row["First Name"] if !row["First Name"].nil?
66
68
  name << " #{row["Last Name"]}" if !row["Last Name"].nil?
@@ -74,5 +76,13 @@ class Contacts
74
76
  private
75
77
 
76
78
  TYPES[:hotmail] = Hotmail
79
+
80
+ # the contacts url is dynamic
81
+ # luckily it tells us where to find it
82
+ def get_contact_list_url
83
+ data = get(CONTACT_LIST_URL, @cookies)[0]
84
+ html_doc = Nokogiri::HTML(data)
85
+ html_doc.xpath("//a")[0]["href"]
86
+ end
77
87
  end
78
88
  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.7
4
+ version: 1.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-02-21 00:00:00.000000000Z
14
+ date: 2012-02-22 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json
18
- requirement: &3513920 !ruby/object:Gem::Requirement
18
+ requirement: &12557260 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 1.6.5
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *3513920
26
+ version_requirements: *12557260
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gdata_19
29
- requirement: &3512300 !ruby/object:Gem::Requirement
29
+ requirement: &12555740 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,7 +34,18 @@ dependencies:
34
34
  version: 1.1.3
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *3512300
37
+ version_requirements: *12555740
38
+ - !ruby/object:Gem::Dependency
39
+ name: nokogiri
40
+ requirement: &12554980 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.0
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *12554980
38
49
  description: A universal interface to grab contact list information from various providers
39
50
  including Yahoo, AOL, Gmail, Hotmail, and Plaxo. Now supporting Ruby 1.9.
40
51
  email: zan@liangzan.net