tic_tac_toe_mchliakh 0.1.5 → 0.1.6

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: 2c9bad45490fc64cbffaee6614650fcb4c95ed96
4
- data.tar.gz: 4d479d0e2e687f21239a9d2549af3be166882f5e
3
+ metadata.gz: aec0542c8caab3c801c94ec1bbaff4476d08f3b1
4
+ data.tar.gz: 5e49e29ca68ee0e4293ffc8bc58b9e6724038ff4
5
5
  SHA512:
6
- metadata.gz: ba75837c2e15829ff111195acb10e4436c8fc7e9db2f1e476007540789ca024f71be17f27a5314a0e73ed007a3bb8f1b6d1310bf8aa82a2391bff4c991b4cee2
7
- data.tar.gz: 8477aeac27e9b641d06855ca45222702a0bfbf651df7b7e14b76327cac0e5aeda998042a461dbb32d0e4b4a2d55adb3ec0ca56a0a28113aef422968191a9d5a2
6
+ metadata.gz: 428e92da2fb3cfa4468d3300a023635406540f656534ce982e793152cecba4f42a687363aa79c96eeab187edb007252c39f009281229a05d5af62dd29ead1285
7
+ data.tar.gz: 03e8257aafcfb276ce8f6e5bc8ebb2107e4cc8d0247e04514a9d63bc820a45a396f7d205db4ca60b4b1f94b610beba19b9a713f41cfbafce0f3a2b8448415709
data/README.md CHANGED
@@ -29,7 +29,7 @@ class GamesController < ApplicationController
29
29
  def move
30
30
  game = Game.find(params[:id])
31
31
 
32
- result = TicTacToeMchliakh.move(square, game.board)
32
+ result = TicTacToe.move(square, game.board)
33
33
 
34
34
  if result[:board]
35
35
  game.update_attributes(board: result[:board])
@@ -6,7 +6,7 @@ require 'tic_tac_toe_mchliakh/board/board'
6
6
  require 'tic_tac_toe_mchliakh/players/player'
7
7
  require 'tic_tac_toe_mchliakh/players/computer'
8
8
 
9
- module TicTacToeMchliakh
9
+ module TicTacToe
10
10
  def self.move(square, saved_board=nil)
11
11
  square = square.to_i
12
12
  saved_board.map! {|s| s.to_i if s } if saved_board
@@ -1,4 +1,4 @@
1
- module TicTacToeMchliakh
1
+ module TicTacToe
2
2
  class Board
3
3
  attr_reader :squares, :lines, :winner
4
4
 
@@ -1,4 +1,4 @@
1
- module TicTacToeMchliakh
1
+ module TicTacToe
2
2
  class Line
3
3
  attr_reader :squares
4
4
 
@@ -1,4 +1,4 @@
1
- module TicTacToeMchliakh
1
+ module TicTacToe
2
2
  class Lines < Array
3
3
  def can_win(player)
4
4
  select {|l| l.can_win?(player) }
@@ -1,4 +1,4 @@
1
- module TicTacToeMchliakh
1
+ module TicTacToe
2
2
  class IllegalMoveError < StandardError; end
3
3
 
4
4
  class Square
@@ -1,4 +1,4 @@
1
- module TicTacToeMchliakh
1
+ module TicTacToe
2
2
  class Squares < Array
3
3
  def empty
4
4
  select(&:empty?)
@@ -1,4 +1,4 @@
1
- module TicTacToeMchliakh
1
+ module TicTacToe
2
2
  class Computer < Player
3
3
  def next_move
4
4
  line = any_winning_line || any_losing_line
@@ -1,4 +1,4 @@
1
- module TicTacToeMchliakh
1
+ module TicTacToe
2
2
  class Player
3
3
  def initialize(board, number)
4
4
  @board, @number = board, number
@@ -1,3 +1,3 @@
1
- module TicTacToeMchliakh
2
- VERSION = '0.1.5'
1
+ module TicTacToe
2
+ VERSION = '0.1.6'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TicTacToeMchliakh
3
+ module TicTacToe
4
4
  describe Board do
5
5
  before do
6
6
  @board = Board.new
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TicTacToeMchliakh
3
+ module TicTacToe
4
4
  describe Line do
5
5
  before do
6
6
  @square = Square.new(nil, 0, 123)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TicTacToeMchliakh
3
+ module TicTacToe
4
4
  describe Lines do
5
5
  before do
6
6
  @board = Board.new([
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TicTacToeMchliakh
3
+ module TicTacToe
4
4
  describe Square do
5
5
  before do
6
6
  @board = double()
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TicTacToeMchliakh
3
+ module TicTacToe
4
4
  describe Squares do
5
5
  before do
6
6
  @squares = Squares.new
@@ -1,31 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TicTacToeMchliakh
4
- describe TicTacToeMchliakh do
3
+ module TicTacToe
4
+ describe TicTacToe do
5
5
  it 'makes a move' do
6
- expect(TicTacToeMchliakh.move(1)[:board].compact.sort)
6
+ expect(TicTacToe.move(1)[:board].compact.sort)
7
7
  .to eq([0, 1])
8
8
  end
9
9
 
10
10
  it 'accepts string input for the square' do
11
- expect(TicTacToeMchliakh.move(' 1')[:board].compact.sort)
11
+ expect(TicTacToe.move(' 1')[:board].compact.sort)
12
12
  .to eq([0, 1])
13
13
  end
14
14
 
15
15
  it 'makes a move on a saved board' do
16
16
  board = [nil, nil, nil, 1, 0, nil, nil, nil, nil]
17
- expect(TicTacToeMchliakh.move(1, board)[:board].compact.sort)
17
+ expect(TicTacToe.move(1, board)[:board].compact.sort)
18
18
  .to eq([0, 0, 1, 1])
19
19
  end
20
20
 
21
21
  it 'makes accepts string input for the saved board' do
22
22
  board = [nil, nil, nil, '1', '0', nil, nil, nil, nil]
23
- expect(TicTacToeMchliakh.move(1, board)[:board].compact.sort)
23
+ expect(TicTacToe.move(1, board)[:board].compact.sort)
24
24
  .to eq([0, 0, 1, 1])
25
25
  end
26
26
 
27
27
  it 'returns an error when desired square is taken' do
28
- expect(TicTacToeMchliakh.move(1, Array.new(9, 0)))
28
+ expect(TicTacToe.move(1, Array.new(9, 0)))
29
29
  .to have_key(:error)
30
30
  end
31
31
  end
@@ -5,7 +5,7 @@ require 'tic_tac_toe_mchliakh/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'tic_tac_toe_mchliakh'
8
- s.version = TicTacToeMchliakh::VERSION
8
+ s.version = TicTacToe::VERSION
9
9
  s.authors = ['Mikhail Chliakhovski']
10
10
  s.email = ['mchliakh.dev@gmail.com']
11
11
  s.summary = 'Tic-tac-toe'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tic_tac_toe_mchliakh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Chliakhovski