pgn 0.0.5 → 0.0.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: b0db25b7764a417bbfa3251343eb6276d2a437ba
4
- data.tar.gz: dea50170bb8d9cc50f4d6cbe203c61a6ad4821f5
3
+ metadata.gz: d0a443bf7faed2df357231993215ff3573ec0aa5
4
+ data.tar.gz: 270e148b8e7058f6de567e5109e3dbf701327515
5
5
  SHA512:
6
- metadata.gz: 4dac8be300ff071e21478f75eaf030c1b1b315ff23e75b195f4456eca309cba28ea70facfdc298d9c2f67c8e1a07511022bf517d04ccfb620175e1de80c5917d
7
- data.tar.gz: c32cdb2516e554c60b91d4992f8b495c7e6f0fdc075d9e3a449ab3eb069ec8a0db771c229597f8631635f82ab45f362c12501f4729878dbb087122a8edd194c7
6
+ metadata.gz: 44a48cabb57cb8de5b753b5d6475fda1c9820ce82f3bb088a62cce1c90ff274b67373d7189d8b7f67855e3e7c25c8880a53eb669878d8e94fa350d9cfa57ddef
7
+ data.tar.gz: c3c1609f08f1d0da32a27799e02deb1a4c4e3e56437bc71b9a4e3249ea68a1d04198d36216f2d9fea30ea4815e7a5a17c5ed616b81b15390c09f76417ea1fef7
@@ -40,6 +40,14 @@ module PGN
40
40
  self.result = result
41
41
  end
42
42
 
43
+ # @param moves [Array<String>] a list of moves in SAN
44
+ #
45
+ # Standardize castling moves to use O's instead of 0's
46
+ #
47
+ def moves=(moves)
48
+ @moves = moves.map {|m| m.gsub("0", "O") }
49
+ end
50
+
43
51
  # @return [Array<PGN::Position>] list of the {PGN::Position}s in the game
44
52
  #
45
53
  def positions
@@ -87,7 +87,7 @@ module PGN
87
87
  rule(
88
88
  :san_move => %r{
89
89
  (
90
- O(-O){1,2} | # castling (O-O, O-O-O)
90
+ [O0](-[O0]){1,2} | # castling (O-O, O-O-O)
91
91
  [a-h][1-8] | # pawn moves (e4, d7)
92
92
  [BKNQR][a-h1-8]?x?[a-h][1-8] | # major piece moves w/ optional specifier
93
93
  # and capture
@@ -1,3 +1,3 @@
1
1
  module PGN
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -11,4 +11,16 @@ describe PGN do
11
11
  game.moves.last.should == "Be7#"
12
12
  end
13
13
  end
14
+
15
+ context "alternate castling notation" do
16
+ describe "parsing a file" do
17
+ it "should return a list of games" do
18
+ games = PGN.parse(File.read("./spec/pgn_files/alternate_castling.pgn"))
19
+ game = games.first
20
+ game.tags["White"].should == "Somebody"
21
+ game.result.should == "*"
22
+ game.moves.last.should == "O-O-O"
23
+ end
24
+ end
25
+ end
14
26
  end
@@ -0,0 +1,4 @@
1
+ [White "Somebody"]
2
+ [Black "Somebody Else"]
3
+
4
+ 1.e4 e5 2.Nf3 Nc6 3.Bb5 d6 4.0-0 Bg4 5.Nc3 Qe7 6.d3 0-0-0 *
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stacey Touset
@@ -94,6 +94,7 @@ files:
94
94
  - spec/fen_spec.rb
95
95
  - spec/game_spec.rb
96
96
  - spec/parser_spec.rb
97
+ - spec/pgn_files/alternate_castling.pgn
97
98
  - spec/position_spec.rb
98
99
  - spec/spec_helper.rb
99
100
  homepage: https://github.com/capicue/pgn
@@ -124,6 +125,7 @@ test_files:
124
125
  - spec/fen_spec.rb
125
126
  - spec/game_spec.rb
126
127
  - spec/parser_spec.rb
128
+ - spec/pgn_files/alternate_castling.pgn
127
129
  - spec/position_spec.rb
128
130
  - spec/spec_helper.rb
129
131
  has_rdoc: