Skip to content

Commit

Permalink
Changing 'game' model to 'table' model to better encapsulate concepts
Browse files Browse the repository at this point in the history
now we have a game_type for a table
  • Loading branch information
Ben Feigin committed Feb 16, 2012
1 parent 365a9ff commit 1013774
Show file tree
Hide file tree
Showing 29 changed files with 232 additions and 174 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ gem 'database_cleaner', :group => "test"
# Padrino Stable Gem
gem 'padrino', '0.10.5'


# Or Padrino Edge
# gem 'padrino', :git => 'git://github.com/padrino/padrino-framework.git'

# Or Individual Gems
# %w(core gen helpers cache mailer admin).each do |g|
# gem 'padrino-' + g, '0.10.5'
# end
group :development do
gem 'guard'
gem 'rb-readline'
end
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ GEM
diff-lcs (1.1.3)
factory_girl (2.5.2)
activesupport (>= 2.3.9)
ffi (1.0.11)
grit (2.4.1)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
guard (1.0.0)
ffi (>= 0.5.0)
thor (~> 0.14.6)
haml (3.1.4)
http_router (0.10.2)
rack (>= 1.0.0)
Expand Down Expand Up @@ -68,6 +72,7 @@ GEM
rack-test (0.6.1)
rack (>= 1.0)
rake (0.9.2.2)
rb-readline (0.4.2)
rspec (2.8.0)
rspec-core (~> 2.8.0)
rspec-expectations (~> 2.8.0)
Expand Down Expand Up @@ -100,10 +105,12 @@ DEPENDENCIES
bcrypt-ruby
database_cleaner
factory_girl
guard
haml
padrino (= 0.10.5)
rack-test
rake
rb-readline
rspec
sinatra-flash
sqlite3
23 changes: 23 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end


guard :bundler do
watch('Gemfile')
end
2 changes: 1 addition & 1 deletion admin/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Admin < Padrino::Application
access_control.roles_for :admin do |role|
role.project_module :actions, "/actions"
role.project_module :hands, "/hands"
role.project_module :games, "/games"
role.project_module :tables, "/tables"
role.project_module :players, "/players"
role.project_module :tournaments, "/tournaments"
role.project_module :accounts, "/accounts"
Expand Down
47 changes: 0 additions & 47 deletions admin/controllers/games.rb

This file was deleted.

47 changes: 47 additions & 0 deletions admin/controllers/tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Admin.controllers :tables do

get :index do
@tables = Game.all
render 'tables/index'
end

get :new do
@table = Game.new
render 'tables/new'
end

post :create do
@table = Game.new(params[:table])
if @table.save
flash[:notice] = 'Game was successfully created.'
redirect url(:tables, :edit, :id => @table.id)
else
render 'tables/new'
end
end

get :edit, :with => :id do
@table = Game.find(params[:id])
render 'tables/edit'
end

put :update, :with => :id do
@table = Game.find(params[:id])
if @table.update_attributes(params[:table])
flash[:notice] = 'Game was successfully updated.'
redirect url(:tables, :edit, :id => @table.id)
else
render 'tables/edit'
end
end

delete :destroy, :with => :id do
table = Game.find(params[:id])
if table.destroy
flash[:notice] = 'Game was successfully destroyed.'
else
flash[:error] = 'Unable to destroy Game!'
end
redirect url(:tables, :index)
end
end
6 changes: 3 additions & 3 deletions admin/views/actions/_form.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.group
=f.label :game_id
=f.error_message_on :game_id
=f.text_field :game_id, :class => :text_field
=f.label :table_id
=f.error_message_on :table_id
=f.text_field :table_id, :class => :text_field
%span.description Ex: a simple text

.group
Expand Down
4 changes: 2 additions & 2 deletions admin/views/actions/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%table.table
%tr
%th.first=mat(:action, :id)
%th=mat(:action, :game_id)
%th=mat(:action, :table_id)
%th=mat(:action, :betting_round)
%th=mat(:action, :turn_number)
%th=mat(:action, :action)
Expand All @@ -21,7 +21,7 @@
-@actions.each do |action|
%tr
%td.first=action.id
%td=action.game_id
%td=action.table_id
%td=action.betting_round
%td=action.turn_number
%td=action.action
Expand Down
15 changes: 0 additions & 15 deletions admin/views/games/edit.haml

This file was deleted.

33 changes: 0 additions & 33 deletions admin/views/games/index.haml

This file was deleted.

14 changes: 0 additions & 14 deletions admin/views/games/new.haml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

.group.navform.wat-cf
=f.submit pat(:save), :class => :button
=f.submit pat(:cancel), :onclick => "window.location='#{url(:games, :index)}';return false", :class => :button
=f.submit pat(:cancel), :onclick => "window.location='#{url(:tables, :index)}';return false", :class => :button
15 changes: 15 additions & 0 deletions admin/views/tables/edit.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first=link_to pat(:list), url(:tables, :index)
%li=link_to pat(:new), url(:tables, :new)
%li.active=link_to pat(:edit), url(:tables, :edit, :id => @table.id)
.content
%h2.title
=pat(:edit)
=mt(:table)
.inner
-form_for :table, url(:tables, :update, :id => @table.id), :method => :put, :class => :form do |f|
=partial "tables/form", :locals => { :f => f }

-content_for :sidebar, partial("base/sidebar")
33 changes: 33 additions & 0 deletions admin/views/tables/index.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first.active=link_to pat(:list), url(:tables, :index)
%li=link_to pat(:new), url(:tables, :new)
.content
%h2.title
=pat(:all)
=mt(:tables)
.inner
%table.table
%tr
%th.first=mat(:table, :id)
%th=mat(:table, :tournament_id)
%th=mat(:table, :betting_round)
%th=mat(:table, :turn)
%th=mat(:table, :action_to)
%th.last="&nbsp;"
-@tables.each do |table|
%tr
%td.first=table.id
%td=table.tournament_id
%td=table.betting_round
%td=table.turn
%td=table.action_to
%td.last
=button_to pat(:edit), url(:tables, :edit, :id => table.id), :method => :get, :class => :button_to
="|"
=button_to pat(:delete), url(:tables, :destroy, :id => table.id), :method => :delete, :class => :button_to, :onsubmit => "return confirm('#{pat(:confirm)}')"
.actions-bar.wat-cf
.actions="&nbsp;"

-content_for :sidebar, partial("base/sidebar")
14 changes: 14 additions & 0 deletions admin/views/tables/new.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first=link_to pat(:list), url(:tables, :index)
%li.active=link_to pat(:new), url(:tables, :new)
.content
%h2.title
=pat(:new)
=mt(:table)
.inner
-form_for :table, url(:tables, :create), :class => :form do |f|
=partial "tables/form", :locals => { :f => f }

-content_for :sidebar, partial("base/sidebar")
Binary file removed db/enova_poker_development.db
Binary file not shown.
Empty file removed db/enova_poker_production.db
Empty file.
Loading

0 comments on commit 1013774

Please sign in to comment.