google-api-omniauth 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ == 0.1.0
2
+
3
+ * initial release
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # OmniAuth Google
2
+
3
+ <dl>
4
+ <dt>Homepage</dt><dd><a href="http://code.google.com/p/omniauth-google/">http://code.google.com/p/omniauth-google/</a></dd>
5
+ <dt>Author</dt><dd><a href="mailto:bobaman@google.com">Bob Aman</a></dd>
6
+ <dt>Copyright</dt><dd>Copyright © 2011 Google, Inc.</dd>
7
+ <dt>License</dt><dd>Apache 2.0</dd>
8
+ </dl>
9
+
10
+ # Description
11
+
12
+ An OmniAuth strategy for Google.
13
+
14
+ # Install
15
+
16
+ * sudo gem install google-api-omniauth
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
2
+ $:.unshift(lib_dir)
3
+ $:.uniq!
4
+
5
+ require 'rubygems'
6
+ require 'rake'
7
+
8
+ gem 'rspec', '~> 1.2.9'
9
+ begin
10
+ require 'spec/rake/spectask'
11
+ rescue LoadError
12
+ STDERR.puts 'Please install rspec:'
13
+ STDERR.puts 'sudo gem install rspec'
14
+ exit(1)
15
+ end
16
+
17
+ require File.join(File.dirname(__FILE__), 'lib/omniauth/google', 'version')
18
+
19
+ PKG_DISPLAY_NAME = 'OmniAuth Google'
20
+ PKG_NAME = 'google-api-omniauth'
21
+ PKG_VERSION = OmniAuth::Google::VERSION::STRING
22
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
23
+
24
+ RELEASE_NAME = "REL #{PKG_VERSION}"
25
+
26
+ PKG_AUTHOR = 'Bob Aman'
27
+ PKG_AUTHOR_EMAIL = 'bob@sporkmonger.com'
28
+ PKG_HOMEPAGE = 'http://code.google.com/p/omniauth-google/'
29
+ PKG_SUMMARY = 'An OmniAuth strategy for Google.'
30
+ PKG_DESCRIPTION = <<-TEXT
31
+ An OmniAuth strategy for Google.
32
+ TEXT
33
+
34
+ PKG_FILES = FileList[
35
+ 'lib/**/*', 'spec/**/*', 'vendor/**/*',
36
+ 'tasks/**/*', 'website/**/*',
37
+ '[A-Z]*', 'Rakefile'
38
+ ].exclude(/database\.yml/).exclude(/[_\.]git$/)
39
+
40
+ RCOV_ENABLED = (RUBY_PLATFORM != 'java' && RUBY_VERSION =~ /^1\.8/)
41
+ if RCOV_ENABLED
42
+ task :default => 'spec:verify'
43
+ else
44
+ task :default => 'spec'
45
+ end
46
+
47
+ WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
48
+ SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
49
+
50
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,16 @@
1
+ # Copyright 2011 Google, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require 'omniauth/google'
@@ -0,0 +1,17 @@
1
+ # Copyright 2011 Google, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require 'omniauth/google/version'
17
+ require 'omniauth/strategies/google'
@@ -0,0 +1,29 @@
1
+ # Copyright 2011 Google, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ # Used to prevent the class/module from being loaded more than once
17
+ unless defined? ::OmniAuth::Google::VERSION
18
+ module OmniAuth
19
+ module Google
20
+ module VERSION
21
+ MAJOR = 0
22
+ MINOR = 1
23
+ TINY = 0
24
+
25
+ STRING = [MAJOR, MINOR, TINY].join('.')
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,173 @@
1
+ require 'google/api_client'
2
+ require 'signet/oauth_2/client'
3
+ require 'multi_json'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ ##
8
+ # Authentication strategy for connecting with Google
9
+ class Google
10
+ include OmniAuth::Strategy
11
+
12
+ PLUS_PROFILE_SCOPE = 'https://www.googleapis.com/auth/plus.me'
13
+ USERINFO_SCOPE = 'https://www.googleapis.com/auth/userinfo.profile'
14
+ DEFAULT_SCOPE = PLUS_PROFILE_SCOPE
15
+
16
+ args [:client_id, :client_secret]
17
+
18
+ option :client_options, {}
19
+ option :client_id, nil
20
+ option :client_secret, nil
21
+ option :scope, DEFAULT_SCOPE
22
+ option :refresh_token, nil
23
+ option :api_key, nil
24
+
25
+ def client
26
+ @client ||= (begin
27
+ client = ::Google::APIClient.new(options.client_options)
28
+ client.key = options.api_key
29
+ if request.ip != '127.0.0.1'
30
+ client.user_ip = request.ip
31
+ end
32
+ if client.authorization.kind_of?(::Signet::OAuth2::Client)
33
+ client.authorization.client_id = options.client_id
34
+ client.authorization.client_secret = options.client_secret
35
+ client.authorization.scope = options.scope
36
+ client.authorization.refresh_token = options.refresh_token
37
+ client.authorization.redirect_uri = redirect_uri
38
+ end
39
+ client
40
+ end)
41
+ end
42
+
43
+ def redirect_uri
44
+ full_host + script_name + callback_path
45
+ end
46
+
47
+ def profile_data
48
+ if skip_info?
49
+ raise ArgumentError,
50
+ "Profile data is not available when the :skip_info option is set."
51
+ end
52
+ @profile_data ||= (begin
53
+ if client.authorization.scope.include?(PLUS_PROFILE_SCOPE)
54
+ plus = client.discovered_api('plus', 'v1')
55
+ result = client.execute(plus.people.get, {'userId' => 'me'})
56
+ result.data
57
+ elsif client.authorization.scope.include?(USERINFO_SCOPE)
58
+ result = client.execute(
59
+ :uri => 'https://www.googleapis.com/oauth2/v1/userinfo'
60
+ )
61
+ result.data
62
+ else
63
+ raise ArgumentError,
64
+ "Profile data is not available without requesting " +
65
+ "the '#{USERINFO_SCOPE}' scope."
66
+ end
67
+ end)
68
+ end
69
+
70
+ uid do
71
+ if client.authorization.id_token
72
+ client.authorization.decoded_id_token['id']
73
+ elsif client.authorization.access_token && !skip_info? &&
74
+ (client.authorization.scope.include?(PLUS_PROFILE_SCOPE) ||
75
+ client.authorization.scope.include?(USERINFO_SCOPE))
76
+ # This is just relying on the fact that both profile formats store
77
+ # the ID in the same field.
78
+ profile_data.to_hash['id']
79
+ elsif skip_info?
80
+ raise ArgumentError,
81
+ "ID token was missing and the :skip_info option was set, " +
82
+ "preventing the use of an automatic API call fallback."
83
+ else
84
+ raise ArgumentError,
85
+ "User ID is not available without requesting " +
86
+ "the '#{USERINFO_SCOPE}' scope."
87
+ end
88
+ end
89
+
90
+ info do
91
+ prune!(profile_data.to_hash)
92
+ end
93
+
94
+ credentials do
95
+ hash = {'access_token' => client.authorization.access_token}
96
+ if client.authorization.refresh_token
97
+ hash.merge!('refresh_token' => client.authorization.refresh_token)
98
+ end
99
+ if client.authorization.id_token
100
+ hash.merge!('id_token' => client.authorization.id_token)
101
+ # TODO(bobaman): This should maybe attempt to verify the ID token.
102
+ hash.merge!(
103
+ 'decoded_id_token' => client.authorization.decoded_id_token
104
+ )
105
+ end
106
+ # Token expiration data should not be relied upon. Only the
107
+ # error for invalid_credentials can be trusted.
108
+ if client.authorization.expires_in
109
+ hash.merge!('expires_in' => client.authorization.expires_in)
110
+ end
111
+ if client.authorization.issued_at
112
+ hash.merge!('issued_at' => client.authorization.issued_at)
113
+ end
114
+ prune!(hash)
115
+ end
116
+
117
+ extra do
118
+ prune!({
119
+ 'profile' => (!skip_info? ? profile_data : nil),
120
+ 'client' => client
121
+ })
122
+ end
123
+
124
+ def request_phase
125
+ redirect client.authorization.authorization_uri.to_s
126
+ end
127
+
128
+ def callback_phase
129
+ if request.params['error'] || request.params['error_reason']
130
+ raise CallbackError.new(
131
+ request.params['error'],
132
+ request.params['error_description'] ||
133
+ request.params['error_reason'],
134
+ request.params['error_uri']
135
+ )
136
+ end
137
+ if request.params['code']
138
+ client.authorization.code = request.params['code']
139
+ end
140
+ client.authorization.fetch_access_token!
141
+ super
142
+ rescue ::Signet::UnsafeOperationError => e
143
+ fail!(:unsafe_operation, e)
144
+ rescue ::Signet::AuthorizationError, CallbackError => e
145
+ fail!(:invalid_credentials, e)
146
+ rescue ::MultiJson::DecodeError, ::Signet::ParseError => e
147
+ fail!(:invalid_response, e)
148
+ rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
149
+ fail!(:timeout, e)
150
+ end
151
+
152
+ protected
153
+ # An error that is indicated in the OAuth 2.0 callback.
154
+ # This could be a `redirect_uri_mismatch` or other
155
+ class CallbackError < StandardError
156
+ attr_accessor :error, :error_reason, :error_uri
157
+
158
+ def initialize(error, error_reason=nil, error_uri=nil)
159
+ self.error = error
160
+ self.error_reason = error_reason
161
+ self.error_uri = error_uri
162
+ end
163
+ end
164
+ private
165
+ def prune!(hash)
166
+ hash.delete_if do |_, value|
167
+ prune!(value) if value.is_a?(Hash)
168
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format specdoc
@@ -0,0 +1,7 @@
1
+ spec_dir = File.expand_path(File.dirname(__FILE__))
2
+ lib_dir = File.expand_path(File.join(spec_dir, '../lib'))
3
+
4
+ $:.unshift(lib_dir)
5
+ $:.uniq!
6
+
7
+ require 'google-api-omniauth'
@@ -0,0 +1,2 @@
1
+ desc 'Remove all build products'
2
+ task 'clobber'
data/tasks/gem.rake ADDED
@@ -0,0 +1,88 @@
1
+ require 'rubygems/package_task'
2
+ require 'rake/clean'
3
+
4
+ CLOBBER.include('pkg')
5
+
6
+ namespace :gem do
7
+ GEM_SPEC = Gem::Specification.new do |s|
8
+ unless s.respond_to?(:add_development_dependency)
9
+ puts 'The gem spec requires a newer version of RubyGems.'
10
+ exit(1)
11
+ end
12
+
13
+ s.name = PKG_NAME
14
+ s.version = PKG_VERSION
15
+ s.author = PKG_AUTHOR
16
+ s.email = PKG_AUTHOR_EMAIL
17
+ s.homepage = PKG_HOMEPAGE
18
+ s.summary = PKG_SUMMARY
19
+ s.description = PKG_DESCRIPTION
20
+
21
+ s.files = PKG_FILES.to_a
22
+
23
+ s.has_rdoc = true
24
+ s.extra_rdoc_files = %w( README.md )
25
+ s.rdoc_options.concat ['--main', 'README.md']
26
+
27
+ s.add_runtime_dependency('google-api-client', '~> 0.4.0')
28
+ s.add_runtime_dependency('signet', '>= 0.3.2')
29
+
30
+ s.add_development_dependency('rake', '~> 0.8.3')
31
+ s.add_development_dependency('rspec', '~> 1.1.11')
32
+ s.add_development_dependency('launchy', '~> 0.3.2')
33
+ s.add_development_dependency('diff-lcs', '~> 1.1.2')
34
+
35
+ s.require_path = 'lib'
36
+ end
37
+
38
+ Gem::PackageTask.new(GEM_SPEC) do |p|
39
+ p.gem_spec = GEM_SPEC
40
+ p.need_tar = true
41
+ p.need_zip = true
42
+ end
43
+
44
+ desc "Generates .gemspec file"
45
+ task :gemspec do
46
+ spec_string = GEM_SPEC.to_ruby
47
+
48
+ begin
49
+ Thread.new { eval("$SAFE = 3\n#{spec_string}", binding) }.join
50
+ rescue
51
+ abort "unsafe gemspec: #{$!}"
52
+ else
53
+ File.open("#{GEM_SPEC.name}.gemspec", 'w') do |file|
54
+ file.write spec_string
55
+ end
56
+ end
57
+ end
58
+
59
+ desc 'Show information about the gem'
60
+ task :debug do
61
+ puts GEM_SPEC.to_ruby
62
+ end
63
+
64
+ desc 'Install the gem'
65
+ task :install => ['clobber', 'gem:package'] do
66
+ sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
67
+ end
68
+
69
+ desc 'Uninstall the gem'
70
+ task :uninstall do
71
+ installed_list = Gem.source_index.find_name(PKG_NAME)
72
+ if installed_list &&
73
+ (installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION))
74
+ sh(
75
+ "#{SUDO} gem uninstall --version '#{PKG_VERSION}' " +
76
+ "--ignore-dependencies --executables #{PKG_NAME}"
77
+ )
78
+ end
79
+ end
80
+
81
+ desc 'Reinstall the gem'
82
+ task :reinstall => [:uninstall, :install]
83
+ end
84
+
85
+ desc 'Alias to gem:package'
86
+ task 'gem' => 'gem:package'
87
+
88
+ task 'clobber' => ['gem:clobber_package']
data/tasks/git.rake ADDED
@@ -0,0 +1,45 @@
1
+ namespace :git do
2
+ namespace :tag do
3
+ desc 'List tags from the Git repository'
4
+ task :list do
5
+ tags = `git tag -l`
6
+ tags.gsub!("\r", '')
7
+ tags = tags.split("\n").sort {|a, b| b <=> a }
8
+ puts tags.join("\n")
9
+ end
10
+
11
+ desc 'Create a new tag in the Git repository'
12
+ task :create do
13
+ changelog = File.open('CHANGELOG.md', 'r') { |file| file.read }
14
+ puts '-' * 80
15
+ puts changelog
16
+ puts '-' * 80
17
+ puts
18
+
19
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
20
+ abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
21
+
22
+ git_status = `git status`
23
+ if git_status !~ /nothing to commit \(working directory clean\)/
24
+ abort "Working directory isn't clean."
25
+ end
26
+
27
+ tag = "#{PKG_NAME}-#{PKG_VERSION}"
28
+ msg = "Release #{PKG_NAME}-#{PKG_VERSION}"
29
+
30
+ existing_tags = `git tag -l #{PKG_NAME}-*`.split('\n')
31
+ if existing_tags.include?(tag)
32
+ warn('Tag already exists, deleting...')
33
+ unless system "git tag -d #{tag}"
34
+ abort 'Tag deletion failed.'
35
+ end
36
+ end
37
+ puts "Creating git tag '#{tag}'..."
38
+ unless system "git tag -a -m \"#{msg}\" #{tag}"
39
+ abort 'Tag creation failed.'
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ task 'gem:release' => 'git:tag:create'
@@ -0,0 +1,22 @@
1
+ namespace :metrics do
2
+ task :lines do
3
+ lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
4
+ for file_name in FileList['lib/**/*.rb']
5
+ f = File.open(file_name)
6
+ while line = f.gets
7
+ lines += 1
8
+ next if line =~ /^\s*$/
9
+ next if line =~ /^\s*#/
10
+ codelines += 1
11
+ end
12
+ puts "L: #{sprintf('%4d', lines)}, " +
13
+ "LOC #{sprintf('%4d', codelines)} | #{file_name}"
14
+ total_lines += lines
15
+ total_codelines += codelines
16
+
17
+ lines, codelines = 0, 0
18
+ end
19
+
20
+ puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
21
+ end
22
+ end
data/tasks/rdoc.rake ADDED
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+ begin
3
+ # We prefer to use the RDoc gem over the site version.
4
+ gem 'rdoc'
5
+ rescue Gem::LoadError
6
+ end unless defined?(RDoc)
7
+
8
+ require 'rdoc/task'
9
+ require 'rake/clean'
10
+
11
+ CLOBBER.include('doc', 'ri')
12
+ CLOBBER.uniq!
13
+
14
+ namespace :doc do
15
+ desc 'Generate RDoc documentation'
16
+ Rake::RDocTask.new do |rdoc|
17
+ rdoc.rdoc_dir = 'doc'
18
+ rdoc.title = "#{PKG_NAME}-#{PKG_VERSION} Documentation"
19
+ rdoc.options << '--line-numbers' << '--inline-source' <<
20
+ '--accessor' << 'cattr_accessor=object' << '--charset' << 'utf-8'
21
+ rdoc.template = "#{ENV['template']}.rb" if ENV['template']
22
+ rdoc.rdoc_files.include('README.md', 'CHANGELOG.md', 'LICENSE')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
25
+
26
+ desc 'Generate ri locally for testing'
27
+ task :ri do
28
+ sh 'rdoc --ri -o ri .'
29
+ end
30
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,71 @@
1
+ require 'spec/rake/verify_rcov'
2
+
3
+ namespace :spec do
4
+ Spec::Rake::SpecTask.new(:rcov) do |t|
5
+ t.spec_files = FileList['spec/**/*_spec.rb']
6
+ t.spec_opts = ['--color', '--format', 'specdoc']
7
+ if RCOV_ENABLED
8
+ if `which rcov`.strip == ''
9
+ STDERR.puts 'Please install rcov:'
10
+ STDERR.puts 'sudo gem install relevance-rcov'
11
+ exit(1)
12
+ end
13
+ t.rcov = true
14
+ else
15
+ t.rcov = false
16
+ end
17
+ t.rcov_opts = [
18
+ '--exclude', 'spec',
19
+ '--exclude', '\\.rvm\\/gems',
20
+ '--exclude', '1\\.8\\/gems',
21
+ '--exclude', '1\\.9\\/gems',
22
+ '--exclude', '\\.rvm',
23
+ '--exclude', '\\/Library\\/Ruby'
24
+ ]
25
+ end
26
+
27
+ Spec::Rake::SpecTask.new(:normal) do |t|
28
+ t.spec_files = FileList['spec/**/*_spec.rb']
29
+ t.spec_opts = ['--color', '--format', 'specdoc']
30
+ t.rcov = false
31
+ end
32
+
33
+ if RCOV_ENABLED
34
+ RCov::VerifyTask.new(:verify) do |t|
35
+ t.threshold = 100.0
36
+ t.index_html = 'coverage/index.html'
37
+ end
38
+
39
+ task :verify => :rcov
40
+ end
41
+
42
+ desc 'Generate HTML Specdocs for all specs'
43
+ Spec::Rake::SpecTask.new(:specdoc) do |t|
44
+ specdoc_path = File.expand_path(
45
+ File.join(File.dirname(__FILE__), '../specdoc/'))
46
+ Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
47
+
48
+ output_file = File.join(specdoc_path, 'index.html')
49
+ t.spec_files = FileList['spec/**/*_spec.rb']
50
+ t.spec_opts = ['--format', "\"html:#{output_file}\"", '--diff']
51
+ t.fail_on_error = false
52
+ end
53
+
54
+ namespace :rcov do
55
+ desc 'Browse the code coverage report.'
56
+ task :browse => 'spec:rcov' do
57
+ require 'launchy'
58
+ Launchy::Browser.run('coverage/index.html')
59
+ end
60
+ end
61
+ end
62
+
63
+ if RCOV_ENABLED
64
+ desc 'Alias to spec:verify'
65
+ task 'spec' => 'spec:verify'
66
+ else
67
+ desc 'Alias to spec:normal'
68
+ task 'spec' => 'spec:normal'
69
+ end
70
+
71
+ task 'clobber' => ['spec:clobber_rcov']
data/tasks/yard.rake ADDED
@@ -0,0 +1,26 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'yard'
5
+ require 'yard/rake/yardoc_task'
6
+
7
+ namespace :doc do
8
+ desc 'Generate Yardoc documentation'
9
+ YARD::Rake::YardocTask.new do |yardoc|
10
+ yardoc.name = 'yard'
11
+ yardoc.options = ['--verbose']
12
+ yardoc.files = [
13
+ 'lib/**/*.rb', 'ext/**/*.c', 'README.md', 'CHANGELOG', 'LICENSE'
14
+ ]
15
+ end
16
+ end
17
+
18
+ task 'clobber' => ['doc:clobber_yard']
19
+
20
+ desc 'Alias to doc:yard'
21
+ task 'doc' => 'doc:yard'
22
+ rescue LoadError
23
+ # If yard isn't available, it's not the end of the world
24
+ desc 'Alias to doc:rdoc'
25
+ task 'doc' => 'doc:rdoc'
26
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google-api-omniauth
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Bob Aman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-02-10 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: google-api-client
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: signet
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.3.2
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.3
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.1.11
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: launchy
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.3.2
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: diff-lcs
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.1.2
79
+ type: :development
80
+ version_requirements: *id006
81
+ description: |
82
+ An OmniAuth strategy for Google.
83
+
84
+ email: bob@sporkmonger.com
85
+ executables: []
86
+
87
+ extensions: []
88
+
89
+ extra_rdoc_files:
90
+ - README.md
91
+ files:
92
+ - lib/google/omniauth.rb
93
+ - lib/omniauth/google/version.rb
94
+ - lib/omniauth/google.rb
95
+ - lib/omniauth/strategies/google.rb
96
+ - spec/spec.opts
97
+ - spec/spec_helper.rb
98
+ - tasks/clobber.rake
99
+ - tasks/gem.rake
100
+ - tasks/git.rake
101
+ - tasks/metrics.rake
102
+ - tasks/rdoc.rake
103
+ - tasks/spec.rake
104
+ - tasks/yard.rake
105
+ - CHANGELOG.md
106
+ - LICENSE
107
+ - Rakefile
108
+ - README.md
109
+ homepage: http://code.google.com/p/omniauth-google/
110
+ licenses: []
111
+
112
+ post_install_message:
113
+ rdoc_options:
114
+ - --main
115
+ - README.md
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: "0"
130
+ requirements: []
131
+
132
+ rubyforge_project:
133
+ rubygems_version: 1.8.15
134
+ signing_key:
135
+ specification_version: 3
136
+ summary: An OmniAuth strategy for Google.
137
+ test_files: []
138
+