Skip to content

Commit 45c471d

Browse files
committed
🚨 Use gemfiles/*.gemfile pattern
- Different Ruby builds can load different dependencies
1 parent 84090a4 commit 45c471d

32 files changed

+684
-464
lines changed

.rubocop_gradual.lock

+177
Large diffs are not rendered by default.

.simplecov

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require "kettle/soup/cover/config"
34

45
SimpleCov.start do

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ gem "redcarpet", platform: :mri
1919
### Linting
2020
gem "rubocop-lts", "~> 12.1", ">= 12.1.1"
2121
gem "rubocop-minitest"
22+
gem "rubocop-packaging", "~> 0.5", ">= 0.5.2"
23+
gem "rubocop-rspec", "~> 3.2"
2224
gem "rubocop-sequel"
2325

2426
### ORMs

Gemfile.lock

+7-1
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,15 @@ GEM
206206
rubocop-minitest (0.36.0)
207207
rubocop (>= 1.61, < 2.0)
208208
rubocop-ast (>= 1.31.1, < 2.0)
209+
rubocop-packaging (0.5.2)
210+
rubocop (>= 1.33, < 2.0)
209211
rubocop-performance (1.22.1)
210212
rubocop (>= 1.48.1, < 2.0)
211213
rubocop-ast (>= 1.31.1, < 2.0)
212214
rubocop-rake (0.6.0)
213215
rubocop (~> 1.0)
216+
rubocop-rspec (3.2.0)
217+
rubocop (~> 1.61)
214218
rubocop-ruby2_4 (2.0.5)
215219
rubocop-gradual (~> 0.3, >= 0.3.1)
216220
rubocop-md (~> 1.2)
@@ -324,9 +328,11 @@ DEPENDENCIES
324328
rb-fsevent
325329
redcarpet
326330
rspec (~> 3)
327-
rspec-block_is_expected (~> 1.0)
331+
rspec-block_is_expected (~> 1.0, >= 1.0.6)
328332
rubocop-lts (~> 12.1, >= 12.1.1)
329333
rubocop-minitest
334+
rubocop-packaging (~> 0.5, >= 0.5.2)
335+
rubocop-rspec (~> 3.2)
330336
rubocop-sequel
331337
sequel (~> 5)
332338
sqlite3 (~> 1.4)

Guardfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# frozen_string_literal: true
22

3-
guard 'rspec', version: 2 do
3+
guard "rspec", version: 2 do
44
watch(%r{^spec/.+_spec\.rb$})
5-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6-
watch('spec/spec_helper.rb') { 'spec' }
5+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6+
watch("spec/spec_helper.rb") { "spec" }
77
end
88

9-
guard 'bundler' do
10-
watch('Gemfile')
9+
guard "bundler" do
10+
watch("Gemfile")
1111
watch(/^.+\.gemspec/)
1212
end

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ This gem is compatible with, as of Feb 2021, version 3:
3636
To acquire the latest release from RubyGems add the following to your `Gemfile`:
3737

3838
```ruby
39-
gem 'omniauth-identity'
39+
gem "omniauth-identity"
4040
```
4141

4242
If the git repository has new commits not yet in an official release, simply specify the repo instead:
4343

4444
```ruby
45-
gem 'omniauth-identity', git: 'https://github.com/intridea/omniauth-identity.git'
45+
gem "omniauth-identity", git: "https://github.com/intridea/omniauth-identity.git"
4646
```
4747

4848
## Usage
@@ -57,8 +57,8 @@ Rack middleware. In rails, this would be created by an initializer, such as
5757
```ruby
5858
use OmniAuth::Builder do
5959
provider :identity, #mandatory: tells OA that the Identity strategy is being used
60-
model: Identity, # optional: specifies the name of the "Identity" model. Defaults to "Identity"
61-
fields: %i[email custom1 custom2] # optional: list of custom fields that are in the model's table
60+
model: Identity, # optional: specifies the name of the "Identity" model. Defaults to "Identity"
61+
fields: %i[email custom1 custom2] # optional: list of custom fields that are in the model's table
6262
end
6363
```
6464

@@ -221,8 +221,8 @@ fails. In your OmniAuth configuration, specify any valid rack endpoint in the
221221
```ruby
222222
use OmniAuth::Builder do
223223
provider :identity,
224-
fields: [:email],
225-
on_failed_registration: UsersController.action(:new)
224+
fields: [:email],
225+
on_failed_registration: UsersController.action(:new)
226226
end
227227
```
228228

@@ -241,7 +241,7 @@ The default value is:
241241
```ruby
242242
use OmniAuth::Builder do
243243
provider :identity,
244-
locate_conditions: ->(req) { { model.auth_key => req.params['auth_key'] } }
244+
locate_conditions: ->(req) { {model.auth_key => req.params["auth_key"]} }
245245
# ...
246246
end
247247
```
@@ -270,7 +270,7 @@ option :on_login, nil # See #request_phase
270270
option :on_validation, nil # See #registration_phase
271271
option :on_registration, nil # See #registration_phase
272272
option :on_failed_registration, nil # See #registration_phase
273-
option :locate_conditions, ->(req) { { model.auth_key => req.params['auth_key'] } }
273+
option :locate_conditions, ->(req) { {model.auth_key => req.params["auth_key"]} }
274274
```
275275

276276
Please contribute some documentation if you have the gumption! The maintainer's time is limited, and sometimes the authors of PRs with new options don't update the _this_ readme. 😭

gemfiles/style.gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ gem "activerecord", ">= 6", require: false # rails 6 requires Ruby 2.5 or later
1212
# Linting
1313
gem "rubocop-lts", "~> 12.1", ">= 12.1.1"
1414
gem "rubocop-minitest"
15+
gem "rubocop-packaging", "~> 0.5", ">= 0.5.2"
16+
gem "rubocop-rspec", "~> 3.2"
1517
gem "rubocop-sequel"
1618

1719
gemspec path: "../"

lib/omniauth-identity.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# frozen_string_literal: true
22

3-
require 'omniauth-identity/version'
4-
require 'omniauth/identity'
3+
require "omniauth-identity/version"
4+
require "omniauth/identity"

lib/omniauth-identity/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module OmniAuth
44
module Identity
5-
VERSION = '3.0.9'
5+
VERSION = "3.0.9"
66
end
77
end

lib/omniauth/identity.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# frozen_string_literal: true
22

3-
require 'omniauth'
3+
require "omniauth"
44

55
module OmniAuth
66
module Strategies
7-
autoload :Identity, 'omniauth/strategies/identity'
7+
autoload :Identity, "omniauth/strategies/identity"
88
end
99

1010
module Identity
11-
autoload :Model, 'omniauth/identity/model'
12-
autoload :SecurePassword, 'omniauth/identity/secure_password'
11+
autoload :Model, "omniauth/identity/model"
12+
autoload :SecurePassword, "omniauth/identity/secure_password"
1313
module Models
14-
autoload :ActiveRecord, 'omniauth/identity/models/active_record'
15-
autoload :Mongoid, 'omniauth/identity/models/mongoid'
16-
autoload :CouchPotatoModule, 'omniauth/identity/models/couch_potato'
17-
autoload :NoBrainer, 'omniauth/identity/models/nobrainer'
18-
autoload :Sequel, 'omniauth/identity/models/sequel'
14+
autoload :ActiveRecord, "omniauth/identity/models/active_record"
15+
autoload :Mongoid, "omniauth/identity/models/mongoid"
16+
autoload :CouchPotatoModule, "omniauth/identity/models/couch_potato"
17+
autoload :NoBrainer, "omniauth/identity/models/nobrainer"
18+
autoload :Sequel, "omniauth/identity/models/sequel"
1919
end
2020
end
2121
end

lib/omniauth/identity/model.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ module Model
2424
SCHEMA_ATTRIBUTES = %w[name email nickname first_name last_name location description image phone].freeze
2525

2626
def self.included(base)
27-
base.extend ClassMethods
28-
base.extend ClassCreateApi unless base.respond_to?(:create)
27+
base.extend(ClassMethods)
28+
base.extend(ClassCreateApi) unless base.respond_to?(:create)
2929
im = base.instance_methods
30-
base.include InstanceSaveApi unless im.include?(:save)
31-
base.include InstancePersistedApi unless im.include?(:persisted?)
30+
base.include(InstanceSaveApi) unless im.include?(:save)
31+
base.include(InstancePersistedApi) unless im.include?(:persisted?)
3232
end
3333

3434
module ClassMethods
@@ -49,9 +49,9 @@ def authenticate(conditions, password)
4949
# @return [String] The method name.
5050
def auth_key(method = false)
5151
@auth_key = method.to_s unless method == false
52-
@auth_key = nil if !defined?(@auth_key) || @auth_key == ''
52+
@auth_key = nil if !defined?(@auth_key) || @auth_key == ""
5353

54-
@auth_key || 'email'
54+
@auth_key || "email"
5555
end
5656

5757
# Locate an identity given its unique login key.
@@ -121,7 +121,7 @@ def authenticate(_password)
121121
# @return [String] An identifier string unique to this identity.
122122
def uid
123123
if respond_to?(:id)
124-
return nil if id.nil?
124+
return if id.nil?
125125

126126
id.to_s
127127
else
@@ -172,8 +172,8 @@ def info
172172
SCHEMA_ATTRIBUTES.each_with_object(info) do |attribute, hash|
173173
hash[attribute] = send(attribute) if respond_to?(attribute)
174174
end
175-
info['name'] ||= [info['first_name'], info['last_name']].join(' ').strip if info['first_name'] || info['last_name']
176-
info['name'] ||= info['nickname']
175+
info["name"] ||= [info["first_name"], info["last_name"]].join(" ").strip if info["first_name"] || info["last_name"]
176+
info["name"] ||= info["nickname"]
177177
info
178178
end
179179
end

lib/omniauth/identity/models/active_record.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'active_record'
3+
require "active_record"
44

55
module OmniAuth
66
module Identity
@@ -18,11 +18,11 @@ class ActiveRecord < ::ActiveRecord::Base
1818

1919
def self.auth_key=(key)
2020
super
21-
validates_uniqueness_of key, case_sensitive: false
21+
validates_uniqueness_of(key, case_sensitive: false)
2222
end
2323

2424
def self.locate(search_hash)
25-
search_hash = search_hash.reverse_merge!('provider' => 'identity') if column_names.include?('provider')
25+
search_hash = search_hash.reverse_merge!("provider" => "identity") if column_names.include?("provider")
2626
where(search_hash).first
2727
end
2828
end

lib/omniauth/identity/models/couch_potato.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'couch_potato'
3+
require "couch_potato"
44

55
module OmniAuth
66
module Identity
@@ -13,15 +13,15 @@ module Models
1313
module CouchPotatoModule
1414
def self.included(base)
1515
base.class_eval do
16-
include ::OmniAuth::Identity::Model
17-
include ::OmniAuth::Identity::SecurePassword
16+
include(::OmniAuth::Identity::Model)
17+
include(::OmniAuth::Identity::SecurePassword)
1818

1919
# validations: true (default) incurs a dependency on ActiveModel, but CouchPotato is ActiveModel based.
20-
has_secure_password validations: false
20+
has_secure_password(validations: false)
2121

2222
def self.auth_key=(key)
2323
super
24-
validates_uniqueness_of key, case_sensitive: false
24+
validates_uniqueness_of(key, case_sensitive: false)
2525
end
2626

2727
def self.locate(search_hash)

lib/omniauth/identity/models/mongoid.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'mongoid'
3+
require "mongoid"
44

55
module OmniAuth
66
module Identity
@@ -11,15 +11,15 @@ module Models
1111
module Mongoid
1212
def self.included(base)
1313
base.class_eval do
14-
include ::OmniAuth::Identity::Model
15-
include ::OmniAuth::Identity::SecurePassword
14+
include(::OmniAuth::Identity::Model)
15+
include(::OmniAuth::Identity::SecurePassword)
1616

1717
# validations: true (default) incurs a dependency on ActiveModel, but Mongoid is ActiveModel based.
1818
has_secure_password
1919

2020
def self.auth_key=(key)
2121
super
22-
validates_uniqueness_of key, case_sensitive: false
22+
validates_uniqueness_of(key, case_sensitive: false)
2323
end
2424

2525
def self.locate(search_hash)

lib/omniauth/identity/models/nobrainer.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'nobrainer'
3+
require "nobrainer"
44

55
module OmniAuth
66
module Identity
@@ -11,15 +11,15 @@ module Models
1111
module NoBrainer
1212
def self.included(base)
1313
base.class_eval do
14-
include ::OmniAuth::Identity::Model
15-
include ::OmniAuth::Identity::SecurePassword
14+
include(::OmniAuth::Identity::Model)
15+
include(::OmniAuth::Identity::SecurePassword)
1616

1717
# validations: true (default) incurs a dependency on ActiveModel, but NoBrainer is ActiveModel based.
1818
has_secure_password
1919

2020
def self.auth_key=(key)
2121
super
22-
validates_uniqueness_of key, case_sensitive: false
22+
validates_uniqueness_of(key, case_sensitive: false)
2323
end
2424

2525
def self.locate(search_hash)

lib/omniauth/identity/models/sequel.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'sequel'
3+
require "sequel"
44

55
module OmniAuth
66
module Identity
@@ -17,17 +17,17 @@ def self.included(base)
1717
# NOTE: Using the deprecated :validations_class_methods because it defines
1818
# validates_confirmation_of, while current :validation_helpers does not.
1919
# plugin :validation_helpers
20-
plugin :validation_class_methods
20+
plugin(:validation_class_methods)
2121

22-
include ::OmniAuth::Identity::Model
23-
include ::OmniAuth::Identity::SecurePassword
22+
include(::OmniAuth::Identity::Model)
23+
include(::OmniAuth::Identity::SecurePassword)
2424

2525
# validations: true incurs a dependency on ActiveModel, so we turn it off here.
26-
has_secure_password validations: false
26+
has_secure_password(validations: false)
2727

2828
def self.auth_key=(key)
2929
super
30-
validates_uniqueness_of :key, case_sensitive: false
30+
validates_uniqueness_of(:key, case_sensitive: false)
3131
end
3232

3333
# @param arguments [any] -

0 commit comments

Comments
 (0)