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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/Rakefile +5 -0
- data/bin/game_histories +13 -0
- data/bin/tic_tac_toes +1 -1
- data/lib/tic_tac_toes/tasks/destroy_databases.rake +1 -1
- data/lib/tic_tac_toes/tasks/set_up_databases.rake +9 -19
- data/lib/tic_tac_toes/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b92da0b3d048f306b6ac300f94e94fcd656ef7
|
4
|
+
data.tar.gz: 10497e3ed936e362e8ae20e1e85282b8990e92f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d33321f395dae4c693c0610a51b998d7b606bc00408ffe65cfcc305f8f06278f5bf09085ea1de4d7a4556fe80ad0a302a4c006c2a887f8b31db59dacb3ee4983
|
7
|
+
data.tar.gz: 5e7f86e90489fdc057a6804b77e85ed2ba067c189585d9d813051abbc2e5d5bae2dc34a270a2b9c3d477e8a92ed20fab08d82b17c36114434eb3e5917ee10473
|
data/Gemfile.lock
CHANGED
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
data/bin/game_histories
ADDED
@@ -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
@@ -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
|
-
|
9
|
-
|
8
|
+
create_databases
|
9
|
+
create_production_tables
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def create_databases
|
13
13
|
connection = PG.connect(dbname: "postgres")
|
14
14
|
|
15
|
-
connection.exec("CREATE DATABASE #{PRODUCTION_DATABASE}")
|
16
|
-
connection.exec("CREATE DATABASE #{TEST_DATABASE}")
|
15
|
+
connection.exec("CREATE DATABASE #{PRODUCTION_DATABASE}")
|
16
|
+
connection.exec("CREATE DATABASE #{TEST_DATABASE}")
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
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
|
-
|
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
|
27
|
+
connection.exec("CREATE TABLE moves (
|
38
28
|
game integer REFERENCES games (id),
|
39
29
|
number integer,
|
40
30
|
token varchar,
|
data/lib/tic_tac_toes/version.rb
CHANGED
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.
|
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-
|
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
|