freiden-contacts 0.2.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ [submodule "vendor/fakeweb"]
2
+ path = vendor/fakeweb
3
+ url = git://github.com/mislav/fakeweb.git
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ gem "httparty"
3
+ gem "hpricot"
4
+ gem "nokogiri"
5
+ gem "oauth", "~> 0.4.0"
6
+ gem "json"
7
+
8
+ group :development do
9
+ gem "rspec", "~> 2.1.0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.1"
12
+ gem "rcov", ">= 0"
13
+ gem "mocha"
14
+ gem "fakeweb"
15
+ end
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ crack (0.1.8)
5
+ diff-lcs (1.1.2)
6
+ fakeweb (1.3.0)
7
+ git (1.2.5)
8
+ hpricot (0.8.4)
9
+ hpricot (0.8.4-java)
10
+ httparty (0.7.8)
11
+ crack (= 0.1.8)
12
+ jeweler (1.5.2)
13
+ bundler (~> 1.0.0)
14
+ git (>= 1.2.5)
15
+ rake
16
+ json (1.5.3)
17
+ json (1.5.3-java)
18
+ mocha (0.9.12)
19
+ nokogiri (1.4.6)
20
+ nokogiri (1.4.6-java)
21
+ weakling (>= 0.0.3)
22
+ oauth (0.4.4)
23
+ rake (0.9.2)
24
+ rcov (0.9.9)
25
+ rcov (0.9.9-java)
26
+ rspec (2.1.0)
27
+ rspec-core (~> 2.1.0)
28
+ rspec-expectations (~> 2.1.0)
29
+ rspec-mocks (~> 2.1.0)
30
+ rspec-core (2.1.0)
31
+ rspec-expectations (2.1.0)
32
+ diff-lcs (~> 1.1.2)
33
+ rspec-mocks (2.1.0)
34
+ weakling (0.0.4-java)
35
+
36
+ PLATFORMS
37
+ java
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ bundler (~> 1.0.0)
42
+ fakeweb
43
+ hpricot
44
+ httparty
45
+ jeweler (~> 1.5.1)
46
+ json
47
+ mocha
48
+ nokogiri
49
+ oauth (~> 0.4.0)
50
+ rcov
51
+ rspec (~> 2.1.0)
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2009 Mislav Marohnić
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,111 @@
1
+ ## Contacts
2
+
3
+ Fetch users' contact lists without asking them to provide their
4
+ passwords, as painlessly as possible.
5
+
6
+ Contacts provides adapters for:
7
+
8
+ * Google
9
+ * Yahoo!
10
+ * Windows Live
11
+
12
+ ## Basic usage instructions
13
+
14
+ First, register your application with the service providers you
15
+ require. Instructions below under "Setting up your accounts".
16
+
17
+ Now, create a consumer:
18
+
19
+ consumer = Contacts::Google.new
20
+ consumer = Contacts::Yahoo.new
21
+ consumer = Contacts::WindowsLive.new
22
+ # OR by parameter:
23
+ # provider is one of :google, :yahoo, :windows_live
24
+ consumer = Contacts.new_consumer(provider)
25
+
26
+ Now, direct your user to:
27
+
28
+ consumer.authentication_url(return_url)
29
+
30
+ `return_url` is the page the user will be redirected to by the service
31
+ once authorization has been granted. You should also persist the
32
+ consumer object so you can grab the contacts once the user returns:
33
+
34
+ session[:consumer] = consumer.serialize
35
+
36
+ Now in the request handler of the return_url above:
37
+
38
+ consumer = Contacts.deserialize(session[:consumer])
39
+ if consumer.authorize(params)
40
+ @contacts = consumer.contacts
41
+ else
42
+ # handle error
43
+ end
44
+
45
+ Here, `params` is the hash of request parameters that the user returns
46
+ with. `consumer.authorize` returns true if the authorization was
47
+ successful, false otherwise.
48
+
49
+ The list of `@contacts` are `Contacts::Contact` objects which have
50
+ these attributes:
51
+
52
+ * name
53
+ * emails
54
+
55
+ ## Setting up your accounts
56
+
57
+ ### Google
58
+
59
+ Set up your projects
60
+ [here](http://code.google.com/apis/accounts/docs/RegistrationForWebAppsAuto.html).
61
+
62
+ * When redirecting to an unverified domain (e.g., localhost), the
63
+ user sees a warning when authorizing access.
64
+
65
+ What this means:
66
+
67
+ * You can use the same consumer key for development as production.
68
+
69
+ ### Yahoo
70
+
71
+ Set up your projects [here](https://developer.apps.yahoo.com/projects)
72
+
73
+ * When a project's domain is verified, you must redirect to it.
74
+ * When a project's domain is not verified, you can redirect anywhere, and the
75
+ user sees a warning when authorizing access.
76
+
77
+ What this means:
78
+
79
+ * Set up separate production and development projects.
80
+ * Verify the domain of your production project. You will only be able to
81
+ redirect to your production domain when using this key.
82
+ * Don't verify the domain of your development project. You will be able to
83
+ redirect to any domain when using this key.
84
+
85
+ ## Windows Live
86
+
87
+ Set up your projects [here](http://msdn.microsoft.com/en-us/library/cc287659.aspx).
88
+
89
+ * There is no domain verification step.
90
+ * The domain cannot be localhost, an IP address, or have a query string.
91
+ * You must redirect to the project's domain, on any port, and the URL may not
92
+ have a query string or fragment.
93
+ * You must specify a privacy policy URL.
94
+
95
+ What this means:
96
+
97
+ * Set up separate production and development projects.
98
+ * For development, use a domain like myapp.local.
99
+ * Map this domain to 127.0.0.1 in /etc/hosts or a local DNS server.
100
+ * If you want to run your app on a different domain (e.g., localhost:3000),
101
+ redirect the POST from Windows Live to a GET on the original domain. This
102
+ ensures the popup window has the same origin as the opener page, in
103
+ accordance with browser same origin policies.
104
+
105
+ ## Copyright
106
+
107
+ Copyright (c) 2010 [George Ogata](mailto:george.ogata@gmail.com) See
108
+ LICENSE for details.
109
+
110
+ Derived from [Mislav's Contacts](http://github.com/mislav/contacts),
111
+ Copyright (c) 2009 [Mislav Marohnić](mailto:mislav.marohnic@gmail.com)
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "freiden-contacts"
18
+ gem.homepage = "https://github.com/freiden/contacts"
19
+ gem.license = "MIT"
20
+ gem.summary = "Import users' contacts lists from Google, Yahoo!, and Windows Live."
21
+ gem.description = "Import users' contacts lists from Google, Yahoo!, and Windows Live fork from holinn and turing contacts gem"
22
+ gem.email = "chuck_cfd@hotmail.fr"
23
+ gem.authors = ["freiden"]
24
+ end
25
+
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "gitnetworkitis #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.6.1
@@ -0,0 +1,106 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{freiden-contacts}
8
+ s.version = "0.2.6.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["freiden"]
12
+ s.date = %q{2011-09-13}
13
+ s.description = %q{Import users' contacts lists from Google, Yahoo!, and Windows Live fork from holinn and turing contacts gem}
14
+ s.email = %q{chuck_cfd@hotmail.fr}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".gitmodules",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/contacts.rb",
28
+ "lib/contacts/consumer.rb",
29
+ "lib/contacts/google.rb",
30
+ "lib/contacts/oauth_consumer.rb",
31
+ "lib/contacts/util.rb",
32
+ "lib/contacts/version.rb",
33
+ "lib/contacts/windows_live.rb",
34
+ "lib/contacts/yahoo.rb",
35
+ # "patch-contacts.gemspec",
36
+ "spec/config/contacts.yml",
37
+ "spec/contact_spec.rb",
38
+ "spec/feeds/google-many.xml",
39
+ "spec/feeds/wl_contacts.xml",
40
+ "spec/feeds/yh_contacts.txt",
41
+ "spec/gmail/google_spec.rb",
42
+ "spec/rcov.opts",
43
+ "spec/spec.opts",
44
+ "spec/spec_helper.rb",
45
+ "spec/windows_live/windows_live_spec.rb",
46
+ "spec/yahoo/yahoo_spec.rb",
47
+ # "turing-contacts.gemspec"
48
+ "freiden-contacts.gemspec"
49
+ ]
50
+ s.homepage = %q{https://github.com/freiden/contacts}
51
+ s.licenses = ["MIT"]
52
+ s.require_paths = ["lib"]
53
+ s.rubygems_version = %q{1.3.6}
54
+ s.summary = %q{Import users' contacts lists from Google, Yahoo!, and Windows Live.}
55
+ s.test_files = [
56
+ "spec/contact_spec.rb",
57
+ "spec/gmail/google_spec.rb",
58
+ "spec/spec_helper.rb",
59
+ "spec/windows_live/windows_live_spec.rb",
60
+ "spec/yahoo/yahoo_spec.rb"
61
+ ]
62
+
63
+ if s.respond_to? :specification_version then
64
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
+ s.specification_version = 3
66
+
67
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
68
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
69
+ s.add_runtime_dependency(%q<hpricot>, [">= 0"])
70
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
71
+ s.add_runtime_dependency(%q<oauth>, ["= 0.4.4"])
72
+ s.add_runtime_dependency(%q<json>, [">= 0"])
73
+ s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
74
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
75
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
76
+ s.add_development_dependency(%q<rcov>, [">= 0"])
77
+ s.add_development_dependency(%q<mocha>, [">= 0"])
78
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
79
+ else
80
+ s.add_dependency(%q<httparty>, [">= 0"])
81
+ s.add_dependency(%q<hpricot>, [">= 0"])
82
+ s.add_dependency(%q<nokogiri>, [">= 0"])
83
+ s.add_dependency(%q<oauth>, ["= 0.4.4"])
84
+ s.add_dependency(%q<json>, [">= 0"])
85
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
86
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
87
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
88
+ s.add_dependency(%q<rcov>, [">= 0"])
89
+ s.add_dependency(%q<mocha>, [">= 0"])
90
+ s.add_dependency(%q<fakeweb>, [">= 0"])
91
+ end
92
+ else
93
+ s.add_dependency(%q<httparty>, [">= 0"])
94
+ s.add_dependency(%q<hpricot>, [">= 0"])
95
+ s.add_dependency(%q<nokogiri>, [">= 0"])
96
+ s.add_dependency(%q<oauth>, ["= 0.4.4"])
97
+ s.add_dependency(%q<json>, [">= 0"])
98
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
99
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
100
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
101
+ s.add_dependency(%q<rcov>, [">= 0"])
102
+ s.add_dependency(%q<mocha>, [">= 0"])
103
+ s.add_dependency(%q<fakeweb>, [">= 0"])
104
+ end
105
+ end
106
+
@@ -0,0 +1,86 @@
1
+ require 'uri'
2
+ require 'contacts/version'
3
+
4
+ module Contacts
5
+
6
+ Identifier = 'Ruby Contacts v' + VERSION::STRING
7
+
8
+ def self.configure(configuration)
9
+ configuration.each do |key, value|
10
+ klass =
11
+ case key.to_s
12
+ when 'google'
13
+ Google
14
+ when 'yahoo'
15
+ Yahoo
16
+ when 'windows_live'
17
+ WindowsLive
18
+ else
19
+ raise ArgumentError, "unknown consumer: #{key}"
20
+ end
21
+ klass.configure(value)
22
+ end
23
+ end
24
+
25
+ class Contact
26
+ attr_reader :name, :username, :emails
27
+
28
+ def initialize(emails, name, username = "")
29
+ @name = name
30
+ @emails = Array(emails)
31
+ @username = username
32
+ end
33
+
34
+ def email
35
+ @emails.first
36
+ end
37
+ end
38
+
39
+ def self.deserialize_consumer(name, serialized_data)
40
+ klass = consumer_class_for(name) and
41
+ klass.deserialize(serialized_data)
42
+ end
43
+
44
+ def self.new(name, *args, &block)
45
+ klass = consumer_class_for(name) and
46
+ klass.new(*args, &block)
47
+ end
48
+
49
+ def self.consumer_class_for(name)
50
+ class_name = name.to_s.gsub(/(?:\A|_)(.)/){|s| $1.upcase}
51
+ class_name.sub!(/Oauth/, 'OAuth')
52
+ class_name.sub!(/Bbauth/, 'BBAuth')
53
+ begin
54
+ klass = const_get(class_name)
55
+ rescue NameError
56
+ return nil
57
+ end
58
+ klass < Consumer ? klass : nil
59
+ end
60
+
61
+ def self.verbose?
62
+ 'irb' == $0
63
+ end
64
+
65
+ class Error < StandardError
66
+ end
67
+
68
+ class TooManyRedirects < Error
69
+ attr_reader :response, :location
70
+
71
+ MAX_REDIRECTS = 2
72
+
73
+ def initialize(response)
74
+ @response = response
75
+ @location = @response['Location']
76
+ super "exceeded maximum of #{MAX_REDIRECTS} redirects (Location: #{location})"
77
+ end
78
+ end
79
+
80
+ autoload :Util, 'contacts/util'
81
+ autoload :Consumer, 'contacts/consumer'
82
+ autoload :OAuthConsumer, 'contacts/oauth_consumer'
83
+ autoload :Google, 'contacts/google'
84
+ autoload :Yahoo, 'contacts/yahoo'
85
+ autoload :WindowsLive, 'contacts/windows_live'
86
+ end