tic_tac_toes 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22ba02e7e5275ba82986cd4bc1c0afa6702085e7
4
- data.tar.gz: fddb7424a82204ebc710edb266c25162f46edc9f
3
+ metadata.gz: 77b92da0b3d048f306b6ac300f94e94fcd656ef7
4
+ data.tar.gz: 10497e3ed936e362e8ae20e1e85282b8990e92f7
5
5
  SHA512:
6
- metadata.gz: 04467495e7afeaf413c8b66714e61a4efa22e4da5dbc37ea1d6dfad2e8e0a48584156c274a15130b4ff522c67c834256d335a9c567d890c44f83f2397ec5a2ab
7
- data.tar.gz: a0724449d160d43969c1565c8dc030f40c18d72fdbb313816811387cd4e465eff1432829710fe3eeba818121e0661dce941231ac368833967d39d9e8c5bf1297
6
+ metadata.gz: d33321f395dae4c693c0610a51b998d7b606bc00408ffe65cfcc305f8f06278f5bf09085ea1de4d7a4556fe80ad0a302a4c006c2a887f8b31db59dacb3ee4983
7
+ data.tar.gz: 5e7f86e90489fdc057a6804b77e85ed2ba067c189585d9d813051abbc2e5d5bae2dc34a270a2b9c3d477e8a92ed20fab08d82b17c36114434eb3e5917ee10473
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tic_tac_toes (0.1.3)
4
+ tic_tac_toes (0.1.4)
5
5
  pg
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -12,4 +12,9 @@ The game Tic-tac-toe, featuring an unbeatable AI.
12
12
  * To drop the databases: `destroy_ttt_databases`
13
13
  4. Launch the game: `tic_tac_toes`
14
14
 
15
+ ## Rake tasks
16
+ * `rake` runs the specs
17
+ * `rake set_up_databases` sets up production and test databases
18
+ * `rake destroy_databases` tears down production and test databases
19
+
15
20
  [PostgreSQL]: http://www.postgresql.org
data/Rakefile CHANGED
@@ -1,4 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
2
3
 
3
4
  load './lib/tic_tac_toes/tasks/set_up_databases.rake'
4
5
  load './lib/tic_tac_toes/tasks/destroy_databases.rake'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require 'tic_tac_toes/database/pg_wrapper'
6
+ require 'tic_tac_toes/command_line/history_reader'
7
+
8
+ database = 'tic_tac_toes'
9
+
10
+ wrapper = TicTacToes::Database::PGWrapper.new(database)
11
+ reader = TicTacToes::CommandLine::HistoryReader.new(wrapper)
12
+
13
+ reader.display_game_histories
data/bin/tic_tac_toes CHANGED
@@ -13,7 +13,7 @@ require 'tic_tac_toes/core/history'
13
13
 
14
14
  require 'tic_tac_toes/command_line/runner'
15
15
 
16
- database = "tic_tac_toes"
16
+ database = 'tic_tac_toes'
17
17
 
18
18
  prompt = TicTacToes::CommandLine::Prompt
19
19
  io = TicTacToes::Core::IO.new(prompt)
@@ -1,6 +1,6 @@
1
1
  require 'pg'
2
2
 
3
- desc 'Drop tic_tac_toes databases'
3
+ desc 'Drop Tic_tac_toes production and test databases'
4
4
  task :destroy_databases do
5
5
  connection = PG.connect(dbname: "postgres")
6
6
 
@@ -3,38 +3,28 @@ require 'pg'
3
3
  PRODUCTION_DATABASE = 'tic_tac_toes'
4
4
  TEST_DATABASE = 'tic_tac_toes_test'
5
5
 
6
- desc 'Set up tic_tac_toes databases'
6
+ desc 'Set up tic_tac_toes production and test databases'
7
7
  task :set_up_databases do
8
- create_databases_if_not_exist
9
- create_production_tables_if_not_exist
8
+ create_databases
9
+ create_production_tables
10
10
  end
11
11
 
12
- def create_databases_if_not_exist
12
+ def create_databases
13
13
  connection = PG.connect(dbname: "postgres")
14
14
 
15
- connection.exec("CREATE DATABASE #{PRODUCTION_DATABASE}") unless already_exists?(PRODUCTION_DATABASE, connection)
16
- connection.exec("CREATE DATABASE #{TEST_DATABASE}") unless already_exists?(TEST_DATABASE, connection)
15
+ connection.exec("CREATE DATABASE #{PRODUCTION_DATABASE}")
16
+ connection.exec("CREATE DATABASE #{TEST_DATABASE}")
17
17
  end
18
18
 
19
- def already_exists?(database, connection)
20
- existing_ttt_database_result = connection.exec("SELECT COUNT(*) FROM pg_database WHERE datname = '#{database}'")
21
- number_of_existing_ttt_databases = existing_ttt_database_result.getvalue(0,0).to_i
22
-
23
- number_of_existing_ttt_databases == 1 ? true : false
24
- end
25
-
26
- def create_production_tables_if_not_exist
19
+ def create_production_tables
27
20
  connection = PG.connect(dbname: "#{PRODUCTION_DATABASE}")
28
21
 
29
- # Suppress "already exist" notices
30
- connection.exec("set client_min_messages=warning")
31
-
32
- connection.exec("CREATE TABLE IF NOT EXISTS games (
22
+ connection.exec("CREATE TABLE games (
33
23
  id serial primary key,
34
24
  board_size integer,
35
25
  difficulty varchar,
36
26
  winner varchar)")
37
- connection.exec("CREATE TABLE IF NOT EXISTS moves (
27
+ connection.exec("CREATE TABLE moves (
38
28
  game integer REFERENCES games (id),
39
29
  number integer,
40
30
  token varchar,
@@ -1,3 +1,3 @@
1
1
  module TicTacToes
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tic_tac_toes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Spatafora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-25 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,6 +84,7 @@ files:
84
84
  - README.md
85
85
  - Rakefile
86
86
  - bin/destroy_ttt_databases
87
+ - bin/game_histories
87
88
  - bin/set_up_ttt_databases
88
89
  - bin/tic_tac_toes
89
90
  - lib/tic_tac_toes/command_line/history_reader.rb