Skip to content

Commit

Permalink
project wide ruby 1.8 to ruby 1.9 hash syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
miharekar committed Jul 28, 2014
1 parent eb3981e commit efa897d
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -9,6 +9,6 @@ Elovation::Application.load_tasks
begin
require "rspec/core/rake_task"

task :default => :spec
task default: :spec
rescue LoadError
end
6 changes: 3 additions & 3 deletions app/views/dashboard/show.html.erb
Expand Up @@ -2,7 +2,7 @@

<div class='span8'>
<h1>Elovation Games</h1>
<%= link_to "New Game", new_game_path, :class => "btn btn-primary" %>
<%= link_to "New Game", new_game_path, class: "btn btn-primary" %>

<ul id='games-list'>
<% Game.all.sort_by(&:name).each do |game| %>
Expand Down Expand Up @@ -48,13 +48,13 @@
<div class='span4'>
<div class='well'>
<h2>Players</h2>
<%= link_to "New Player", new_player_path, :class => "btn" %>
<%= link_to "New Player", new_player_path, class: "btn" %>

<ul id='players-list'>
<% Player.all.sort_by(&:name).each do |player| %>
<li class="<%= "active" if @player == player %>">
<%= link_to player_path(player) do %>
<%= image_tag(gravatar_url(player, :size => 24)) %>
<%= image_tag(gravatar_url(player, size: 24)) %>
<%= player.name %>
<% end %>
</li>
Expand Down
30 changes: 15 additions & 15 deletions app/views/games/_form.html.erb
@@ -1,50 +1,50 @@
<%= form_for @game, :html => {class: "form-horizontal"} do |f| %>
<%= form_for @game, html: {class: "form-horizontal"} do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :min_number_of_players_per_team, value: 1, :class => "input-mini" %>
<%= f.hidden_field :min_number_of_teams, value: 2, :class => "input-mini" %>
<%= f.hidden_field :min_number_of_players_per_team, value: 1, class: "input-mini" %>
<%= f.hidden_field :min_number_of_teams, value: 2, class: "input-mini" %>

<h1>New Game</h1>

<div class="control-group">
<%= f.label :name, :class => "control-label" %>
<%= f.label :name, class: "control-label" %>
<div class="controls">
<%= f.text_field :name, :class => "input-xlarge" %>
<%= f.text_field :name, class: "input-xlarge" %>
</div>
</div>

<div class="control-group">
<%= f.label :rating_type, :class => "control-label" %>
<%= f.label :rating_type, class: "control-label" %>
<div class="controls">
<%= f.select :rating_type, Game::RATER_MAPPINGS.map{|k, v| [v.description, k]}, {}, :class => "input-xlarge" %>
<%= f.select :rating_type, Game::RATER_MAPPINGS.map{|k, v| [v.description, k]}, {}, class: "input-xlarge" %>
</div>
</div>

<div class="control-group">
<%= f.label :max_number_of_players_per_team, 'Maximum number of players per team', :class => "control-label" %>
<%= f.label :max_number_of_players_per_team, 'Maximum number of players per team', class: "control-label" %>
<div class="controls">
<%= f.number_field :max_number_of_players_per_team, :class => "input-mini" %>
<%= f.number_field :max_number_of_players_per_team, class: "input-mini" %>
<span class="help-inline">Leave blank for no restriction</span>
</div>
</div>

<div class="control-group">
<%= f.label :max_number_of_teams, 'Maximum number of teams', :class => "control-label" %>
<%= f.label :max_number_of_teams, 'Maximum number of teams', class: "control-label" %>
<div class="controls">
<%= f.number_field :max_number_of_teams, :class => "input-mini" %>
<%= f.number_field :max_number_of_teams, class: "input-mini" %>
<span class="help-inline">Leave blank for no restriction</span>
</div>
</div>

<div class="control-group">
<div class="controls">
<%= f.check_box :allow_ties, :class => "input-mini" %>
<%= f.label :allow_ties, :class => "control-label" %>
<%= f.check_box :allow_ties, class: "input-mini" %>
<%= f.label :allow_ties, class: "control-label" %>
</div>
</div>

<div class="form-actions">
<%= f.submit :class => "btn btn-primary" %>
<%= link_to "Cancel", root_path, :class => "btn btn-warning" %>
<%= f.submit class: "btn btn-primary" %>
<%= link_to "Cancel", root_path, class: "btn btn-warning" %>
</div>

<% end %>
2 changes: 1 addition & 1 deletion app/views/games/_rating.html.erb
@@ -1,7 +1,7 @@
<tr>
<td>
<div class='player'>
<%= image_tag(gravatar_url(rating.player, :size => 24)) %>
<%= image_tag(gravatar_url(rating.player, size: 24)) %>
<%= link_to rating.player.name, player_game_path(rating.player, @game) %>
</div>
</td>
Expand Down
10 changes: 5 additions & 5 deletions app/views/games/show.html.erb
@@ -1,19 +1,19 @@
<h1>Games / <%= @game.name %></h1>

<section class="action-buttons">
<%= link_to 'Edit', edit_game_path(@game), :class => "btn" %>
<%= link_to 'Edit', edit_game_path(@game), class: "btn" %>
<% if @game.results.empty? %>
<%= link_to "Delete", game_path(@game), :method => :delete, :confirm => "Are you sure?", :class => "btn btn-danger" %>
<%= link_to "Delete", game_path(@game), method: :delete, confirm: "Are you sure?", class: "btn btn-danger" %>
<% end %>
</section>

<div class="row-fluid">
<div class="span8">
<h2>Recent Results</h2>
<%= link_to "Add Result", new_game_result_path(@game), :class => "btn btn-primary" %>
<%= link_to "Add Result", new_game_result_path(@game), class: "btn btn-primary" %>
<% if @game.recent_results.any? %>
<%= render :partial => 'shared/results', :object => @game.recent_results, locals: {show_game: false} %>
<%= render partial: 'shared/results', object: @game.recent_results, locals: {show_game: false} %>
<% else %>
<span>No results, play some games!</span>
<% end %>
Expand All @@ -32,7 +32,7 @@
</tr>
</thead>
<tbody>
<%= render :partial => 'rating', :collection => @game.all_ratings.select(&:active?) %>
<%= render partial: 'rating', collection: @game.all_ratings.select(&:active?) %>
</tbody>
</table>
<%= link_to "View All", game_ratings_path(@game) %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Expand Up @@ -6,15 +6,15 @@
<meta name='apple-mobile-web-app-status-bar-style' content='black' />
<meta name='viewport', content='width = device-width, initial-scale = 1, maximum-scale = 1, user-scalable = yes' />

<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div id='container'>
<header>
<%= link_to root_path, :class => "brand" do %>
<%= link_to root_path, class: "brand" do %>
<div class='brand-name'>Elovation</div>
<div class='brand-label'>Home</div>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/player_games/show.html.erb
Expand Up @@ -24,7 +24,7 @@
<tr class="<%= "unplayed" if @player != opponent and wins == 0 and losses == 0 %>" >
<td>
<%= link_to opponent do %>
<%= image_tag(gravatar_url(opponent, :size => 24)) %>
<%= image_tag(gravatar_url(opponent, size: 24)) %>
<%= opponent.name %>
<% end %>
</td>
Expand Down Expand Up @@ -62,7 +62,7 @@
Lost to <strong><%= result.winners.map(&:name).join(", ") %></strong>
<% end %>
<% if result.most_recent? -%>
<%= link_to "Delete", game_result_path(@game, result), :class => "btn btn-danger", :method => :delete, :confirm => "Are you sure?" %>
<%= link_to "Delete", game_result_path(@game, result), class: "btn btn-danger", method: :delete, confirm: "Are you sure?" %>
<% end -%>
</li>
<% end %>
Expand Down
14 changes: 7 additions & 7 deletions app/views/players/_form.html.erb
@@ -1,25 +1,25 @@
<%= form_for @player, :html => {class: "form-horizontal"} do |f| %>
<%= form_for @player, html: {class: "form-horizontal"} do |f| %>
<%= f.error_messages %>

<h1>Player</h1>

<div class="control-group">
<%= f.label :name, :class => "control-label" %>
<%= f.label :name, class: "control-label" %>
<div class="controls">
<%= f.text_field :name, :class => "input-xlarge" %>
<%= f.text_field :name, class: "input-xlarge" %>
</div>
</div>

<div class="control-group">
<%= f.label :email, :class => "control-label" %>
<%= f.label :email, class: "control-label" %>
<div class="controls">
<%= f.text_field :email, :class => "input-xlarge" %>
<%= f.text_field :email, class: "input-xlarge" %>
</div>
</div>

<div class="form-actions">
<%= f.submit :class => "btn btn-primary" %>
<%= link_to "Cancel", root_path, :class => "btn btn-warning" %>
<%= f.submit class: "btn btn-primary" %>
<%= link_to "Cancel", root_path, class: "btn btn-warning" %>
</div>

<small class="description attribution">
Expand Down
10 changes: 5 additions & 5 deletions app/views/players/show.html.erb
@@ -1,28 +1,28 @@
<h1>
<%= image_tag(gravatar_url(@player, :size => 80)) %>
<%= image_tag(gravatar_url(@player, size: 80)) %>
<%= @player.name %>
</h1>

<section class="action-buttons">
<span><%= link_to 'Edit Player', edit_player_path(@player), :class => "btn btn-primary" %></span>
<span><%= link_to 'Edit Player', edit_player_path(@player), class: "btn btn-primary" %></span>
<% if @player.results.empty? %>
<span><%= link_to "Delete", player_path(@player), :method => :delete, :confirm => "Are you sure?", :class => "btn btn-danger" %></span>
<span><%= link_to "Delete", player_path(@player), method: :delete, confirm: "Are you sure?", class: "btn btn-danger" %></span>
<% end %>
</section>

<div class="row-fluid">
<div class="span8">
<h2>Recent Results</h2>
<% if @player.recent_results.any? %>
<%= render :partial => 'shared/results', :object => @player.recent_results, locals: {show_game: true} %>
<%= render partial: 'shared/results', object: @player.recent_results, locals: {show_game: true} %>
<% else %>
<span>No results, play some games!</span>
<% end %>
</div>
<div class="span4">
<h2>Ratings</h2>
<ol>
<%= render :partial => 'rating', :collection => @player.ratings %>
<%= render partial: 'rating', collection: @player.ratings %>
</ol>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/ratings/index.html.erb
Expand Up @@ -14,7 +14,7 @@
</thead>

<tbody>
<%= render :partial => 'games/rating', :collection => @game.all_ratings %>
<%= render partial: 'games/rating', collection: @game.all_ratings %>
</tbody>
</table>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/results/new.html.erb
@@ -1,8 +1,8 @@
<%= form_for [@game, @result], :html => {id: "form-results"} do |f| %>
<%= form_for [@game, @result], html: {id: "form-results"} do |f| %>
<%= f.error_messages %>
<% @result.teams.each.with_index do |team, index| %>
<%= select "result[teams][#{index}]", "players", player_options, {:include_blank => ''}, :class => "players", :multiple => @game.max_number_of_players_per_team != 1, "data-placeholder" => "Team #{index + 1}" %>
<%= select "result[teams][#{index}]", "players", player_options, {include_blank: ''}, class: "players", multiple: @game.max_number_of_players_per_team != 1, "data-placeholder" => "Team #{index + 1}" %>
<% if index != @result.teams.size - 1 %>
<br/>
Expand All @@ -11,7 +11,7 @@
<% end %>

<div class='form-actions'>
<%= f.submit :class => "btn btn-primary", value: 'Save Result' %>
<%= f.submit class: "btn btn-primary", value: 'Save Result' %>
</div>

<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/_result.html.erb
Expand Up @@ -5,7 +5,7 @@
<% team.players.each do |winner| %>
<%= link_to winner, class: 'player' do %>
<%= image_tag(gravatar_url(winner, :size => 16)) %>
<%= image_tag(gravatar_url(winner, size: 16)) %>
<strong> <%= winner.name %></strong>
<% end %>
Expand All @@ -25,7 +25,7 @@


<% if result.most_recent? -%>
<%= link_to "Delete", game_result_path(result.game, result), :class => "btn btn-danger", :method => :delete, :confirm => "Are you sure?" %>
<%= link_to "Delete", game_result_path(result.game, result), class: "btn btn-danger", method: :delete, confirm: "Are you sure?" %>
<% end -%>

</li>
2 changes: 1 addition & 1 deletion app/views/shared/_results.html.erb
@@ -1,3 +1,3 @@
<ol id='results'>
<%= render :partial => 'shared/result', :collection => results, locals: {show_game: show_game} %>
<%= render partial: 'shared/result', collection: results, locals: {show_game: show_game} %>
</ol>
2 changes: 1 addition & 1 deletion config/application.rb
Expand Up @@ -5,7 +5,7 @@

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
Bundler.require(*Rails.groups(assets: %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

Elovation::Application.config.session_store :cookie_store, :key => '_elovation_session'
Elovation::Application.config.session_store :cookie_store, key: '_elovation_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/wrap_parameters.rb
Expand Up @@ -5,7 +5,7 @@

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters :format => [:json]
wrap_parameters format: [:json]
end

# Disable root element in JSON by default.
Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Expand Up @@ -5,9 +5,9 @@
end

resources :players do
resources :games, only: [:show], :controller => 'player_games'
resources :games, only: [:show], controller: 'player_games'
end

get '/dashboard' => 'dashboard#show', as: :dashboard
root :to => 'dashboard#show'
root to: 'dashboard#show'
end
22 changes: 11 additions & 11 deletions db/migrate/001_release_001.rb
@@ -1,35 +1,35 @@
class Release001 < ActiveRecord::Migration
def up
create_table :games do |t|
t.string :name, :null => false
t.string :name, null: false

t.timestamps
end

create_table :players do |t|
t.string :name, :null => false
t.string :name, null: false

t.timestamps
end

create_table :players_results do |t|
t.integer :player_id, :null => false
t.integer :result_id, :null => false
t.integer :player_id, null: false
t.integer :result_id, null: false
end

create_table :ratings do |t|
t.integer :player_id, :null => false
t.integer :game_id, :null => false
t.integer :value, :null => false
t.boolean :pro, :null => false
t.integer :player_id, null: false
t.integer :game_id, null: false
t.integer :value, null: false
t.boolean :pro, null: false

t.timestamps
end

create_table :results do |t|
t.integer :game_id, :null => false
t.integer :loser_id, :null => false
t.integer :winner_id, :null => false
t.integer :game_id, null: false
t.integer :loser_id, null: false
t.integer :winner_id, null: false

t.timestamps
end
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/002_release_002.rb
@@ -1,8 +1,8 @@
class Release002 < ActiveRecord::Migration
def up
create_table :rating_history_events do |t|
t.integer :rating_id, :null => false
t.integer :value, :null => false
t.integer :rating_id, null: false
t.integer :value, null: false

t.timestamps
end
Expand Down
2 changes: 1 addition & 1 deletion db/populate_data.rb
Expand Up @@ -6,6 +6,6 @@
winner = players[rand(5)]
loser = players.reject { |p| p == winner }[rand(4)]

ResultService.create(game, :winner_id => winner.id, :loser_id => loser.id)
ResultService.create(game, winner_id: winner.id, loser_id: loser.id)
end
end

0 comments on commit efa897d

Please sign in to comment.