Skip to content

Commit

Permalink
Updated ruby 1.9 hash syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Anshul Sharma committed Feb 25, 2014
1 parent 4995d3c commit dc1b399
Show file tree
Hide file tree
Showing 98 changed files with 950 additions and 950 deletions.
4 changes: 2 additions & 2 deletions app/controllers/devise/confirmations_controller.rb
Expand Up @@ -10,7 +10,7 @@ def create
yield resource if block_given?

if successfully_sent?(resource)
respond_with({}, :location => after_resending_confirmation_instructions_path_for(resource_name))
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))

This comment has been minimized.

Copy link
@pavelvasev

pavelvasev Oct 19, 2014

This breaks Devise for Ruby 1.8.7. We have to use it. Please, revert to 1.8.7-compatible syntax, or fix your gemfile to note that this version of gem not suitable for Ruby 1.8.7. Many thanks!

This comment has been minimized.

Copy link
@seuros

seuros Oct 19, 2014

Contributor

Use an old version of devise or update your app

else
respond_with(resource)
end
Expand All @@ -25,7 +25,7 @@ def show
set_flash_message(:notice, :confirmed) if is_flashing_format?
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/devise/omniauth_callbacks_controller.rb
Expand Up @@ -2,11 +2,11 @@ class Devise::OmniauthCallbacksController < DeviseController
prepend_before_filter { request.env["devise.skip_timeout"] = true }

def passthru
render :status => 404, :text => "Not found. Authentication passthru."
render status: 404, text: "Not found. Authentication passthru."
end

def failure
set_flash_message :alert, :failure, :kind => OmniAuth::Utils.camelize(failed_strategy.name), :reason => failure_message
set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
redirect_to after_omniauth_failure_path_for(resource_name)
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/devise/passwords_controller.rb
@@ -1,7 +1,7 @@
class Devise::PasswordsController < DeviseController
prepend_before_filter :require_no_authentication
# Render the #edit only if coming from a reset password email link
append_before_filter :assert_reset_token_passed, :only => :edit
append_before_filter :assert_reset_token_passed, only: :edit

# GET /resource/password/new
def new
Expand All @@ -14,7 +14,7 @@ def create
yield resource if block_given?

if successfully_sent?(resource)
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
else
respond_with(resource)
end
Expand All @@ -36,7 +36,7 @@ def update
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message(:notice, flash_message) if is_flashing_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_resetting_password_path_for(resource)
respond_with resource, location: after_resetting_password_path_for(resource)
else
respond_with resource
end
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/devise/registrations_controller.rb
@@ -1,6 +1,6 @@
class Devise::RegistrationsController < DeviseController
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
prepend_before_filter :require_no_authentication, only: [ :new, :create, :cancel ]
prepend_before_filter :authenticate_scope!, only: [:edit, :update, :destroy]

# GET /resource/sign_up
def new
Expand All @@ -17,11 +17,11 @@ def create
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
expire_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
Expand All @@ -48,8 +48,8 @@ def update
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, :bypass => true
respond_with resource, :location => after_update_path_for(resource)
sign_in resource_name, resource, bypass: true
respond_with resource, location: after_update_path_for(resource)
else
clean_up_passwords resource
respond_with resource
Expand Down Expand Up @@ -121,7 +121,7 @@ def after_update_path_for(resource)

# Authenticates the current scope and gets the current resource from the session.
def authenticate_scope!
send(:"authenticate_#{resource_name}!", :force => true)
send(:"authenticate_#{resource_name}!", force: true)
self.resource = send(:"current_#{resource_name}")
end

Expand Down
12 changes: 6 additions & 6 deletions app/controllers/devise/sessions_controller.rb
@@ -1,7 +1,7 @@
class Devise::SessionsController < DeviseController
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
prepend_before_filter :allow_params_authentication!, :only => :create
prepend_before_filter :only => [ :create, :destroy ] { request.env["devise.skip_timeout"] = true }
prepend_before_filter :require_no_authentication, only: [ :new, :create ]
prepend_before_filter :allow_params_authentication!, only: :create
prepend_before_filter only: [ :create, :destroy ] { request.env["devise.skip_timeout"] = true }

# GET /resource/sign_in
def new
Expand All @@ -16,7 +16,7 @@ def create
set_flash_message(:notice, :signed_in) if is_flashing_format?
sign_in(resource_name, resource)
yield resource if block_given?
respond_with resource, :location => after_sign_in_path_for(resource)
respond_with resource, location: after_sign_in_path_for(resource)
end

# DELETE /resource/sign_out
Expand Down Expand Up @@ -44,10 +44,10 @@ def serialize_options(resource)
methods = resource_class.authentication_keys.dup
methods = methods.keys if methods.is_a?(Hash)
methods << :password if resource.respond_to?(:password)
{ :methods => methods, :only => [:password] }
{ methods: methods, only: [:password] }
end

def auth_options
{ :scope => resource_name, :recall => "#{controller_path}#new" }
{ scope: resource_name, recall: "#{controller_path}#new" }
end
end
4 changes: 2 additions & 2 deletions app/controllers/devise/unlocks_controller.rb
Expand Up @@ -12,7 +12,7 @@ def create
yield resource if block_given?

if successfully_sent?(resource)
respond_with({}, :location => after_sending_unlock_instructions_path_for(resource))
respond_with({}, location: after_sending_unlock_instructions_path_for(resource))
else
respond_with(resource)
end
Expand All @@ -27,7 +27,7 @@ def show
set_flash_message :notice, :unlocked if is_flashing_format?
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/devise_controller.rb
Expand Up @@ -30,7 +30,7 @@ def resource_class

# Returns a signed in resource from session (if one exists)
def signed_in_resource
warden.authenticate(:scope => resource_name)
warden.authenticate(scope: resource_name)
end

# Attempt to find the mapped route for devise based on request path
Expand Down Expand Up @@ -92,14 +92,14 @@ def resource=(new_resource)
# Helper for use in before_filters where no authentication is required.
#
# Example:
# before_filter :require_no_authentication, :only => :new
# before_filter :require_no_authentication, only: :new
def require_no_authentication
assert_is_devise_resource!
return unless is_navigational_format?
no_input = devise_mapping.no_input_strategies

authenticated = if no_input.present?
args = no_input.dup.push :scope => resource_name
args = no_input.dup.push scope: resource_name
warden.authenticate?(*args)
else
warden.authenticated?(resource_name)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/devise_helper.rb
Expand Up @@ -10,8 +10,8 @@ def devise_error_messages!

messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t("errors.messages.not_saved",
:count => resource.errors.count,
:resource => resource.class.model_name.human.downcase)
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)

html = <<-HTML
<div id="error_explanation">
Expand Down
6 changes: 3 additions & 3 deletions lib/devise.rb
Expand Up @@ -350,8 +350,8 @@ def self.add_mapping(resource, options)
# == Examples:
#
# Devise.add_module(:party_module)
# Devise.add_module(:party_module, :strategy => true, :controller => :sessions)
# Devise.add_module(:party_module, :model => 'party_module/model')
# Devise.add_module(:party_module, strategy: true, controller: :sessions)
# Devise.add_module(:party_module, model: 'party_module/model')
#
def self.add_module(module_name, options = {})
ALL << module_name
Expand Down Expand Up @@ -449,7 +449,7 @@ def self.configure_warden! #:nodoc:
warden_config.intercept_401 = false

Devise.mappings.each_value do |mapping|
warden_config.scope_defaults mapping.name, :strategies => mapping.strategies
warden_config.scope_defaults mapping.name, strategies: mapping.strategies

warden_config.serialize_into_session(mapping.name) do |record|
mapping.to.serialize_into_session(record)
Expand Down
8 changes: 4 additions & 4 deletions lib/devise/controllers/helpers.rb
Expand Up @@ -55,7 +55,7 @@ def #{mapping}_signed_in?
end
def current_#{mapping}
@current_#{mapping} ||= warden.authenticate(:scope => :#{mapping})
@current_#{mapping} ||= warden.authenticate(scope: :#{mapping})
end
def #{mapping}_session
Expand All @@ -77,7 +77,7 @@ def warden
# the controllers defined inside devise. Useful if you want to apply a before
# filter to all controllers, except the ones in devise:
#
# before_filter :my_filter, :unless => :devise_controller?
# before_filter :my_filter, unless: :devise_controller?
def devise_controller?
is_a?(::DeviseController)
end
Expand Down Expand Up @@ -121,10 +121,10 @@ def signed_in_root_path(resource_or_scope)
# root path. For a user scope, you can define the default url in
# the following way:
#
# map.user_root '/users', :controller => 'users' # creates user_root_path
# map.user_root '/users', controller: 'users' # creates user_root_path
#
# map.namespace :user do |user|
# user.root :controller => 'users' # creates user_root_path
# user.root controller: 'users' # creates user_root_path
# end
#
# If the resource root path is not defined, root_path is used. However,
Expand Down
6 changes: 3 additions & 3 deletions lib/devise/controllers/rememberable.rb
Expand Up @@ -31,11 +31,11 @@ def forget_cookie_values(resource)
end

def remember_cookie_values(resource)
options = { :httponly => true }
options = { httponly: true }
options.merge!(forget_cookie_values(resource))
options.merge!(
:value => resource.class.serialize_into_cookie(resource),
:expires => resource.remember_expires_at
value: resource.class.serialize_into_cookie(resource),
expires: resource.remember_expires_at
)
end

Expand Down
16 changes: 8 additions & 8 deletions lib/devise/controllers/sign_in_out.rb
Expand Up @@ -7,7 +7,7 @@ module SignInOut
# true if any scope is signed in. Does not run authentication hooks.
def signed_in?(scope=nil)
[ scope || Devise.mappings.keys ].flatten.any? do |_scope|
warden.authenticate?(:scope => _scope)
warden.authenticate?(scope: _scope)
end
end

Expand All @@ -23,9 +23,9 @@ def signed_in?(scope=nil)
#
# sign_in :user, @user # sign_in(scope, resource)
# sign_in @user # sign_in(resource)
# sign_in @user, :event => :authentication # sign_in(resource, options)
# sign_in @user, :store => false # sign_in(resource, options)
# sign_in @user, :bypass => true # sign_in(resource, options)
# sign_in @user, event: :authentication # sign_in(resource, options)
# sign_in @user, store: false # sign_in(resource, options)
# sign_in @user, bypass: true # sign_in(resource, options)
#
def sign_in(resource_or_scope, *args)
options = args.extract_options!
Expand All @@ -40,7 +40,7 @@ def sign_in(resource_or_scope, *args)
# Do nothing. User already signed in and we are not forcing it.
true
else
warden.set_user(resource, options.merge!(:scope => scope))
warden.set_user(resource, options.merge!(scope: scope))
end
end

Expand All @@ -56,11 +56,11 @@ def sign_in(resource_or_scope, *args)
def sign_out(resource_or_scope=nil)
return sign_out_all_scopes unless resource_or_scope
scope = Devise::Mapping.find_scope!(resource_or_scope)
user = warden.user(:scope => scope, :run_callbacks => false) # If there is no user
user = warden.user(scope: scope, run_callbacks: false) # If there is no user

warden.raw_session.inspect # Without this inspect here. The session does not clear.
warden.logout(scope)
warden.clear_strategies_cache!(:scope => scope)
warden.clear_strategies_cache!(scope: scope)
instance_variable_set(:"@current_#{scope}", nil)

!!user
Expand All @@ -70,7 +70,7 @@ def sign_out(resource_or_scope=nil)
# in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
# and false if there was no user logged in on all scopes.
def sign_out_all_scopes(lock=true)
users = Devise.mappings.keys.map { |s| warden.user(:scope => s, :run_callbacks => false) }
users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }

warden.raw_session.inspect
warden.logout
Expand Down
6 changes: 3 additions & 3 deletions lib/devise/failure_app.rb
Expand Up @@ -15,7 +15,7 @@ class FailureApp < ActionController::Metal

include Devise::Controllers::StoreLocation

delegate :flash, :to => :request
delegate :flash, to: :request

def self.call(env)
@respond ||= action(:respond)
Expand Down Expand Up @@ -151,9 +151,9 @@ def http_auth_body
return i18n_message unless request_format
method = "to_#{request_format}"
if method == "to_xml"
{ :error => i18n_message }.to_xml(:root => "errors")
{ error: i18n_message }.to_xml(root: "errors")
elsif {}.respond_to?(method)
{ :error => i18n_message }.send(method)
{ error: i18n_message }.send(method)
else
i18n_message
end
Expand Down
2 changes: 1 addition & 1 deletion lib/devise/hooks/activatable.rb
Expand Up @@ -6,6 +6,6 @@
if record && record.respond_to?(:active_for_authentication?) && !record.active_for_authentication?
scope = options[:scope]
warden.logout(scope)
throw :warden, :scope => scope, :message => record.inactive_message
throw :warden, scope: scope, message: record.inactive_message
end
end
2 changes: 1 addition & 1 deletion lib/devise/hooks/lockable.rb
@@ -1,6 +1,6 @@
# After each sign in, if resource responds to failed_attempts, sets it to 0
# This is only triggered when the user is explicitly set (with set_user)
Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
record.update_attribute(:failed_attempts, 0) unless record.failed_attempts.to_i.zero?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/devise/hooks/proxy.rb
Expand Up @@ -7,7 +7,7 @@ class Proxy #:nodoc:
include Devise::Controllers::SignInOut

attr_reader :warden
delegate :cookies, :env, :to => :warden
delegate :cookies, :env, to: :warden

def initialize(warden)
@warden = warden
Expand Down
2 changes: 1 addition & 1 deletion lib/devise/hooks/rememberable.rb
@@ -1,4 +1,4 @@
Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
scope = options[:scope]
if record.respond_to?(:remember_me) && options[:store] != false &&
record.remember_me && warden.authenticated?(scope)
Expand Down
2 changes: 1 addition & 1 deletion lib/devise/hooks/timeoutable.rb
Expand Up @@ -18,7 +18,7 @@
record.reset_authentication_token!
end

throw :warden, :scope => scope, :message => :timeout
throw :warden, scope: scope, message: :timeout
end

unless env['devise.skip_trackable']
Expand Down
2 changes: 1 addition & 1 deletion lib/devise/hooks/trackable.rb
Expand Up @@ -2,7 +2,7 @@
# This is only triggered when the user is explicitly set (with set_user)
# and on authentication. Retrieving the user from session (:fetch) does
# not trigger it.
Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
if record.respond_to?(:update_tracked_fields!) && warden.authenticated?(options[:scope]) && !warden.request.env['devise.skip_trackable']
record.update_tracked_fields!(warden.request)
end
Expand Down

0 comments on commit dc1b399

Please sign in to comment.