Skip to content

Panda and Tiger #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GEM
i18n (0.6.0)
multi_json (1.3.4)
pg (0.13.2)
pg (0.13.2-x86-mingw32)
rake (0.9.2.2)
rspec (2.9.0)
rspec-core (~> 2.9.0)
Expand All @@ -31,6 +32,7 @@ GEM

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
activerecord
Expand Down
6 changes: 0 additions & 6 deletions config/database.yml.sample

This file was deleted.

10 changes: 10 additions & 0 deletions db/migrate/001_create_games.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateGames < ActiveRecord::Migration
def change
create_table :games do |t|
t.string :name
t.string :designer
t.integer :players_min
t.integer :players_max
end
end
end
13 changes: 13 additions & 0 deletions db/migrate/002_create_publishers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CreatePublishers < ActiveRecord::Migration
def change
create_table :publishers do |t|
t.string :name
t.timestamps
end

change_table :games do |t|
t.references :publisher
t.timestamps
end
end
end
9 changes: 0 additions & 9 deletions db/migrate/201205031230_create_shows.rb

This file was deleted.

13 changes: 0 additions & 13 deletions db/migrate/201205031300_create_networks.rb

This file was deleted.

17 changes: 11 additions & 6 deletions db/seed.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Cleaning Out
Network.delete_all
Show.delete_all
amc = Network.create(name: "AMC")
nbc = Network.create(name: "NBC")
Show.create(name: "Mad Men", day_of_week: "Sunday", hour_of_day: 22, network: amc)
Show.create(name: "Community", day_of_week: "Thursday", hour_of_day: 20, network: nbc)
Publisher.delete_all
Game.delete_all
ffg = Publisher.create(name: "Fantasy Flight Games")
slg = Publisher.create(name: "Sirlin Games")
zmg = Publisher.create(name: "Z-Man Games")

Game.create(name: "Mansions of Madness", players_min: 2, players_max: 5, designer: "Corey Konieczka", publisher: ffg)
Game.create(name: "Android: Infiltration", players_min: 2, players_max: 6, designer: "Donald X. Vaccarino", publisher: ffg)
Game.create(name: "Puzzle Strike", players_min: 2, players_max: 4, designer: "David Sirlin", publisher: slg)
Game.create(name: "Flash Duel", players_min: 1, players_max: 5, designer: "David Sirlin", publisher: slg)
Game.create(name: "Pandemic", players_min: 2, players_max: 4, designer: "Matt Leacock", publisher: zmg)
9 changes: 9 additions & 0 deletions models/game.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Game < ActiveRecord::Base
belongs_to :publisher

validates_presence_of :name

def to_s
"#{designer}'s \"#{name}\" for #{players_min}-#{players_max} players published by #{publisher}." # is for #{hour_of_day}:#{day_of_week}:00 on #{network} "
end
end
7 changes: 0 additions & 7 deletions models/network.rb

This file was deleted.

7 changes: 7 additions & 0 deletions models/publisher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Publisher < ActiveRecord::Base
has_many :games

def to_s
name
end
end
9 changes: 0 additions & 9 deletions models/show.rb

This file was deleted.

17 changes: 10 additions & 7 deletions watchman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
Dir.glob('./models/*').each { |r| require r}
require "./db/seed"

puts "There are #{Show.count} in the database"

Network.all.each do |network|
puts "Shows airing on #{network}"
network.shows.each do |show|
puts show
end
puts "There are #{Game.count} games in the database:"
Game.all.each do |game|
puts game
end

puts "\nHow many players do you have? (Enter 1-6)"
player_count = gets.chomp().to_i
puts "\nGames for #{player_count} player(s):"
Game.all.each do |game|
puts game if game.players_min <= player_count && game.players_max >= player_count
end