Skip to content

Commit

Permalink
Merge pull request discourse#547 from kid0m4n/convert-ruby-1-9-syntax
Browse files Browse the repository at this point in the history
Convert a lot of :a => b to a: b and bring peace to the world
  • Loading branch information
SamSaffron committed Mar 24, 2013
2 parents 36a0694 + 5dfb04e commit deb603f
Show file tree
Hide file tree
Showing 62 changed files with 173 additions and 173 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def block_if_maintenance_mode
def check_restricted_access
# note current_user is defined in the CurrentUser mixin
if SiteSetting.access_password.present? && cookies[:_access] != SiteSetting.access_password
redirect_to request_access_path(:return_path => request.fullpath)
redirect_to request_access_path(return_path: request.fullpath)
return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/forums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ForumsController < ApplicationController

def status
if $shutdown
render text: 'shutting down', :status => 500
render text: 'shutting down', status: 500
else
render text: 'ok'
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TopicsController < ApplicationController
before_filter :consider_user_for_promotion, only: :show

skip_before_filter :check_xhr, only: [:avatar, :show, :feed]
caches_action :avatar, :cache_path => Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" }
caches_action :avatar, cache_path: Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" }


def show
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.types
skip_before_filter :check_xhr

# must be done, cause we may trigger a POST
skip_before_filter :verify_authenticity_token, :only => :complete
skip_before_filter :verify_authenticity_token, only: :complete

def complete
# Make sure we support that provider
Expand Down Expand Up @@ -49,7 +49,7 @@ def create_or_sign_on_user_using_twitter(auth_token)
twitter_screen_name: screen_name
}

user_info = TwitterUserInfo.where(:twitter_user_id => twitter_user_id).first
user_info = TwitterUserInfo.where(twitter_user_id: twitter_user_id).first

@data = {
username: screen_name,
Expand Down Expand Up @@ -97,7 +97,7 @@ def create_or_sign_on_user_using_facebook(auth_token)
email_valid: true
}

user_info = FacebookUserInfo.where(:facebook_user_id => fb_uid ).first
user_info = FacebookUserInfo.where(facebook_user_id: fb_uid).first

@data = {
username: username,
Expand Down Expand Up @@ -194,7 +194,7 @@ def create_or_sign_on_user_using_github(auth_token)
github_screen_name: screen_name
}

user_info = GithubUserInfo.where(:github_user_id => github_user_id).first
user_info = GithubUserInfo.where(github_user_id: github_user_id).first

@data = {
username: screen_name,
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def user_preferences_redirect
end

def update
user = User.where(:username_lower => params[:username].downcase).first
user = User.where(username_lower: params[:username].downcase).first
guardian.ensure_can_edit!(user)
json_result(user) do |u|

Expand Down Expand Up @@ -179,15 +179,15 @@ def create
# Create auth records
if auth.present?
if auth[:twitter_user_id] && auth[:twitter_screen_name] && TwitterUserInfo.find_by_twitter_user_id(auth[:twitter_user_id]).nil?
TwitterUserInfo.create(:user_id => user.id, :screen_name => auth[:twitter_screen_name], :twitter_user_id => auth[:twitter_user_id])
TwitterUserInfo.create(user_id: user.id, screen_name: auth[:twitter_screen_name], twitter_user_id: auth[:twitter_user_id])
end

if auth[:facebook].present? && FacebookUserInfo.find_by_facebook_user_id(auth[:facebook][:facebook_user_id]).nil?
FacebookUserInfo.create!(auth[:facebook].merge(user_id: user.id))
end

if auth[:github_user_id] && auth[:github_screen_name] && GithubUserInfo.find_by_github_user_id(auth[:github_user_id]).nil?
GithubUserInfo.create(:user_id => user.id, :screen_name => auth[:github_screen_name], :github_user_id => auth[:github_user_id])
GithubUserInfo.create(user_id: user.id, screen_name: auth[:github_screen_name], github_user_id: auth[:github_user_id])
end
end

Expand Down Expand Up @@ -219,7 +219,7 @@ def avatar
# TEMP to catch all missing spots
# raise ActiveRecord::RecordNotFound

user = User.select(:email).where(:username_lower => params[:username].downcase).first
user = User.select(:email).where(username_lower: params[:username].downcase).first
if user
# for now we only support gravatar in square (redirect cached for a day), later we can use x-sendfile and/or a cdn to serve local
size = params[:size].to_i
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/common_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module CommonHelper
def render_google_analytics_code
if Rails.env == "production" && SiteSetting.ga_tracking_code.present?
render :partial => "common/google_analytics"
render partial: "common/google_analytics"
end
end
end
end
4 changes: 2 additions & 2 deletions app/mailers/user_notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def digest(user, opts={})
mail to: user.email,
from: "#{I18n.t('user_notifications.digest.from', site_name: SiteSetting.title)} <#{SiteSetting.notification_email}>",
subject: I18n.t('user_notifications.digest.subject_template',
:site_name => @site_name,
:date => I18n.l(Time.now, format: :short))
site_name: @site_name,
date: I18n.l(Time.now, format: :short))
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/category_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CategoryList

def initialize(current_user)
@categories = Category
.includes(:featured_topics => [:category])
.includes(featured_topics: [:category])
.includes(:featured_users)
.order('topics_week desc, topics_month desc, topics_year desc')
.to_a
Expand Down
4 changes: 2 additions & 2 deletions app/models/user_action.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class UserAction < ActiveRecord::Base
belongs_to :user
belongs_to :target_post, :class_name => "Post"
belongs_to :target_topic, :class_name => "Topic"
belongs_to :target_post, class_name: "Post"
belongs_to :target_topic, class_name: "Topic"
attr_accessible :acting_user_id, :action_type, :target_topic_id, :target_post_id, :target_user_id, :user_id

validates_presence_of :action_type
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/application_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class ApplicationSerializer < ActiveModel::Serializer
embed :ids, :include => true
embed :ids, include: true
end
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test profile)))
Bundler.require(*Rails.groups(assets: %w(development test profile)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
Expand Down
4 changes: 2 additions & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
config.handlebars.precompile = false

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
config.action_mailer.raise_delivery_errors = true

BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']
end

2 changes: 1 addition & 1 deletion config/environments/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
config.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.3.js"
config.handlebars.precompile = true

# config.middleware.use ::Rack::PerftoolsProfiler, :default_printer => 'gif'
# config.middleware.use ::Rack::PerftoolsProfiler, default_printer: 'gif'

end
2 changes: 1 addition & 1 deletion config/initializers/04-message_bus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

MessageBus.on_connect do |site_id|
RailsMultisite::ConnectionManagement.establish_connection(:db => site_id)
RailsMultisite::ConnectionManagement.establish_connection(db: site_id)
end

MessageBus.on_disconnect do |site_id|
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/mini_profiler.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# If Mini Profiler is included via gem
if defined?(Rack::MiniProfiler)

Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(:connection => DiscourseRedis.new)
Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(connection: DiscourseRedis.new)

# For our app, let's just show mini profiler always, polling is chatty so nuke that
Rack::MiniProfiler.config.pre_authorize_cb = lambda do |env|
Expand Down
20 changes: 10 additions & 10 deletions config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
Rails.application.config.middleware.use OmniAuth::Builder do

provider :open_id,
:store => OpenID::Store::Redis.new($redis),
:name => 'google',
:identifier => 'https://www.google.com/accounts/o8/id',
:require => 'omniauth-openid'
store: OpenID::Store::Redis.new($redis),
name: 'google',
identifier: 'https://www.google.com/accounts/o8/id',
require: 'omniauth-openid'

provider :open_id,
:store => OpenID::Store::Redis.new($redis),
:name => 'yahoo',
:identifier => 'https://me.yahoo.com',
:require => 'omniauth-openid'
store: OpenID::Store::Redis.new($redis),
name: 'yahoo',
identifier: 'https://me.yahoo.com',
require: 'omniauth-openid'

provider :facebook,
SiteSetting.facebook_app_id,
SiteSetting.facebook_app_secret,
:scope => "email"
scope: "email"

provider :twitter,
SiteSetting.twitter_consumer_key,
Expand All @@ -32,6 +32,6 @@
SiteSetting.github_client_secret

provider :browser_id,
:name => 'persona'
name: 'persona'

end
4 changes: 2 additions & 2 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sidekiq.configure_server do |config|
config.redis = { :url => $redis.url, :namespace => 'sidekiq' }
config.redis = { url: $redis.url, namespace: 'sidekiq' }
end

Sidekiq.configure_client do |config|
config.redis = { :url => $redis.url, :namespace => 'sidekiq' }
config.redis = { url: $redis.url, namespace: 'sidekiq' }
end
2 changes: 1 addition & 1 deletion config/initializers/silence_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def call(env)
end

silenced = ["/mini-profiler-resources/results", "/mini-profiler-resources/includes.js", "/mini-profiler-resources/includes.css", "/mini-profiler-resources/jquery.tmpl.js"]
Rails.configuration.middleware.swap Rails::Rack::Logger, SilenceLogger, :silenced => silenced
Rails.configuration.middleware.swap Rails::Rack::Logger, SilenceLogger, silenced: silenced
72 changes: 36 additions & 36 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Discourse::Application.routes.draw do

match "/404", :to => "exceptions#not_found"
match "/404", to: "exceptions#not_found"

mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new

Expand Down Expand Up @@ -63,13 +63,13 @@
post 'email/resubscribe/:key' => 'email#resubscribe', as: 'email_resubscribe'


resources :session, id: USERNAME_ROUTE_FORMAT, :only => [:create, :destroy] do
resources :session, id: USERNAME_ROUTE_FORMAT, only: [:create, :destroy] do
collection do
post 'forgot_password'
end
end

resources :users, :except => [:show, :update] do
resources :users, except: [:show, :update] do
collection do
get 'check_username'
get 'is_local_username'
Expand All @@ -90,17 +90,17 @@
get 'users/hp' => 'users#get_honeypot_value'

get 'user_preferences' => 'users#user_preferences_redirect'
get 'users/:username/private-messages' => 'user_actions#private_messages', :constraints => {:username => USERNAME_ROUTE_FORMAT}
get 'users/:username' => 'users#show', :constraints => {:username => USERNAME_ROUTE_FORMAT}
put 'users/:username' => 'users#update', :constraints => {:username => USERNAME_ROUTE_FORMAT}
get 'users/:username/preferences' => 'users#preferences', :constraints => {:username => USERNAME_ROUTE_FORMAT}, :as => :email_preferences
get 'users/:username/preferences/email' => 'users#preferences', :constraints => {:username => USERNAME_ROUTE_FORMAT}
put 'users/:username/preferences/email' => 'users#change_email', :constraints => {:username => USERNAME_ROUTE_FORMAT}
get 'users/:username/preferences/username' => 'users#preferences', :constraints => {:username => USERNAME_ROUTE_FORMAT}
put 'users/:username/preferences/username' => 'users#username', :constraints => {:username => USERNAME_ROUTE_FORMAT}
get 'users/:username/avatar(/:size)' => 'users#avatar', :constraints => {:username => USERNAME_ROUTE_FORMAT}
get 'users/:username/invited' => 'users#invited', :constraints => {:username => USERNAME_ROUTE_FORMAT}
get 'users/:username/send_activation_email' => 'users#send_activation_email', :constraints => {:username => USERNAME_ROUTE_FORMAT}
get 'users/:username/private-messages' => 'user_actions#private_messages', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username' => 'users#show', constraints: {username: USERNAME_ROUTE_FORMAT}
put 'users/:username' => 'users#update', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/preferences' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}, as: :email_preferences
get 'users/:username/preferences/email' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}
put 'users/:username/preferences/email' => 'users#change_email', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/preferences/username' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}
put 'users/:username/preferences/username' => 'users#username', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/avatar(/:size)' => 'users#avatar', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/invited' => 'users#invited', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/send_activation_email' => 'users#send_activation_email', constraints: {username: USERNAME_ROUTE_FORMAT}

resources :uploads

Expand Down Expand Up @@ -168,30 +168,30 @@
get 'topics/similar_to'

# Legacy route for old avatars
get 'threads/:topic_id/:post_number/avatar' => 'topics#avatar', :constraints => {:topic_id => /\d+/, :post_number => /\d+/}
get 'threads/:topic_id/:post_number/avatar' => 'topics#avatar', constraints: {topic_id: /\d+/, post_number: /\d+/}

# Topic routes
get 't/:slug/:topic_id/best_of' => 'topics#show', :defaults => {best_of: true}, :constraints => {:topic_id => /\d+/, :post_number => /\d+/}
get 't/:topic_id/best_of' => 'topics#show', :constraints => {:topic_id => /\d+/, :post_number => /\d+/}
put 't/:slug/:topic_id' => 'topics#update', :constraints => {:topic_id => /\d+/}
put 't/:slug/:topic_id/star' => 'topics#star', :constraints => {:topic_id => /\d+/}
put 't/:topic_id/star' => 'topics#star', :constraints => {:topic_id => /\d+/}
put 't/:slug/:topic_id/status' => 'topics#status', :constraints => {:topic_id => /\d+/}
put 't/:topic_id/status' => 'topics#status', :constraints => {:topic_id => /\d+/}
put 't/:topic_id/clear-pin' => 'topics#clear_pin', :constraints => {:topic_id => /\d+/}
put 't/:topic_id/mute' => 'topics#mute', :constraints => {:topic_id => /\d+/}
put 't/:topic_id/unmute' => 'topics#unmute', :constraints => {:topic_id => /\d+/}

get 't/:topic_id/:post_number' => 'topics#show', :constraints => {:topic_id => /\d+/, :post_number => /\d+/}
get 't/:slug/:topic_id.rss' => 'topics#feed', :format => :rss, :constraints => {:topic_id => /\d+/}
get 't/:slug/:topic_id' => 'topics#show', :constraints => {:topic_id => /\d+/}
get 't/:slug/:topic_id/:post_number' => 'topics#show', :constraints => {:topic_id => /\d+/, :post_number => /\d+/}
post 't/:topic_id/timings' => 'topics#timings', :constraints => {:topic_id => /\d+/}
post 't/:topic_id/invite' => 'topics#invite', :constraints => {:topic_id => /\d+/}
post 't/:topic_id/move-posts' => 'topics#move_posts', :constraints => {:topic_id => /\d+/}
delete 't/:topic_id/timings' => 'topics#destroy_timings', :constraints => {:topic_id => /\d+/}

post 't/:topic_id/notifications' => 'topics#set_notifications' , :constraints => {:topic_id => /\d+/}
get 't/:slug/:topic_id/best_of' => 'topics#show', defaults: {best_of: true}, constraints: {topic_id: /\d+/, post_number: /\d+/}
get 't/:topic_id/best_of' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/}
put 't/:slug/:topic_id' => 'topics#update', constraints: {topic_id: /\d+/}
put 't/:slug/:topic_id/star' => 'topics#star', constraints: {topic_id: /\d+/}
put 't/:topic_id/star' => 'topics#star', constraints: {topic_id: /\d+/}
put 't/:slug/:topic_id/status' => 'topics#status', constraints: {topic_id: /\d+/}
put 't/:topic_id/status' => 'topics#status', constraints: {topic_id: /\d+/}
put 't/:topic_id/clear-pin' => 'topics#clear_pin', constraints: {topic_id: /\d+/}
put 't/:topic_id/mute' => 'topics#mute', constraints: {topic_id: /\d+/}
put 't/:topic_id/unmute' => 'topics#unmute', constraints: {topic_id: /\d+/}

get 't/:topic_id/:post_number' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/}
get 't/:slug/:topic_id.rss' => 'topics#feed', format: :rss, constraints: {topic_id: /\d+/}
get 't/:slug/:topic_id' => 'topics#show', constraints: {topic_id: /\d+/}
get 't/:slug/:topic_id/:post_number' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/}
post 't/:topic_id/timings' => 'topics#timings', constraints: {topic_id: /\d+/}
post 't/:topic_id/invite' => 'topics#invite', constraints: {topic_id: /\d+/}
post 't/:topic_id/move-posts' => 'topics#move_posts', constraints: {topic_id: /\d+/}
delete 't/:topic_id/timings' => 'topics#destroy_timings', constraints: {topic_id: /\d+/}

post 't/:topic_id/notifications' => 'topics#set_notifications' , constraints: {topic_id: /\d+/}


resources :invites
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20120311170118_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username, :limit => 20, null: false
t.string :username, limit: 20, null: false
t.string :avatar_url, null: false
t.timestamps
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20120423151548_remove_last_post_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ def up
end

def down
add_column :forum_threads, :last_post_id, :integer, :default => 0
add_column :forum_threads, :last_post_id, :integer, default: 0
end
end
4 changes: 2 additions & 2 deletions db/migrate/20120427154330_create_vestal_versions.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class CreateVestalVersions < ActiveRecord::Migration
def self.up
create_table :versions do |t|
t.belongs_to :versioned, :polymorphic => true
t.belongs_to :user, :polymorphic => true
t.belongs_to :versioned, polymorphic: true
t.belongs_to :user, polymorphic: true
t.string :user_name
t.text :modifications
t.integer :number
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20120518200115_create_read_posts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def up
t.column :seen, :integer, null: false
end

add_index :read_posts, [:forum_thread_id, :user_id, :page], :unique => true
add_index :read_posts, [:forum_thread_id, :user_id, :page], unique: true
end

def down
Expand Down
Loading

0 comments on commit deb603f

Please sign in to comment.