erc-contacts 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b51c93fde44ce267e335a7b1bd557ee20409cce
4
+ data.tar.gz: fb52b5eb4d1ed8c0dfc9330ba9cadc447ee9221f
5
+ SHA512:
6
+ metadata.gz: 734168c1bf7e7fe005839f7354127fa18e5377b7196089a55ace2854c68aace62e2d1d734f9ba3f5adad8f7d64105a0712a6ffdf89fb30f4853061bd2ba873e7
7
+ data.tar.gz: 5a9559b9bb7e3381c687b8ff2ef510c3545dd18c0d0cbf6ae8dc0221ee862e58b68f6699b7872d5c09b296df89fa1b8355bd8af8c0affea7ce15f72b9289a062
@@ -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,13 @@
1
+ source "http://rubygems.org"
2
+ gem "httparty"
3
+ gem "hpricot"
4
+ gem "nokogiri", "~> 1.8.1"
5
+ gem "oauth", "~> 0.4.5"
6
+ gem "oj", "~> 3.0"
7
+
8
+ group :development do
9
+ gem "rspec", "~> 3.6.0"
10
+ gem "jeweler", "~> 2.3.7"
11
+ gem "mocha"
12
+ gem "fakeweb"
13
+ end
@@ -0,0 +1,96 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ builder (3.2.3)
6
+ crack (0.1.8)
7
+ descendants_tracker (0.0.4)
8
+ thread_safe (~> 0.3, >= 0.3.1)
9
+ diff-lcs (1.3)
10
+ fakeweb (1.3.0)
11
+ faraday (0.9.2)
12
+ multipart-post (>= 1.2, < 3)
13
+ git (1.3.0)
14
+ github_api (0.16.0)
15
+ addressable (~> 2.4.0)
16
+ descendants_tracker (~> 0.0.4)
17
+ faraday (~> 0.8, < 0.10)
18
+ hashie (>= 3.4)
19
+ mime-types (>= 1.16, < 3.0)
20
+ oauth2 (~> 1.0)
21
+ hashie (3.5.6)
22
+ highline (1.7.8)
23
+ hpricot (0.8.4)
24
+ hpricot (0.8.4-java)
25
+ httparty (0.7.7)
26
+ crack (= 0.1.8)
27
+ jar-dependencies (0.3.11)
28
+ jeweler (2.3.7)
29
+ builder
30
+ bundler (>= 1)
31
+ git (>= 1.2.5)
32
+ github_api (~> 0.16.0)
33
+ highline (>= 1.6.15)
34
+ nokogiri (>= 1.5.10)
35
+ psych (~> 2.2)
36
+ rake
37
+ rdoc
38
+ semver2
39
+ jwt (1.5.6)
40
+ mime-types (2.99.3)
41
+ mini_portile2 (2.3.0)
42
+ mocha (0.9.12)
43
+ multi_json (1.12.2)
44
+ multi_xml (0.6.0)
45
+ multipart-post (2.0.0)
46
+ nokogiri (1.8.1)
47
+ mini_portile2 (~> 2.3.0)
48
+ nokogiri (1.8.1-java)
49
+ oauth (0.4.5)
50
+ oauth2 (1.4.0)
51
+ faraday (>= 0.8, < 0.13)
52
+ jwt (~> 1.0)
53
+ multi_json (~> 1.3)
54
+ multi_xml (~> 0.5)
55
+ rack (>= 1.2, < 3)
56
+ oj (3.3.7)
57
+ psych (2.2.4)
58
+ psych (2.2.4-java)
59
+ jar-dependencies (>= 0.1.7)
60
+ rack (2.0.3)
61
+ rake (12.1.0)
62
+ rdoc (5.1.0)
63
+ rspec (3.6.0)
64
+ rspec-core (~> 3.6.0)
65
+ rspec-expectations (~> 3.6.0)
66
+ rspec-mocks (~> 3.6.0)
67
+ rspec-core (3.6.0)
68
+ rspec-support (~> 3.6.0)
69
+ rspec-expectations (3.6.0)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.6.0)
72
+ rspec-mocks (3.6.0)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.6.0)
75
+ rspec-support (3.6.0)
76
+ semver2 (3.4.2)
77
+ thread_safe (0.3.6)
78
+ thread_safe (0.3.6-java)
79
+
80
+ PLATFORMS
81
+ java
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ fakeweb
86
+ hpricot
87
+ httparty
88
+ jeweler (~> 2.3.7)
89
+ mocha
90
+ nokogiri (~> 1.8.1)
91
+ oauth (~> 0.4.5)
92
+ oj (~> 3.0)
93
+ rspec (~> 3.6.0)
94
+
95
+ BUNDLED WITH
96
+ 1.16.0.pre.2
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,32 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "erc-contacts"
16
+ gem.homepage = "https://github.com/kulesa/contacts"
17
+ gem.license = "MIT"
18
+ gem.summary = "Import users' contacts lists from Google, Yahoo!, and Windows Live."
19
+ gem.description = "Import users' contacts lists from Google, Yahoo!, and Windows Live."
20
+ gem.email = "kulesa@gmail.com"
21
+ gem.authors = ["Mislav Marohnic", "George Odata", "Julian Countu"]
22
+ end
23
+
24
+ Jeweler::RubygemsDotOrgTasks.new
25
+
26
+ require 'rspec/core'
27
+ require 'rspec/core/rake_task'
28
+ RSpec::Core::RakeTask.new(:spec) do |spec|
29
+ spec.pattern = FileList['spec/**/*_spec.rb']
30
+ end
31
+
32
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -0,0 +1,91 @@
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
+ # stub: erc-contacts 0.3.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "erc-contacts"
9
+ s.version = "0.3.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Mislav Marohnic", "George Odata", "Julian Countu"]
14
+ s.date = "2017-10-04"
15
+ s.description = "Import users' contacts lists from Google, Yahoo!, and Windows Live."
16
+ s.email = "kulesa@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.markdown"
20
+ ]
21
+ s.files = [
22
+ ".gitmodules",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE",
26
+ "README.markdown",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "erc-contacts.gemspec",
30
+ "lib/contacts.rb",
31
+ "lib/contacts/consumer.rb",
32
+ "lib/contacts/google.rb",
33
+ "lib/contacts/oauth_consumer.rb",
34
+ "lib/contacts/railtie.rb",
35
+ "lib/contacts/util.rb",
36
+ "lib/contacts/version.rb",
37
+ "lib/contacts/windows_live.rb",
38
+ "lib/contacts/yahoo.rb",
39
+ "pkg/kulesa-contacts-0.2.6.gem",
40
+ "spec/config/contacts.yml",
41
+ "spec/contact_spec.rb",
42
+ "spec/feeds/google-many.xml",
43
+ "spec/feeds/wl_contacts.xml",
44
+ "spec/feeds/yh_contacts.txt",
45
+ "spec/gmail/google_spec.rb",
46
+ "spec/spec_helper.rb",
47
+ "spec/windows_live/windows_live_spec.rb",
48
+ "spec/yahoo/yahoo_spec.rb"
49
+ ]
50
+ s.homepage = "https://github.com/kulesa/contacts"
51
+ s.licenses = ["MIT"]
52
+ s.rubygems_version = "2.5.1"
53
+ s.summary = "Import users' contacts lists from Google, Yahoo!, and Windows Live."
54
+
55
+ if s.respond_to? :specification_version then
56
+ s.specification_version = 4
57
+
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
60
+ s.add_runtime_dependency(%q<hpricot>, [">= 0"])
61
+ s.add_runtime_dependency(%q<nokogiri>, ["~> 1.8.1"])
62
+ s.add_runtime_dependency(%q<oauth>, ["~> 0.4.5"])
63
+ s.add_runtime_dependency(%q<oj>, ["~> 3.0"])
64
+ s.add_development_dependency(%q<rspec>, ["~> 3.6.0"])
65
+ s.add_development_dependency(%q<jeweler>, ["~> 2.3.7"])
66
+ s.add_development_dependency(%q<mocha>, [">= 0"])
67
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
68
+ else
69
+ s.add_dependency(%q<httparty>, [">= 0"])
70
+ s.add_dependency(%q<hpricot>, [">= 0"])
71
+ s.add_dependency(%q<nokogiri>, ["~> 1.8.1"])
72
+ s.add_dependency(%q<oauth>, ["~> 0.4.5"])
73
+ s.add_dependency(%q<oj>, ["~> 3.0"])
74
+ s.add_dependency(%q<rspec>, ["~> 3.6.0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 2.3.7"])
76
+ s.add_dependency(%q<mocha>, [">= 0"])
77
+ s.add_dependency(%q<fakeweb>, [">= 0"])
78
+ end
79
+ else
80
+ s.add_dependency(%q<httparty>, [">= 0"])
81
+ s.add_dependency(%q<hpricot>, [">= 0"])
82
+ s.add_dependency(%q<nokogiri>, ["~> 1.8.1"])
83
+ s.add_dependency(%q<oauth>, ["~> 0.4.5"])
84
+ s.add_dependency(%q<oj>, ["~> 3.0"])
85
+ s.add_dependency(%q<rspec>, ["~> 3.6.0"])
86
+ s.add_dependency(%q<jeweler>, ["~> 2.3.7"])
87
+ s.add_dependency(%q<mocha>, [">= 0"])
88
+ s.add_dependency(%q<fakeweb>, [">= 0"])
89
+ end
90
+ end
91
+
@@ -0,0 +1,90 @@
1
+ require 'uri'
2
+ require 'contacts/version'
3
+
4
+ if defined?(Rails)
5
+ require "contacts/railtie"
6
+ end
7
+
8
+ module Contacts
9
+
10
+ Identifier = 'Ruby Contacts v' + VERSION::STRING
11
+
12
+ def self.configure(configuration)
13
+ configuration.each do |key, value|
14
+ klass =
15
+ case key.to_s
16
+ when 'google'
17
+ Google
18
+ when 'yahoo'
19
+ Yahoo
20
+ when 'windows_live'
21
+ WindowsLive
22
+ else
23
+ raise ArgumentError, "unknown consumer: #{key}"
24
+ end
25
+ klass.configure(value)
26
+ end
27
+ end
28
+
29
+ class Contact
30
+ attr_reader :name, :username, :emails
31
+
32
+ def initialize(emails, name, username = "")
33
+ @name = name
34
+ @emails = Array(emails)
35
+ @username = username
36
+ end
37
+
38
+ def email
39
+ @emails.first
40
+ end
41
+ end
42
+
43
+ def self.deserialize_consumer(name, serialized_data)
44
+ klass = consumer_class_for(name) and
45
+ klass.deserialize(serialized_data)
46
+ end
47
+
48
+ def self.new(name, *args, &block)
49
+ klass = consumer_class_for(name) and
50
+ klass.new(*args, &block)
51
+ end
52
+
53
+ def self.consumer_class_for(name)
54
+ class_name = name.to_s.gsub(/(?:\A|_)(.)/){|s| $1.upcase}
55
+ class_name.sub!(/Oauth/, 'OAuth')
56
+ class_name.sub!(/Bbauth/, 'BBAuth')
57
+ begin
58
+ klass = const_get(class_name)
59
+ rescue NameError
60
+ return nil
61
+ end
62
+ klass < Consumer ? klass : nil
63
+ end
64
+
65
+ def self.verbose?
66
+ 'irb' == $0
67
+ end
68
+
69
+ class Error < StandardError
70
+ end
71
+
72
+ class TooManyRedirects < Error
73
+ attr_reader :response, :location
74
+
75
+ MAX_REDIRECTS = 2
76
+
77
+ def initialize(response)
78
+ @response = response
79
+ @location = @response['Location']
80
+ super "exceeded maximum of #{MAX_REDIRECTS} redirects (Location: #{location})"
81
+ end
82
+ end
83
+
84
+ autoload :Util, 'contacts/util'
85
+ autoload :Consumer, 'contacts/consumer'
86
+ autoload :OAuthConsumer, 'contacts/oauth_consumer'
87
+ autoload :Google, 'contacts/google'
88
+ autoload :Yahoo, 'contacts/yahoo'
89
+ autoload :WindowsLive, 'contacts/windows_live'
90
+ end