From fbd6ad4ac6b43ba4a9e010c46b08c4471a1b752b Mon Sep 17 00:00:00 2001 From: Callum Barratt Date: Mon, 31 Mar 2014 22:33:16 +0100 Subject: [PATCH] Fixed formatting and ruby hash syntax --- Gemfile | 1 + Gemfile.lock | 3 ++ INSTALL.md | 2 +- app/controllers/api/v1/base_controller.rb | 2 +- app/controllers/api/v1/users_controller.rb | 2 +- app/controllers/articles_controller.rb | 6 ++-- app/controllers/bans_controller.rb | 6 ++-- app/controllers/brackets_controller.rb | 4 +-- app/controllers/categories_controller.rb | 4 +-- app/controllers/challenges_controller.rb | 8 ++--- app/controllers/comments_controller.rb | 10 +++--- app/controllers/contesters_controller.rb | 4 +-- app/controllers/contests_controller.rb | 14 ++++---- app/controllers/data_files_controller.rb | 8 ++--- app/controllers/directories_controller.rb | 12 +++---- app/controllers/forums_controller.rb | 6 ++-- app/controllers/gatherers_controller.rb | 2 +- app/controllers/gathers_controller.rb | 2 +- app/controllers/groups_controller.rb | 12 +++---- app/controllers/issues_controller.rb | 12 +++---- app/controllers/log_events_controller.rb | 16 ++++----- app/controllers/log_files_controller.rb | 8 ++--- app/controllers/maps_controller.rb | 6 ++-- app/controllers/matches_controller.rb | 14 ++++---- app/controllers/messages_controller.rb | 4 +-- app/controllers/movies_controller.rb | 12 +++---- app/controllers/options_controller.rb | 6 ++-- app/controllers/polls_controller.rb | 6 ++-- app/controllers/posts_controller.rb | 8 ++--- app/controllers/rounds_controller.rb | 8 ++--- app/controllers/servers_controller.rb | 10 +++--- app/controllers/teams_controller.rb | 6 ++-- app/controllers/topics_controller.rb | 20 +++++------ app/controllers/tweets_controller.rb | 4 +-- app/controllers/users_controller.rb | 12 +++---- app/controllers/versions_controller.rb | 4 +-- app/controllers/votes_controller.rb | 2 +- app/controllers/weeks_controller.rb | 10 +++--- app/models/article.rb | 40 +++++++++++----------- app/models/ban.rb | 16 ++++----- app/services/api/v1/collection.rb | 2 +- app/services/api/v1/users_collection.rb | 2 +- 42 files changed, 170 insertions(+), 166 deletions(-) diff --git a/Gemfile b/Gemfile index e4ced57..427b01f 100644 --- a/Gemfile +++ b/Gemfile @@ -38,6 +38,7 @@ group :development do gem 'capistrano-rails', '~> 1.1' gem 'capistrano3-unicorn', '~> 0.1.1' gem 'annotate', '~> 2.6.2' + gem 'quiet_assets' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 66339d2..898d21d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,6 +147,8 @@ GEM pry-debugger (0.2.2) debugger (~> 1.3) pry (~> 0.9.10) + quiet_assets (1.0.2) + railties (>= 3.1, < 5.0) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) @@ -275,6 +277,7 @@ DEPENDENCIES oj (~> 2.5.5) poltergeist (~> 1.5.0) pry-debugger (~> 0.2.2) + quiet_assets rails (~> 3.2.17) rmagick (~> 2.13.2) rspec-rails (~> 2.14.1) diff --git a/INSTALL.md b/INSTALL.md index 79fcdce..d7290d3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -64,5 +64,5 @@ Create the `.env` file with the appropriate credentials. # Deployment Use capistrano to deploy: - + bundle exec cap production deploy \ No newline at end of file diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index fddcd58..47d7648 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -1,3 +1,3 @@ class Api::V1::BaseController < ActionController::Base respond_to :json -end \ No newline at end of file +end diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index ef6385b..1898db6 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -2,4 +2,4 @@ class Api::V1::UsersController < Api::V1::BaseController def index respond_with Api::V1::UsersCollection.as_json end -end \ No newline at end of file +end diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index b3d7d49..9fda95e 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -1,5 +1,5 @@ class ArticlesController < ApplicationController - before_filter :get_article, :only => [:show, :edit, :update, :cleanup, :destroy] + before_filter :get_article, only: [:show, :edit, :update, :cleanup, :destroy] def index @categories = Category.ordered.nospecial.domain Category::DOMAIN_ARTICLES @@ -49,7 +49,7 @@ class ArticlesController < ApplicationController flash[:notice] = t(:articles_create) redirect_to @article else - render :action => "new" + render :new end end @@ -59,7 +59,7 @@ class ArticlesController < ApplicationController flash[:notice] = t(:articles_update) redirect_to @article else - render :action => "edit" + render :edit end end diff --git a/app/controllers/bans_controller.rb b/app/controllers/bans_controller.rb index 6081f70..a3ae9fb 100644 --- a/app/controllers/bans_controller.rb +++ b/app/controllers/bans_controller.rb @@ -1,5 +1,5 @@ class BansController < ApplicationController - before_filter :get_ban, :only => [:show, :edit, :update, :destroy] + before_filter :get_ban, only: [:show, :edit, :update, :destroy] def index @bans = Ban.ordered @@ -29,7 +29,7 @@ class BansController < ApplicationController flash[:notice] = t(:bans_create) redirect_to(@ban) else - render :action => "new" + render :new end end @@ -39,7 +39,7 @@ class BansController < ApplicationController flash[:notice] = t(:bans_update) redirect_to(@ban) else - render :action => "edit" + render :edit end end diff --git a/app/controllers/brackets_controller.rb b/app/controllers/brackets_controller.rb index 365d1bd..374199f 100644 --- a/app/controllers/brackets_controller.rb +++ b/app/controllers/brackets_controller.rb @@ -1,5 +1,5 @@ class BracketsController < ApplicationController - before_filter :get_bracket, :only => [:show, :edit, :update, :destroy] + before_filter :get_bracket, only: [:show, :edit, :update, :destroy] def edit raise AccessError unless @bracket.can_update? cuser @@ -23,7 +23,7 @@ class BracketsController < ApplicationController flash[:notice] = t(:brackets_update) end - render :action => "edit" + render :edit end def destroy diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index e46a7cf..9b4afbc 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -1,11 +1,11 @@ class CategoriesController < ApplicationController - before_filter :get_category, :except => [:index, :new, :create] + before_filter :get_category, except: [:index, :new, :create] def show if [Category::DOMAIN_ARTICLES, Category::DOMAIN_NEWS].include? @category.domain @articles = Article.with_comments.ordered.limited.nodrafts.category params[:id] Category.find(params[:id]).read_by! cuser if cuser - render :partial => "articles/article", :collection => @articles.to_a + render partial: 'articles/article', collection: @articles.to_a end end diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index ed83841..b652cee 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -1,5 +1,5 @@ class ChallengesController < ApplicationController - before_filter :get_challenge, :only => ['show', 'edit', 'update', 'destroy'] + before_filter :get_challenge, only: [:show, :edit, :update, :destroy] def index @challenges = Challenge.all @@ -14,7 +14,7 @@ class ChallengesController < ApplicationController c.destroy end - render :text => t(:challenges_cleared) + render text: t(:challenges_cleared) end def new @@ -34,7 +34,7 @@ class ChallengesController < ApplicationController flash[:notice] = t(:challenges_create) redirect_to @challenge else - render :action => "new" + render :new end end @@ -56,7 +56,7 @@ class ChallengesController < ApplicationController flash[:notice] = t(:challenges_update) end - render :action => "show" + render :show end def destroy diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 8610cbe..554c273 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,5 +1,5 @@ class CommentsController < ApplicationController - before_filter :get_comment, :only => [:raw, 'edit', 'update', 'destroy'] + before_filter :get_comment, only: [:raw, :edit, :update, :destroy] respond_to :html, :js def index @@ -7,8 +7,8 @@ class CommentsController < ApplicationController end def show - @comments = Comment.recent5.all :conditions => {:commentable_id => params[:id2], :commentable_type => params[:id]} - render :partial => 'list', :layout => false + @comments = Comment.recent5.all conditions: {commentable_id: params[:id2], commentable_type: params[:id]} + render partial: 'list', layout: false end def edit @@ -23,7 +23,7 @@ class CommentsController < ApplicationController respond_to do |format| if @comment.save flash[:notice] = t(:comments_create) - format.js { render } + format.js { render } else flash[:error] = t(:comments_invalid) + @comment.errors.full_messages.to_s format.html { redirect_to(:back)} @@ -37,7 +37,7 @@ class CommentsController < ApplicationController flash[:notice] = t(:comments_update) return_to else - render :action => "edit" + render :edit end end diff --git a/app/controllers/contesters_controller.rb b/app/controllers/contesters_controller.rb index f7a09c9..9818859 100644 --- a/app/controllers/contesters_controller.rb +++ b/app/controllers/contesters_controller.rb @@ -1,5 +1,5 @@ class ContestersController < ApplicationController - before_filter :get_contester, :only => ['show', 'edit', 'update', :recover, :destroy, :recalc] + before_filter :get_contester, only: [:show, :edit, :update, :recover, :destroy, :recalc] def show @matches = Match.future.unfinished.ordered.of_contester @contester @@ -38,7 +38,7 @@ class ContestersController < ApplicationController flash[:notice] = t(:contests_contester_update) redirect_to @contester else - render :action => "edit" + render :edit end end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 2f2e372..0c260cc 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -1,8 +1,8 @@ class ContestsController < ApplicationController - before_filter :get_contest, :only => ['show', 'edit', 'update', 'destroy', 'del_map', 'scores', 'recalc'] + before_filter :get_contest, only: [:show, :edit, :update, :destroy, :del_map, :scores, :recalc] def index - #@contests = Contest.all + # @contests = Contest.all @contests_active = Contest.active @contests_inactive = Contest.inactive end @@ -60,7 +60,7 @@ class ContestsController < ApplicationController flash[:notice] = t(:contests_create) redirect_to @contest else - render :action => "new" + render :new end end @@ -71,11 +71,11 @@ class ContestsController < ApplicationController flash[:notice] = t(:contests_update) redirect_to @contest else - render :action => "edit" + render :edit end elsif params[:commit] == "Add map" @contest.maps << Map.find(params[:map]) - render :action => "edit" + render :edit elsif params[:commit] == "Add team" contester = Contester.new contester.team = Team.find params[:team] @@ -86,14 +86,14 @@ class ContestsController < ApplicationController else @contest.errors.add_to_base contester.errors.full_messages.to_s end - render :action => "edit" + render :edit end end def del_map raise AccessError unless @contest.can_update? cuser @contest.maps.delete(Map.find(params[:id2])) - render :action => "edit" + render :edit end def destroy diff --git a/app/controllers/data_files_controller.rb b/app/controllers/data_files_controller.rb index bb1b95e..10a708a 100644 --- a/app/controllers/data_files_controller.rb +++ b/app/controllers/data_files_controller.rb @@ -1,5 +1,5 @@ class DataFilesController < ApplicationController - before_filter :get_file, :only => ['show', 'edit', 'update', 'destroy', 'rate', :addFile, :delFile] + before_filter :get_file, only: [:show, :edit, :update, :destroy, :rate, :addFile, :delFile] def show end @@ -41,7 +41,7 @@ class DataFilesController < ApplicationController redirect_to @file end else - render :action => "new" + render :new end end @@ -51,7 +51,7 @@ class DataFilesController < ApplicationController flash[:notice] = t(:files_update) redirect_to(@file) else - render :action => "edit" + render :edit end end @@ -94,7 +94,7 @@ class DataFilesController < ApplicationController @result << file.to_s + "
" end end - render :text => @result, :layout => true + render text: @result, layout: true end private diff --git a/app/controllers/directories_controller.rb b/app/controllers/directories_controller.rb index a1fc81c..f4968bc 100644 --- a/app/controllers/directories_controller.rb +++ b/app/controllers/directories_controller.rb @@ -1,12 +1,12 @@ class DirectoriesController < ApplicationController - before_filter :get_directory, :except => [:new, :create] + before_filter :get_directory, except: [:new, :create] def show if @directory.hidden @files = @directory.files - render :partial => "data_files/list", :layout => true + render partial: 'data_files/list', layout: true else - @directories = Directory.ordered.filtered.all :conditions => {:parent_id => 1} + @directories = Directory.ordered.filtered.all conditions: { parent_id: 1 } end end @@ -22,7 +22,7 @@ class DirectoriesController < ApplicationController def refresh @directory.process_dir - render :text => t(:directories_update) + render text: t(:directories_update) end def create @@ -33,7 +33,7 @@ class DirectoriesController < ApplicationController flash[:notice] = t(:directories_create) redirect_to(@directory) else - render :action => "new" + render :new end end @@ -43,7 +43,7 @@ class DirectoriesController < ApplicationController flash[:notice] = t(:directories_update) redirect_to @directory else - render :action => "edit" + render :edit end end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 1b0c560..d4107f6 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,5 +1,5 @@ class ForumsController < ApplicationController - before_filter :get_forum, :only => [:show, :edit, :update, :up, :down, :destroy] + before_filter :get_forum, only: [:show, :edit, :update, :up, :down, :destroy] def index @categories = Category.domain(Category::DOMAIN_FORUMS).ordered @@ -30,7 +30,7 @@ class ForumsController < ApplicationController flash[:notice] = t(:forums_create) redirect_to(@forum) else - render :action => "new" + render :new end end @@ -40,7 +40,7 @@ class ForumsController < ApplicationController flash[:notice] = t(:forums_update) redirect_to(@forum) else - render :action => "edit" + render :edit end end diff --git a/app/controllers/gatherers_controller.rb b/app/controllers/gatherers_controller.rb index 547dc05..6a45076 100644 --- a/app/controllers/gatherers_controller.rb +++ b/app/controllers/gatherers_controller.rb @@ -1,5 +1,5 @@ class GatherersController < ApplicationController - before_filter :get_gatherer, :except => [:create] + before_filter :get_gatherer, except: [:create] def create Gather.transaction do diff --git a/app/controllers/gathers_controller.rb b/app/controllers/gathers_controller.rb index 9788220..b95bea0 100644 --- a/app/controllers/gathers_controller.rb +++ b/app/controllers/gathers_controller.rb @@ -1,5 +1,5 @@ class GathersController < ApplicationController - before_filter :get_gather, :except => [:latest, :index, :create] + before_filter :get_gather, except: [:latest, :index, :create] respond_to :html, :js def index diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 8ef629c..df96dc2 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,5 +1,5 @@ class GroupsController < ApplicationController - before_filter :get_group, :except => [:index, :new, :create] + before_filter :get_group, except: [:index, :new, :create] def index @groups = Group.all @@ -26,7 +26,7 @@ class GroupsController < ApplicationController flash[:notice] = t(:groups_create) redirect_to @group else - render :action => "new" + render :new end end @@ -36,7 +36,7 @@ class GroupsController < ApplicationController flash[:notice] = t(:groups_update) redirect_to @group else - render :action => "edit" + render :edit end end @@ -47,12 +47,12 @@ class GroupsController < ApplicationController end def addUser - @user = User.first :conditions => {:username => params[:username]} + @user = User.first conditions: {username: params[:username]} raise AccessError unless @group.can_update? cuser raise Error, t(:duplicate_user) if @group.users.include? @user @group.users << @user if @user - redirect_to edit_group_url(@group, :groupTab => "groupTabMembers") + redirect_to edit_group_url(@group, groupTab: "groupTabMembers") end def delUser @@ -60,7 +60,7 @@ class GroupsController < ApplicationController raise AccessError unless @group.can_update? cuser @group.users.delete @user - redirect_to edit_group_url(@group, :groupTab => "groupTabMembers") + redirect_to edit_group_url(@group, groupTab: "groupTabMembers") end private diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index cf0e922..3fb04c9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,5 +1,5 @@ class IssuesController < ApplicationController - before_filter :get_issue, :only => [:show, :edit, :update, :destroy] + before_filter :get_issue, only: [:show, :edit, :update, :destroy] def index raise AccessError unless cuser and cuser.admin? @@ -12,9 +12,9 @@ class IssuesController < ApplicationController else "created_at DESC" end - @open = Issue.with_status(Issue::STATUS_OPEN).all :order => sort - @solved = Issue.with_status(Issue::STATUS_SOLVED).all :order => sort - @rejected = Issue.with_status(Issue::STATUS_REJECTED).all :order => sort + @open = Issue.with_status(Issue::STATUS_OPEN).all order: sort + @solved = Issue.with_status(Issue::STATUS_SOLVED).all order: sort + @rejected = Issue.with_status(Issue::STATUS_REJECTED).all order: sort end def show @@ -44,7 +44,7 @@ class IssuesController < ApplicationController redirect_to_home end else - render :action => "new" + render :new end end @@ -54,7 +54,7 @@ class IssuesController < ApplicationController flash[:notice] = t(:issues_update) redirect_to(@issue) else - render :action => "edit" + render :edit end end diff --git a/app/controllers/log_events_controller.rb b/app/controllers/log_events_controller.rb index abad28d..e1064ee 100644 --- a/app/controllers/log_events_controller.rb +++ b/app/controllers/log_events_controller.rb @@ -6,7 +6,7 @@ class LogEventsController < ApplicationController respond_to do |format| format.html # index.html.erb - format.xml { render :xml => @log_events } + format.xml { render xml: @log_events } end end @@ -17,7 +17,7 @@ class LogEventsController < ApplicationController respond_to do |format| format.html # show.html.erb - format.xml { render :xml => @log_event } + format.xml { render xml: @log_event } end end @@ -28,7 +28,7 @@ class LogEventsController < ApplicationController respond_to do |format| format.html # new.html.erb - format.xml { render :xml => @log_event } + format.xml { render xml: @log_event } end end @@ -46,10 +46,10 @@ class LogEventsController < ApplicationController if @log_event.save flash[:notice] = t(:logevent_create) format.html { redirect_to(@log_event) } - format.xml { render :xml => @log_event, :status => :created, :location => @log_event } + format.xml { render xml: @log_event, :status => :created, :location => @log_event } else - format.html { render :action => "new" } - format.xml { render :xml => @log_event.errors, :status => :unprocessable_entity } + format.html { render :new } + format.xml { render xml: @log_event.errors, :status => :unprocessable_entity } end end end @@ -65,8 +65,8 @@ class LogEventsController < ApplicationController format.html { redirect_to(@log_event) } format.xml { head :ok } else - format.html { render :action => "edit" } - format.xml { render :xml => @log_event.errors, :status => :unprocessable_entity } + format.html { render :edit } + format.xml { render xml: @log_event.errors, :status => :unprocessable_entity } end end end diff --git a/app/controllers/log_files_controller.rb b/app/controllers/log_files_controller.rb index 35c0098..dda7433 100644 --- a/app/controllers/log_files_controller.rb +++ b/app/controllers/log_files_controller.rb @@ -1,12 +1,12 @@ class LogFilesController < ApplicationController def index LogFile.process - render :text => "Ok" + render text: 'Ok' end def handle LogFile.find(params[:id]).deal - render :text => "Ok" + render text: 'Ok' end def refresh @@ -16,9 +16,9 @@ class LogFilesController < ApplicationController end def fix - Rounder.find_in_batches(:batch_size => 100) do |rounders| + Rounder.find_in_batches(batch_size: 100) do |rounders| rounders.each do |r| - r.team_id = nil + r.team_id = nil if r.user and t = Teamer.historic(r.user, r.round.start).first r.team_id = t.team_id end diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 7862eac..cb5546b 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -1,5 +1,5 @@ class MapsController < ApplicationController - before_filter :get_map, :only => [:show, :edit, :update, :destroy] + before_filter :get_map, only: [:show, :edit, :update, :destroy] def index @maps = Map.basic @@ -25,7 +25,7 @@ class MapsController < ApplicationController flash[:notice] = t(:maps_create) redirect_to @map else - render :action => "new" + render :new end end @@ -35,7 +35,7 @@ class MapsController < ApplicationController flash[:notice] = t(:maps_update) redirect_to @map else - render :action => "edit" + render :edit end end diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 16a754b..9827dfe 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -1,12 +1,12 @@ class MatchesController < ApplicationController - before_filter :get_match, :except => [:index, :new, :create] + before_filter :get_match, except: [:index, :new, :create] def index @matches = Match.active end def show - @ownpred = @match.predictions.first :conditions => {:user_id => cuser.id} if cuser + @ownpred = @match.predictions.first conditions: {user_id: cuser.id} if cuser @newpred = @match.predictions.build end @@ -40,9 +40,9 @@ class MatchesController < ApplicationController if @match.save flash[:notice] = t(:matches_create) - redirect_to :controller => "contests", :action => "edit", :id => @match.contest + redirect_to controller: 'contests', action: 'edit', id: @match.contest else - render :action => "new" + render :new end end @@ -69,7 +69,7 @@ class MatchesController < ApplicationController end end else - render :action => "edit" + render :edit end end @@ -88,13 +88,13 @@ class MatchesController < ApplicationController @match.hltv_stop flash[:notice] = t(:hltv_stopped) end - redirect_to :action => "show" + redirect_to action: 'show' end def destroy raise AccessError unless @match.can_destroy? cuser @match.destroy - redirect_to :controller => "contests", :action => "edit", :id => @match.contest + redirect_to controller: 'contests', action: 'edit', id: @match.contest end private diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 46f5320..7c248e5 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -1,5 +1,5 @@ class MessagesController < ApplicationController - before_filter :get_message, :only => [:show, :edit, :update, :destroy] + before_filter :get_message, only: [:show, :edit, :update, :destroy] def index raise AccessError unless cuser @@ -37,7 +37,7 @@ class MessagesController < ApplicationController flash[:notice] = t(:message_create) redirect_to(@message) else - render :action => "new" + render :new end end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index f49cf96..bfdf191 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,5 +1,5 @@ class MoviesController < ApplicationController - before_filter :get_movie, :except => [:index, :new, :create] + before_filter :get_movie, except: [:index, :new, :create] def index @movies = [] @@ -48,7 +48,7 @@ class MoviesController < ApplicationController flash[:notice] = t(:movies_create) redirect_to(@movie) else - render :action => "new" + render :new end end @@ -59,7 +59,7 @@ class MoviesController < ApplicationController flash[:notice] = t(:movies_update) redirect_to(@movie) else - render :action => "edit" + render :edit end end @@ -67,20 +67,20 @@ class MoviesController < ApplicationController raise AccessError unless @movie.can_update? cuser x = params[:x].to_i <= 1280 ? params[:x].to_i : 800 y = params[:y].to_i <= 720 ? params[:y].to_i : 600 - render :text => t(:executed) + "
" + @movie.make_preview(x, y), :layout => true + render text: t(:executed) + "
" + @movie.make_preview(x, y), layout: true end def snapshot raise AccessError unless @movie.can_update? cuser secs = params[:secs].to_i > 0 ? params[:secs].to_i : 5 - render :text => t(:executed) + "
" + @movie.make_snapshot(secs), :layout => true + render text: t(:executed) + "
" + @movie.make_snapshot(secs), layout: true end def download raise AccessError unless cuser.admin? @movie.stream_ip = params[:ip] @movie.stream_port = params[:port] - render :text => t(:executed) + "
" + @movie.make_stream, :layout => true + render text: t(:executed) + "
" + @movie.make_stream, layout: true end def destroy diff --git a/app/controllers/options_controller.rb b/app/controllers/options_controller.rb index 34b3192..2dd640d 100644 --- a/app/controllers/options_controller.rb +++ b/app/controllers/options_controller.rb @@ -1,5 +1,5 @@ class PollsController < ApplicationController - before_filter :get_poll, :except => [:index, :new, :create] + before_filter :get_poll, except: [:index, :new, :create] respond_to :js def add @@ -14,7 +14,7 @@ class PollsController < ApplicationController flash[:notice] = t(:polls_create) redirect_to @poll else - render :action => "new" + render :new end end @@ -25,7 +25,7 @@ class PollsController < ApplicationController flash[:notice] = t(:polls_update) redirect_to @poll else - render :action => "edit" + render :edit end end diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 12526e9..c5d327b 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1,5 +1,5 @@ class PollsController < ApplicationController - before_filter :get_poll, :except => [:index, :new, :create] + before_filter :get_poll, except: [:index, :new, :create] def index @polls = Poll.all @@ -27,7 +27,7 @@ class PollsController < ApplicationController flash[:notice] = t(:polls_create) redirect_to @poll else - render :action => "new" + render :new end end @@ -38,7 +38,7 @@ class PollsController < ApplicationController flash[:notice] = t(:polls_update) redirect_to @poll else - render :action => "edit" + render :edit end end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index bb0b09c..cb3f7f1 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,5 +1,5 @@ class PostsController < ApplicationController - before_filter :get_post, :except => [:new, :create] + before_filter :get_post, except: [:new, :create] respond_to :html, :js def quote @@ -10,12 +10,12 @@ class PostsController < ApplicationController @post = Post.new @post.topic = Topic.find(params[:id]) raise AccessError unless @post.can_create? cuser - render :layout => "forums" + render layout: 'forums' end def edit raise AccessError unless @post.can_update? cuser - render :layout => "forums" + render layout: 'forums' end def create @@ -40,7 +40,7 @@ class PostsController < ApplicationController flash[:notice] = t(:posts_update) redirect_to @post.topic else - render :action => "edit" + render :edit end end diff --git a/app/controllers/rounds_controller.rb b/app/controllers/rounds_controller.rb index 6cd42c1..b09511b 100644 --- a/app/controllers/rounds_controller.rb +++ b/app/controllers/rounds_controller.rb @@ -10,12 +10,12 @@ class RoundsController < ApplicationController end @rounds = Round.basic.paginate \ - :order => sort, - :page => params[:page], - :per_page => 30 + order: sort, + page: params[:page], + per_page: 30 if params[:ajax] - render :partial => "list", :layout => false + render partial: 'list', layout: false return end end diff --git a/app/controllers/servers_controller.rb b/app/controllers/servers_controller.rb index f96998a..1197d7c 100644 --- a/app/controllers/servers_controller.rb +++ b/app/controllers/servers_controller.rb @@ -1,5 +1,5 @@ class ServersController < ApplicationController - before_filter :get_server, :except => [:index, :refresh, :new, :create] + before_filter :get_server, except: [:index, :refresh, :new, :create] def refresh Server.refresh @@ -30,7 +30,7 @@ class ServersController < ApplicationController raise AccessError unless @server.can_update? cuser if request.xhr? - render :partial => "response", :layout => false + render partial: 'response', layout: false end end @@ -43,7 +43,7 @@ class ServersController < ApplicationController flash[:notice] = t(:server_create) redirect_to @server else - render :action => "new" + render :new end end @@ -54,14 +54,14 @@ class ServersController < ApplicationController flash[:notice] = t(:server_update) redirect_to @server else - render :action => "edit" + render :edit end end def default raise AccessError unless @server.can_update? cuser @server.default_record - render :text => "Ok" + render text: 'Ok' end def destroy diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index ce05026..a610a21 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -1,5 +1,5 @@ class TeamsController < ApplicationController - before_filter :get_team, :only => ['show', 'edit', 'update', 'destroy', 'recover'] + before_filter :get_team, only: [:show, :edit, :update, :destroy, :recover] def index @teams = Team.with_teamers_num(0).ordered @@ -26,7 +26,7 @@ class TeamsController < ApplicationController flash[:notice] = t(:teams_create) redirect_to @team else - render :action => "new" + render :new end end @@ -48,7 +48,7 @@ class TeamsController < ApplicationController flash[:notice] = t(:teams_update) redirect_to edit_team_path(@team) else - render :action => "edit" + render :edit end end diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 5b228c6..38a8306 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -1,13 +1,13 @@ class TopicsController < ApplicationController - before_filter :get_topic, :only => [:show, :reply, :edit, :update, :destroy] + before_filter :get_topic, only: [:show, :reply, :edit, :update, :destroy] def index - render :partial => true, :locals => {:page => params[:p].to_i} + render partial: true, locals: {page: params[:p].to_i} end def show raise AccessError unless @topic.can_show? cuser - @posts = @topic.posts.basic.paginate(:page => params[:page], + @posts = @topic.posts.basic.paginate(:page => params[:page], :per_page => Topic::POSTS_PAGE) return_here @@ -18,16 +18,16 @@ class TopicsController < ApplicationController @newpost.topic = @topic @newpost.user = cuser @lock = (@topic.lock ? @topic.lock : Lock.new(:lockable => @topic)) - render :layout => "forums" + render layout: 'forums' end def reply @post = @topic.posts.build raise AccessError unless @post.can_create? cuser if request.xhr? - render "quickreply", :layout => false + render 'quickreply', layout: false else - render :layout => "forums" + render layout: 'forums' end end @@ -35,12 +35,12 @@ class TopicsController < ApplicationController @topic = Topic.new @topic.forum = Forum.find(params[:id]) raise AccessError unless @topic.can_create? cuser - render :layout => "forums" + render layout: 'forums' end def edit raise AccessError unless @topic.can_update? cuser - render :layout => "forums" + render layout: 'forums' end def create @@ -52,7 +52,7 @@ class TopicsController < ApplicationController flash[:notice] = t(:topics_create) redirect_to(@topic) else - render :action => "new" + render :new end end @@ -62,7 +62,7 @@ class TopicsController < ApplicationController flash[:notice] = t(:topics_update) redirect_to(@topic) else - render :action => "edit" + render :edit end end diff --git a/app/controllers/tweets_controller.rb b/app/controllers/tweets_controller.rb index 3f372ac..93106d0 100644 --- a/app/controllers/tweets_controller.rb +++ b/app/controllers/tweets_controller.rb @@ -3,7 +3,7 @@ require 'open-uri' class TweetsController < ApplicationController def index - @tweets = Tweet.all :order => "created_at DESC" + @tweets = Tweet.all order: "created_at DESC" @nobody = true end @@ -24,6 +24,6 @@ class TweetsController < ApplicationController end end - render :text => t(:tweets_refresh) + render text: t(:tweets_refresh) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 607b732..dda9ad1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,9 +1,9 @@ class UsersController < ApplicationController - before_filter :get_user, :only => [:show, :history, :popup, :agenda, :edit, :update, :destroy] + before_filter :get_user, only: [:show, :history, :popup, :agenda, :edit, :update, :destroy] respond_to :html, :js def index - @users = User.search(params[:search]).paginate(:per_page => 40, :page => params[:page]) + @users = User.search(params[:search]).paginate(per_page: 40, page: params[:page]) end def show @@ -29,7 +29,7 @@ class UsersController < ApplicationController end def popup - render :layout => false + render layout: false end def new @@ -54,10 +54,10 @@ class UsersController < ApplicationController @user.profile = Profile.new @user.profile.user = @user @user.profile.save() - redirect_to :action => :show, :id => @user.id + redirect_to action: :show, id: @user.id save_session @user else - render :action => "new" + render :new end end @@ -67,7 +67,7 @@ class UsersController < ApplicationController flash[:notice] = t(:users_update) redirect_to_back else - render :action => "edit" + render :edit end end diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 0c7d7b0..83b147c 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -3,13 +3,13 @@ class VersionsController < ApplicationController def index @versions = @article.versions - render "articles/history" + render 'articles/history' end def show @version = @article.versions.find params[:id] @nobody = true - render "articles/version" + render 'articles/version' end def update diff --git a/app/controllers/votes_controller.rb b/app/controllers/votes_controller.rb index 809f72d..052925d 100644 --- a/app/controllers/votes_controller.rb +++ b/app/controllers/votes_controller.rb @@ -1,6 +1,6 @@ class VotesController < ApplicationController def create - @vote = Vote.new params[:vote] + @vote = Vote.new(params[:vote]) @vote.user = cuser raise AccessError unless @vote.can_create? cuser diff --git a/app/controllers/weeks_controller.rb b/app/controllers/weeks_controller.rb index 1f56ace..e6bc7e2 100644 --- a/app/controllers/weeks_controller.rb +++ b/app/controllers/weeks_controller.rb @@ -1,9 +1,9 @@ class WeeksController < ApplicationController - before_filter :get_week, :except => [:new, :create] + before_filter :get_week, except: [:new, :create] def new @week = Week.new - @week.contest = Contest.find params[:id] + @week.contest = Contest.find(params[:id]) raise AccessError unless @week.can_create? cuser end @@ -19,7 +19,7 @@ class WeeksController < ApplicationController flash[:notice] = t(:weeks_create) redirect_to @week.contest else - render :action => "new" + render :new end end @@ -30,7 +30,7 @@ class WeeksController < ApplicationController flash[:notice] = t(:weeks_update) redirect_to @week.contest else - render :action => "edit" + render :edit end end @@ -43,6 +43,6 @@ class WeeksController < ApplicationController private def get_week - @week = Week.find params[:id] + @week = Week.find(params[:id]) end end diff --git a/app/models/article.rb b/app/models/article.rb index bb4a669..c2edaf1 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -37,26 +37,26 @@ class Article < ActiveRecord::Base attr_protected :id, :updated_at, :created_at, :user_id, :version - scope :recent, :order => "created_at DESC", :limit => 8 + scope :recent, order: 'created_at DESC', limit: 8 scope :with_comments, - :select => "articles.*, COUNT(C.id) AS comment_num", - :joins => "LEFT JOIN comments C ON C.commentable_type = 'Article' AND C.commentable_id = articles.id", - :group => "articles.id" - scope :ordered, :order => "articles.created_at DESC" - scope :limited, :limit => 5 - scope :nodrafts, :conditions => {:status => STATUS_PUBLISHED} - scope :drafts, :conditions => {:status => STATUS_DRAFT} - scope :articles, :conditions => ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_ARTICLES] - scope :onlynews, :conditions => ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_NEWS] - scope :category, lambda { |cat| {:conditions => {:category_id => cat}} } - scope :domain, lambda { |domain| {:include => "category", :conditions => {"categories.domain" => domain}} } - scope :nospecial, :conditions => ["category_id != ?", Category::SPECIAL] - scope :interviews, :conditions => ["category_id = ?", Category::INTERVIEWS] + select: "articles.*, COUNT(C.id) AS comment_num", + joins: "LEFT JOIN comments C ON C.commentable_type = 'Article' AND C.commentable_id = articles.id", + group: "articles.id" + scope :ordered, order: 'articles.created_at DESC' + scope :limited, limit: 5 + scope :nodrafts, conditions: { status: STATUS_PUBLISHED } + scope :drafts, conditions: { status: STATUS_DRAFT } + scope :articles, conditions: ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_ARTICLES] + scope :onlynews, conditions: ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_NEWS] + scope :category, lambda { |cat| { conditions: { category_id: cat } } } + scope :domain, lambda { |domain| { includes: 'category', conditions: { "categories.domain" => domain } } } + scope :nospecial, conditions: ["category_id != ?", Category::SPECIAL] + scope :interviews, conditions: ["category_id = ?", Category::INTERVIEWS] belongs_to :user belongs_to :category - has_many :comments, :as => :commentable, :order => "created_at ASC", :dependent => :destroy - has_many :files, :class_name => "DataFile", :order => "created_at DESC", :dependent => :destroy + has_many :comments, as: :commentable, order: 'created_at ASC', dependent: :destroy + has_many :files, class_name: 'DataFile', order: 'created_at DESC', dependent: :destroy validates_length_of :title, :in => 1..50 validates_length_of :text, :in => 1..16000000 @@ -82,11 +82,11 @@ class Article < ActiveRecord::Base end def previous_article - category.articles.nodrafts.first(:conditions => ["id < ?", self.id], :order => "id DESC") + category.articles.nodrafts.first(conditions: ["id < ?", self.id], order: "id DESC") end def next_article - category.articles.nodrafts.first(:conditions => ["id > ?", self.id], :order => "id ASC") + category.articles.nodrafts.first(conditions: ["id > ?", self.id], order: "id ASC") end def statuses @@ -114,11 +114,11 @@ class Article < ActiveRecord::Base if (new_record? or status_changed?) and status == STATUS_PUBLISHED case category.domain when Category::DOMAIN_NEWS - Profile.all(:include => :user, :conditions => "notify_news = 1").each do |p| + Profile.all(includes: :user, conditions: "notify_news = 1").each do |p| Notifications.news p.user, self if p.user end when Category::DOMAIN_ARTICLES - Profile.all(:include => :user, :conditions => "notify_articles = 1").each do |p| + Profile.all(includes: :user, conditions: "notify_articles = 1").each do |p| Notifications.article p.user, self if p.user end end diff --git a/app/models/ban.rb b/app/models/ban.rb index 0771729..e234580 100644 --- a/app/models/ban.rb +++ b/app/models/ban.rb @@ -29,16 +29,16 @@ class Ban < ActiveRecord::Base attr_protected :id, :created_at, :updated_at attr_accessor :ts, :sign, :len, :user_name - scope :ordered, :order => "created_at DESC" - scope :effective, :conditions => "expiry > UTC_TIMESTAMP()" - scope :ineffective, :conditions => "expiry < UTC_TIMESTAMP()" + scope :ordered, order: "created_at DESC" + scope :effective, conditions: "expiry > UTC_TIMESTAMP()" + scope :ineffective, conditions: "expiry < UTC_TIMESTAMP()" validate :validate_ts validate :validate_type validate :validate_ventban - validates_format_of :steamid, :with => /\A([0-9]{1,10}:){2}[0-9]{1,10}\Z/, :allow_blank => true - validates_format_of :addr, :with => /\A([0-9]{1,3}\.){3}[0-9]{1,3}:?[0-9]{0,5}\z/, :allow_blank => true - validates_length_of :reason, :maximum => 255, :allow_nil => true, :allow_blank => true + validates_format_of :steamid, with: /\A([0-9]{1,10}:){2}[0-9]{1,10}\Z/, allow_blank: true + validates_format_of :addr, with: /\A([0-9]{1,3}\.){3}[0-9]{1,3}:?[0-9]{0,5}\z/, allow_blank: true + validates_length_of :reason, maximum: 255, allow_nil: true, allow_blank: true before_validation :check_user @@ -78,8 +78,8 @@ class Ban < ActiveRecord::Base if user_name self.user = User.find_by_username(user_name) else - self.user = User.first(:conditions => {:steamid => steamid}) - self.server = Server.first(:conditions => ["CONCAT(ip, ':', port) = ?", addr]) + self.user = User.first(conditions: { steamid: steamid }) + self.server = Server.first(conditions: ["CONCAT(ip, ':', port) = ?", addr]) end end diff --git a/app/services/api/v1/collection.rb b/app/services/api/v1/collection.rb index 60eada4..bc7c3b4 100644 --- a/app/services/api/v1/collection.rb +++ b/app/services/api/v1/collection.rb @@ -2,4 +2,4 @@ class Api::V1::Collection def execute_query ActiveRecord::Base.connection.execute(arel_query.to_sql) end -end \ No newline at end of file +end diff --git a/app/services/api/v1/users_collection.rb b/app/services/api/v1/users_collection.rb index 4b9d494..8065d41 100644 --- a/app/services/api/v1/users_collection.rb +++ b/app/services/api/v1/users_collection.rb @@ -55,4 +55,4 @@ class Api::V1::UsersCollection < Api::V1::Collection } end end -end \ No newline at end of file +end