contacts 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/lib/contacts/base.rb +2 -1
  2. metadata +5 -48
  3. data/doc/classes/Contacts.html +0 -195
  4. data/doc/classes/Contacts.src/M000001.html +0 -22
  5. data/doc/classes/Contacts.src/M000002.html +0 -24
  6. data/doc/classes/Contacts/AuthenticationError.html +0 -113
  7. data/doc/classes/Contacts/Base.html +0 -214
  8. data/doc/classes/Contacts/Base.src/M000006.html +0 -21
  9. data/doc/classes/Contacts/Base.src/M000007.html +0 -19
  10. data/doc/classes/Contacts/Base.src/M000008.html +0 -18
  11. data/doc/classes/Contacts/Base.src/M000009.html +0 -31
  12. data/doc/classes/Contacts/Base.src/M000010.html +0 -29
  13. data/doc/classes/Contacts/Base.src/M000011.html +0 -18
  14. data/doc/classes/Contacts/ConnectionError.html +0 -113
  15. data/doc/classes/Contacts/ContactsError.html +0 -111
  16. data/doc/classes/Contacts/Gmail.html +0 -172
  17. data/doc/classes/Contacts/Gmail.src/M000005.html +0 -60
  18. data/doc/classes/Contacts/Hotmail.html +0 -182
  19. data/doc/classes/Contacts/Hotmail.src/M000012.html +0 -74
  20. data/doc/classes/Contacts/TypeNotFound.html +0 -113
  21. data/doc/classes/Contacts/Yahoo.html +0 -187
  22. data/doc/classes/Contacts/Yahoo.src/M000003.html +0 -41
  23. data/doc/classes/Contacts/Yahoo.src/M000004.html +0 -45
  24. data/doc/created.rid +0 -1
  25. data/doc/files/README.html +0 -168
  26. data/doc/files/lib/contacts/base_rb.html +0 -114
  27. data/doc/files/lib/contacts/gmail_rb.html +0 -108
  28. data/doc/files/lib/contacts/hotmail_rb.html +0 -101
  29. data/doc/files/lib/contacts/yahoo_rb.html +0 -108
  30. data/doc/files/lib/contacts_rb.html +0 -112
  31. data/doc/fr_class_index.html +0 -35
  32. data/doc/fr_file_index.html +0 -32
  33. data/doc/fr_method_index.html +0 -38
  34. data/doc/index.html +0 -24
  35. data/doc/rdoc-style.css +0 -208
  36. data/lib/contacts/foo.diff +0 -156
@@ -1,156 +0,0 @@
1
- Index: hotmail.rb
2
- ===================================================================
3
- --- hotmail.rb (revision 8)
4
- +++ hotmail.rb (working copy)
5
- @@ -1,13 +1,16 @@
6
- class Contacts
7
- class Hotmail < Base
8
- - URL = "http://www.hotmail.com/"
9
- - CONTACT_LIST_URL = "http://%s/cgi-bin/addresses"
10
- - COMPOSE_URL = "http://%s/cgi-bin/compose?"
11
- - PROTOCOL_ERROR = "Hotmail has changed its protocols, please upgrade this library first. If that does not work, contact lucas@rufy.com with this error"
12
- + URL = "http://www.hotmail.com/"
13
- + OLD_CONTACT_LIST_URL = "http://%s/cgi-bin/addresses"
14
- + NEW_CONTACT_LIST_URL = "http://%s/mail/GetContacts.aspx"
15
- + COMPOSE_URL = "http://%s/cgi-bin/compose?"
16
- + PROTOCOL_ERROR = "Hotmail has changed its protocols - we'll need to change something on our end. Please try back later."
17
- PWDPAD = "IfYouAreReadingThisYouHaveTooMuchFreeTime"
18
- MAX_HTTP_THREADS = 8
19
-
20
- def real_connect
21
- + @use_new_contact_url = false
22
- +
23
- data, resp, cookies, forward = get(URL)
24
- data, resp, cookies, forward = get(forward, cookies, URL)
25
-
26
- @@ -20,9 +23,9 @@
27
- data, resp, cookies, forward = post(form_url, postdata, cookies)
28
-
29
- if data.index("The e-mail address or password is incorrect")
30
- - raise AuthenticationError, "Username and password do not match"
31
- + raise AuthenticationError, "Username or password is incorrect"
32
- elsif data != ""
33
- - raise AuthenticationError, "Required field must not be blank"
34
- + raise AuthenticationError, "Username or password is incorrect"
35
- elsif cookies == ""
36
- raise ConnectionError, PROTOCOL_ERROR
37
- end
38
- @@ -41,25 +44,33 @@
39
- until forward.nil?
40
- data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward]
41
- end
42
- -
43
- +
44
- if resp.code_type != Net::HTTPOK
45
- raise ConnectionError, PROTOCOL_ERROR
46
- + elsif old_url.include?('login.live.com')
47
- + data, resp, cookies, forward, old_url = get("http://mail.live.com/mail", cookies)
48
- + data, resp, cookies, forward, old_url = get(forward, cookies)
49
- + old_url = forward
50
- + @use_new_contact_url = true
51
- end
52
-
53
- @domain = URI.parse(old_url).host
54
- @cookies = cookies
55
- +
56
- rescue AuthenticationError => m
57
- if @attempt == 1
58
- retry
59
- else
60
- raise m
61
- end
62
- +
63
- end
64
-
65
- private
66
-
67
- def contact_list_url
68
- - CONTACT_LIST_URL % @domain
69
- + return OLD_CONTACT_LIST_URL % @domain unless @use_new_contact_url
70
- + return NEW_CONTACT_LIST_URL % @domain
71
- end
72
-
73
- def follow_email(data, id, contacts_slot)
74
- @@ -82,42 +93,50 @@
75
- end
76
-
77
- def parse(data)
78
- - chunks = data.split('id="hotmail"')
79
- - prev = chunks.delete_at(0)
80
- -
81
- - queue = Queue.new
82
- - threads = []
83
- - @contacts = []
84
- - chunks.each do |chunk|
85
- - name = chunk.split('return false;">')[1].split('</a>')[0] rescue nil
86
- - email = chunk.split('return false;">')[2].split('</a>')[0] rescue nil
87
- - unless email && email != "more"
88
- - prev = chunk
89
- - next
90
- - end
91
- - next_slot = @contacts.size
92
- - @contacts[next_slot] = [name, email]
93
- - if email.match(/\.\.\.$/)
94
- - if m = prev.match(/\s+id="([A-Za-z0-9\-]+)"/)
95
- - queue.push([m[1], next_slot])
96
- - if threads.size < MAX_HTTP_THREADS
97
- - threads.push(Thread.new {
98
- - while x = queue.pop
99
- - follow_email(data, *x)
100
- - end
101
- - })
102
- + unless @use_new_contact_url
103
- + chunks = data.split('id="hotmail"')
104
- + prev = chunks.delete_at(0)
105
- +
106
- + queue = Queue.new
107
- + threads = []
108
- + @contacts = []
109
- + chunks.each do |chunk|
110
- + name = chunk.split('return false;">')[1].split('</a>')[0] rescue nil
111
- + email = chunk.split('return false;">')[2].split('</a>')[0] rescue nil
112
- + unless email && email != "more"
113
- + prev = chunk
114
- + next
115
- + end
116
- + next_slot = @contacts.size
117
- + @contacts[next_slot] = [name, email]
118
- + if email.match(/\.\.\.$/)
119
- + if m = prev.match(/\s+id="([A-Za-z0-9\-]+)"/)
120
- + queue.push([m[1], next_slot])
121
- + if threads.size < MAX_HTTP_THREADS
122
- + threads.push(Thread.new {
123
- + while x = queue.pop
124
- + follow_email(data, *x)
125
- + end
126
- + })
127
- + end
128
- end
129
- end
130
- + prev = chunk
131
- end
132
- - prev = chunk
133
- +
134
- + threads.each { queue.push(nil) }
135
- + threads.each { |t| t.join }
136
- + @contacts
137
- + else
138
- + data = CSV.parse(data)
139
- + col_names = data.shift
140
- + @contacts = data.map do |person|
141
- + [[person[1], person[2], person[3]].delete_if{|i|i.nil?}.join(" "), person[46]] unless person[46].nil?
142
- + end.compact
143
- end
144
- -
145
- - threads.each { queue.push(nil) }
146
- - threads.each { |t| t.join }
147
- - @contacts
148
- end
149
- -
150
- end
151
-
152
- TYPES[:hotmail] = Hotmail
153
- -end
154
-
155
- +end
156
- +