reach 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Manifest +4 -0
  2. data/README.rdoc +26 -0
  3. data/Rakefile +14 -0
  4. data/lib/reach.rb +65 -0
  5. data/reach.gemspec +30 -0
  6. metadata +65 -0
@@ -0,0 +1,4 @@
1
+ README.rdoc
2
+ Rakefile
3
+ lib/reach.rb
4
+ Manifest
@@ -0,0 +1,26 @@
1
+ = Reach
2
+
3
+ Ruby gem for easily importing address book contacts.
4
+
5
+ == Install
6
+
7
+ gem install reach
8
+
9
+ == Usage
10
+
11
+ contacts = Reach.get_gmail_contacts('nick@whitepaperclip.com', 'password')
12
+
13
+ == Copyright
14
+
15
+ Copyright (c) 2009, Nick Kezhaya ("Author")
16
+ All rights reserved.
17
+
18
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
19
+
20
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
21
+
22
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
23
+
24
+ * Neither the name of the Author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
25
+
26
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('reach', '0.1.0') do |p|
6
+ p.description = "Get address book contacts with an email and password."
7
+ p.url = "http://github.com/nkezhaya/reach"
8
+ p.author = "Nick Kezhaya"
9
+ p.email = "nick@whitepaperclip.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,65 @@
1
+ require 'rubygems'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'hpricot'
5
+
6
+ module Reach
7
+ VALID_EMAIL = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
8
+
9
+ def Reach.get_gmail_contacts(email, password)
10
+ return false if not email =~ VALID_EMAIL
11
+
12
+ url = 'www.google.com'
13
+ path = '/accounts/ClientLogin'
14
+
15
+ data = "accountType=HOSTED_OR_GOOGLE&Email=#{email}&Passwd=#{password}" +
16
+ "&service=cp&source=WhitePaperClip-Reach-1"
17
+ headers = {
18
+ 'Content-Type' => 'application/x-www-form-urlencoded'
19
+ }
20
+
21
+ http = Net::HTTP.new(url, 443)
22
+ http.use_ssl = true
23
+ resp = http.post(path, data, headers)
24
+
25
+ auth_token = resp.body.gsub(/.*\n.*\nAuth=(.*)/, '\1')
26
+ headers = { 'Authorization' => "GoogleLogin auth=#{auth_token}" }
27
+
28
+ path = "http://www.google.com/m8/feeds/contacts/#{email}/full?max-results=99999"
29
+
30
+ http = Net::HTTP.new(url, 80)
31
+ res = http.get(path, headers, nil)
32
+
33
+ results = []
34
+ counter = 0
35
+ doc = Hpricot::XML(res.body)
36
+ doc.search("entry").each do |entry|
37
+ results[counter] = [ entry.search("title").inner_html ]
38
+
39
+ entry.search("gd:email[@address]").each do |email|
40
+ results[counter] << email.attributes['address']
41
+ end
42
+
43
+ counter += 1
44
+ end
45
+
46
+ return results
47
+ end
48
+ =begin
49
+ def Reach.get_hotmail_contacts(email, password)
50
+ return false if not email =~ VALID_EMAIL
51
+
52
+
53
+ end
54
+
55
+ def Reach.get_yahoo_contacts(email, password)
56
+ return false if not email =~ VALID_EMAIL
57
+
58
+ end
59
+
60
+ def Reach.get_aol_contacts(email, password)
61
+ return false if not email =~ VALID_EMAIL
62
+
63
+ end
64
+ =end
65
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{reach}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Nick Kezhaya"]
9
+ s.date = %q{2009-11-01}
10
+ s.description = %q{Get address book contacts with an email and password.}
11
+ s.email = %q{nick@whitepaperclip.com}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/reach.rb"]
13
+ s.files = ["README.rdoc", "Rakefile", "lib/reach.rb", "Manifest", "reach.gemspec"]
14
+ s.homepage = %q{http://github.com/nkezhaya/reach}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Reach", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{reach}
18
+ s.rubygems_version = %q{1.3.5}
19
+ s.summary = %q{Get address book contacts with an email and password.}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reach
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick Kezhaya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-01 01:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Get address book contacts with an email and password.
17
+ email: nick@whitepaperclip.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - lib/reach.rb
25
+ files:
26
+ - README.rdoc
27
+ - Rakefile
28
+ - lib/reach.rb
29
+ - Manifest
30
+ - reach.gemspec
31
+ has_rdoc: true
32
+ homepage: http://github.com/nkezhaya/reach
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --line-numbers
38
+ - --inline-source
39
+ - --title
40
+ - Reach
41
+ - --main
42
+ - README.rdoc
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "1.2"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project: reach
60
+ rubygems_version: 1.3.5
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Get address book contacts with an email and password.
64
+ test_files: []
65
+