Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Convert al the Ruby 1.8 hashrockets to 1.9 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki24 committed Apr 11, 2014
1 parent 0c76a2c commit a64e863
Show file tree
Hide file tree
Showing 45 changed files with 135 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gem 'pivotal-tracker', '0.5.8'
gem 'rails', '4.0.4'
gem 'rake'
gem 'xpath'
gem 'whenever', :require => false
gem 'whenever', require: false
gem 'rails-backbone'
gem 'coffee-rails', '~> 4.0.0'
gem 'eco'
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ rescue LoadError
STDERR.puts "Run `rake gems:install` to install delayed_job"
end

task :default => [:jshint, "jasmine:compile_coffeescript", "jasmine:ci"]
task default: [:jshint, "jasmine:compile_coffeescript", "jasmine:ci"]
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Vagrant::Config.run do |config|
chef.add_recipe "teamcity"

# You may also specify custom JSON attributes:
chef.json = { :mysql_password => "foo" }
chef.json = { mysql_password: "foo" }
end

# Enable provisioning with chef server, specifying the chef server URL,
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/aggregate_projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AggregateProjectsController < ApplicationController
before_filter :authenticate_user!, :except => [:show, :status, :index]
before_filter :load_aggregate_project, :only => [:show, :edit, :update, :destroy]
before_filter :authenticate_user!, except: [:show, :status, :index]
before_filter :load_aggregate_project, only: [:show, :edit, :update, :destroy]

respond_to :json, only: [:index, :show]

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class HomeController < ApplicationController

skip_filter :authenticate_user!

respond_to :html, :only => [:styleguide]
respond_to :rss, :only => :builds
respond_to :json, :only => [:github_status, :heroku_status, :rubygems_status, :index]
respond_to :html, only: [:styleguide]
respond_to :rss, only: :builds
respond_to :json, only: [:github_status, :heroku_status, :rubygems_status, :index]

def index
if aggregate_project_id = params[:aggregate_project_id]
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ def google_oauth2
@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)

if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
sign_in_and_redirect @user, :event => :authentication
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: "Google"
sign_in_and_redirect @user, event: :authentication
else
session["devise.google_data"] = request.env["omniauth.auth"]
redirect_to edit_configuration_url
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ProjectsController < ApplicationController
skip_filter :authenticate_user!, :only => [:show, :status, :index]
before_filter :load_project, :only => [:edit, :update, :destroy]
skip_filter :authenticate_user!, only: [:show, :status, :index]
before_filter :load_project, only: [:edit, :update, :destroy]
around_filter :scope_by_aggregate_project

respond_to :json, only: [:index, :show]
Expand Down Expand Up @@ -82,7 +82,7 @@ def validate_build_info
project_updater = ProjectUpdater.new(payload_processor: PayloadProcessor.new(project_status_updater: status_updater))
log_entry = project_updater.update(project)

render :json => {
render json: {
status: log_entry.status == 'successful',
error_type: log_entry.error_type,
error_text: log_entry.error_text.to_s[0,10000]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/versions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class VersionsController < ApplicationController
VERSION_PATH = File.join(Rails.root, 'VERSION')

def show
render :text => version
render text: version
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/models/aggregate_project.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class AggregateProject < ActiveRecord::Base
has_many :projects

before_destroy { |record| record.projects.update_all :aggregate_project_id => nil }
before_destroy { |record| record.projects.update_all aggregate_project_id: nil }

scope :enabled, -> { where(enabled: true) }
scope :with_statuses, -> { joins(:projects => :statuses).uniq }
scope :with_statuses, -> { joins(projects: :statuses).uniq }
scope :displayable, lambda { |tags=nil|
scope = enabled.joins(:projects).select("DISTINCT aggregate_projects.*").order('code ASC')
return scope.tagged_with(tags, :any => true) if tags
return scope.tagged_with(tags, any: true) if tags
scope
}

Expand Down
4 changes: 2 additions & 2 deletions app/models/external_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ class ExternalDependency
class << self
def get_or_fetch(name, threshold=30)
name.downcase!
Rails.cache.fetch(name, :expires_in => threshold.seconds) { refresh_status(name) }
Rails.cache.fetch(name, expires_in: threshold.seconds) { refresh_status(name) }
end

def fetch_status(name)
name.downcase!
status = refresh_status(name)
Rails.cache.write(name, status, :expires_in => 30.seconds)
Rails.cache.write(name, status, expires_in: 30.seconds)
status
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Project < ActiveRecord::Base

scope :displayable, lambda { |tags|
scope = enabled.order('code ASC')
return scope.tagged_with(tags, :any => true) if tags
return scope.tagged_with(tags, any: true) if tags
scope
}

Expand Down
6 changes: 3 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ class User < ActiveRecord::Base

validates :password, confirmation: true
validates :login, presence: true, length: 2..40, uniqueness: true
validates_length_of :name, :maximum => 100
validates_length_of :name, maximum: 100
validates :email, presence: true, length: 6..100, uniqueness: true

def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["lower(login) = :value OR lower(email) = :value", { :value => login.downcase }]).first
where(conditions).where(["lower(login) = :value OR lower(email) = :value", { value: login.downcase }]).first
else
where(conditions).first
end
end

def self.find_for_google_oauth2(access_token, signed_in_resource=nil)
data = access_token.info
user = User.where(:email => data["email"]).first
user = User.where(email: data["email"]).first
user || User.create!(name: data["name"],
email: data["email"],
login: data["email"].split('@').first,
Expand Down
2 changes: 1 addition & 1 deletion app/views/aggregate_projects/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.form-group
= f.label :tag_list, "Tags", class: "col-sm-2 control-label"
.col-sm-2
= f.text_field :tag_list, :size=>40, class: "form-control"
= f.text_field :tag_list, size: 40, class: "form-control"
%p.help-block (separate with commas)
.row
.col-sm-offset-2.col-sm-1
Expand Down
4 changes: 2 additions & 2 deletions app/views/aggregate_projects/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
%h1 Edit Aggregate Project
= error_messages_for :aggregate_project
= form_for @aggregate_project do |f|
= render 'form', :f => f
%div{:style => "margin-left: 30px;"}
= render 'form', f: f
%div{style: "margin-left: 30px;"}
= link_to 'Remove Aggregate Project -', aggregate_project_path, data: { confirm: 'Are you sure?' }, method: :delete, class: "button"
2 changes: 1 addition & 1 deletion app/views/aggregate_projects/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
%hr
= error_messages_for :aggregate_project
= form_for(@aggregate_project, html: { class: "form-horizontal" }) do |f|
= render 'form', :f => f
= render 'form', f: f
22 changes: 11 additions & 11 deletions app/views/configuration/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
%hr
%h4
Projects
= link_to 'Add Project +', new_project_path, :class => 'btn btn-primary btn-xs'
= link_to 'Add Project +', new_project_path, class: 'btn btn-primary btn-xs'

%table.projects.table.table-striped.table-hover
%thead
Expand All @@ -29,32 +29,32 @@
%th Actions
%tbody
- @projects.each do |project|
%tr{:id => "project-#{project.id}", data: { tags: project.tag_list.inspect, "polling-status" => project_last_status_text(project)}}
%tr{id: "project-#{project.id}", data: { tags: project.tag_list.inspect, "polling-status" => project_last_status_text(project)}}
%td= h project.code
%td= h project.name
%td
= content_tag 'span', :title=>"#{project.feed_url}#{project.has_auth? ? ' (under auth)' : ''}" do
= content_tag 'span', title: "#{project.feed_url}#{project.has_auth? ? ' (under auth)' : ''}" do
= t("project_types.#{project.class.name.underscore}")
= image_tag("icons/lock.png") if project.has_auth?
%td.text-center
- if project.enabled?
- else
%span{:style => "color: #AA1224;"} ✕
%span{style: "color: #AA1224;"} ✕
%td
= project_last_status(project)
%td.text-center= project.aggregate_project.present? ? project.aggregate_project.name : ""
%td.tag_list= project.tag_list
%td.age= project.updated_at.present? ? time_ago_in_words(project.updated_at) : "N/A"
%td.webhooks.text-center= project.webhooks_enabled ? "" : ""
%td.actions
= link_to 'Edit', edit_project_path(project), :class => "btn btn-xs btn-default"
= link_to 'Delete', project_path(project), :method => :delete, :data => { :confirm => 'Are you sure?' }, :class =>"btn btn-xs btn-default"
= link_to 'Edit', edit_project_path(project), class: "btn btn-xs btn-default"
= link_to 'Delete', project_path(project), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-xs btn-default"

%hr
%h4
Aggregate Projects
= link_to 'Add Aggregate Project +', new_aggregate_project_path, :class => "btn btn-primary btn-xs"
= link_to 'Add Aggregate Project +', new_aggregate_project_path, class: "btn btn-primary btn-xs"
- unless @aggregate_projects.empty?
%table.projects.table.table-striped.table-hover
%thead
Expand All @@ -67,16 +67,16 @@
%th Actions
%tbody
- for aggregate_project in @aggregate_projects
%tr{:id => "aggregate-project-#{aggregate_project.id}",data: { tags: aggregate_project.tag_list.inspect, "polling-status" => "" }}
%tr{id: "aggregate-project-#{aggregate_project.id}", data: { tags: aggregate_project.tag_list.inspect, "polling-status" => "" }}
%td= h aggregate_project.name
%td.text-center
- if aggregate_project.enabled?
- else
%span{:style => "color: #AA1224;"} ✕
%span{style: "color: #AA1224;"} ✕
%td.tag_list= aggregate_project.tag_list
%td.count= aggregate_project.projects.count
%td.age= aggregate_project.updated_at.present? ? time_ago_in_words(aggregate_project.updated_at) : "N/A"
%td.actions
= link_to 'Edit', edit_aggregate_project_path(aggregate_project), :class => "btn btn-xs btn-default"
= link_to 'Delete', aggregate_project_path(aggregate_project), :method => :delete, :class =>"btn btn-xs btn-default"
= link_to 'Edit', edit_aggregate_project_path(aggregate_project), class: "btn btn-xs btn-default"
= link_to 'Delete', aggregate_project_path(aggregate_project), method: :delete, class:"btn btn-xs btn-default"
2 changes: 1 addition & 1 deletion app/views/devise/sessions/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%h1 Sign in
%hr
= form_for(resource, :as => resource_name, :url => session_path(resource_name), html: { class: "form-horizontal" }) do |f|
= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "form-horizontal" }) do |f|
.form-group
= f.label :login, 'Login or Email', class: "col-sm-2 control-label"
.col-sm-2
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/builds.rss.builder
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xml.instruct!
xml.rss :version => '2.0' do
xml.rss version: '2.0' do
xml.channel do
xml.title "Project Monitor"
xml.link root_url
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%li
= link_to "Log Out", destroy_user_session_path, method: :delete
.container
%div{:class => "page #{params[:controller]} #{params[:action]}"}
%div{class: "page #{params[:controller]} #{params[:action]}"}
- if flash[:error]
.alert.alert-danger
= flash[:error]
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/home.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= csrf_meta_tag
%script{:src => "//fast.fonts.com/jsapi/14aea2b8-37b7-4a31-afb9-e44414bef419.js", :type => "text/javascript"}
%body{:class => "dashboard tiles_#{@tiles_count}", "data-tiles-count" => @tiles_count}
%script{src: "//fast.fonts.com/jsapi/14aea2b8-37b7-4a31-afb9-e44414bef419.js", type: "text/javascript"}
%body{class: "dashboard tiles_#{@tiles_count}", "data-tiles-count" => @tiles_count}
= yield
#footer
.left
Expand Down
2 changes: 1 addition & 1 deletion app/views/payload_log_entries/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%th Message
%th Backtrace
- @payload_log_entries.each_with_index do |entry, index|
%tr{:class => cycle("odd", "even")}
%tr{class: cycle("odd", "even")}
%td= entry.created_at
%td= entry.status
%td= entry.update_method
Expand Down
6 changes: 3 additions & 3 deletions app/views/projects/_build_setup.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
= f.label field, class: "col-sm-2 control-label"
.col-sm-4
- if field == "tddium_project_name"
= f.text_field field, :disabled => !enabled, placeholder: "repo_name (branch_name)", class: "form-control"
= f.text_field field, disabled: !enabled, placeholder: "repo_name (branch_name)", class: "form-control"
- else
= f.text_field field, :disabled => !enabled, class: "form-control"
= f.text_field field, disabled: !enabled, class: "form-control"
%fieldset#polling
.form-group.verify_ssl_field
.col-sm-offset-2.col-sm-10
Expand Down Expand Up @@ -62,7 +62,7 @@
%span.label.label-success.success.hide OK
%span.label.label-info.pending.hide Loading...
%span.label.label-default.unconfigured.hide Unconfigured
%span.label.label-danger.failure.hide{ :title => project_latest_error(@project) } Error
%span.label.label-danger.failure.hide{ title: project_latest_error(@project) } Error
%span.label.label-warning.empty_fields.hide Some Fields Empty
&nbsp;
%input{ class: 'refresh btn btn-default btn-xs', type: 'button', value: 'Refresh' }
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.form-group
= f.label :aggregate_project_id, "Aggregate Project", class: "col-sm-2 control-label"
.col-sm-3
= collection_select(:project, :aggregate_project_id, AggregateProject.all, :id, :name, {:prompt => false, :disabled => lambda { |ap| !ap.enabled? }, :include_blank => true}, class: "form-control")
= collection_select(:project, :aggregate_project_id, AggregateProject.all, :id, :name, {prompt: false, disabled: lambda { |ap| !ap.enabled? }, include_blank: true}, class: "form-control")
.form-group
:javascript
autocomplete("#project_tag_list", #{ ActsAsTaggableOn::Tag.all.map(&:name) });
Expand Down
4 changes: 2 additions & 2 deletions app/views/projects/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
= link_to '&larr; Back to Projects'.html_safe, edit_configuration_path
%h1 Edit Project
= error_messages_for :project
= form_for(@project, :as => :project, :url => project_path(@project), :html => { :class => "form-horizontal" }) do |f|
= render 'form', :f => f
= form_for(@project, as: :project, url: project_path(@project), html: { class: "form-horizontal" }) do |f|
= render 'form', f: f
4 changes: 2 additions & 2 deletions app/views/projects/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
%h1 Add Project
%hr
= error_messages_for :project
= form_for(@project, :as => :project, :url => projects_path, :html => { :class => "form-horizontal" }) do |f|
= render 'form', :f => f
= form_for(@project, as: :project, url: projects_path, html: { class: "form-horizontal" }) do |f|
= render 'form', f: f
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

ProjectMonitor::Application.config.session_store :cookie_store, :key => '_projectmonitor_session'
ProjectMonitor::Application.config.session_store :cookie_store, key: '_projectmonitor_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
Expand Down
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ProjectMonitor::Application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks", :sessions => "sessions" }
devise_for :users, controllers: { omniauth_callbacks: "omniauth_callbacks", sessions: "sessions" }
mount JasmineRails::Engine => "/specs" if defined?(JasmineRails)

get 'builds' => "home#builds", format: :rss
Expand All @@ -12,7 +12,7 @@
patch 'projects/validate_build_info'

resource :configuration, only: [:show, :create, :edit], controller: "configuration"
resources :users, :only => [:new, :create]
resources :users, only: [:new, :create]
resources :projects do
resources :payload_log_entries, only: :index
resource :status, only: :create, controller: "status"
Expand All @@ -31,9 +31,9 @@
end

authenticate :user do
get "/jobs" => DelayedJobWeb, :anchor => false
get "/jobs" => DelayedJobWeb, anchor: false
end

get 'styleguide' => 'home#styleguide'
root :to => 'home#index'
root to: 'home#index'
end
10 changes: 5 additions & 5 deletions config/schedule.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
every :day, :at => '3:00am' do
rake "truncate:payload_log_entries", :output => "log/payload_log_entries.log"
rake "truncate:project_statuses", :output => "log/project_statuses.log"
rake "dependency:truncate_old_statuses", :output => "log/dependency_statuses.log"
every :day, at: '3:00am' do
rake "truncate:payload_log_entries", output: "log/payload_log_entries.log"
rake "truncate:project_statuses", output: "log/project_statuses.log"
rake "dependency:truncate_old_statuses", output: "log/dependency_statuses.log"
rake "projectmonitor:remove_unused_tags"
end

every 3.minutes do
rake "projectmonitor:fetch_statuses", :output => "log/fetch_statuses.log"
rake "projectmonitor:fetch_statuses", output: "log/fetch_statuses.log"
end

every 1.minute do
Expand Down
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Daley', city: cities.first)
Loading

0 comments on commit a64e863

Please sign in to comment.