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 +4 -4
- data/lib/pgn/game.rb +8 -0
- data/lib/pgn/parser.rb +1 -1
- data/lib/pgn/version.rb +1 -1
- data/spec/parser_spec.rb +12 -0
- data/spec/pgn_files/alternate_castling.pgn +4 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0a443bf7faed2df357231993215ff3573ec0aa5
|
4
|
+
data.tar.gz: 270e148b8e7058f6de567e5109e3dbf701327515
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a48cabb57cb8de5b753b5d6475fda1c9820ce82f3bb088a62cce1c90ff274b67373d7189d8b7f67855e3e7c25c8880a53eb669878d8e94fa350d9cfa57ddef
|
7
|
+
data.tar.gz: c3c1609f08f1d0da32a27799e02deb1a4c4e3e56437bc71b9a4e3249ea68a1d04198d36216f2d9fea30ea4815e7a5a17c5ed616b81b15390c09f76417ea1fef7
|
data/lib/pgn/game.rb
CHANGED
@@ -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
|
data/lib/pgn/parser.rb
CHANGED
@@ -87,7 +87,7 @@ module PGN
|
|
87
87
|
rule(
|
88
88
|
:san_move => %r{
|
89
89
|
(
|
90
|
-
|
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
|
data/lib/pgn/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -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
|
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.
|
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:
|