pgn 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/pgn/game.rb +9 -1
- data/lib/pgn/version.rb +1 -1
- data/spec/parser_spec.rb +10 -0
- data/spec/pgn_files/fen.pgn +12 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eab5d5a85ab1fd83ffdda01cd47ff6d607f984e37ab1d6390b46c5a07b98d9d1
|
4
|
+
data.tar.gz: 1e37325c1c5c2c8798736664031d042435915191f0b0e41fac615591a166467b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef297392b415924de383a0956c74368ffb07170d35a59f07cbfc9193077990c173b4907266978b6076c41b71b731291740ce5c4f2e981568ea923117f090a567
|
7
|
+
data.tar.gz: f797d168a2807170f543ca6d4e0a0a043b0f4188de5283f949f9f77cc9640ac8961c42dcad5f37dc5b68767b31306b39475f02ff168361f765c7c0da11311406
|
data/lib/pgn/game.rb
CHANGED
@@ -80,11 +80,19 @@ module PGN
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
def starting_position
|
84
|
+
@starting_position ||= if fen = (self.tags && self.tags['FEN'])
|
85
|
+
PGN::FEN.new(fen).to_position
|
86
|
+
else
|
87
|
+
PGN::Position.start
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
83
91
|
# @return [Array<PGN::Position>] list of the {PGN::Position}s in the game
|
84
92
|
#
|
85
93
|
def positions
|
86
94
|
@positions ||= begin
|
87
|
-
position =
|
95
|
+
position = starting_position
|
88
96
|
arr = [position]
|
89
97
|
self.moves.each do |move|
|
90
98
|
new_pos = position.move(move.notation)
|
data/lib/pgn/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -80,5 +80,15 @@ describe PGN do
|
|
80
80
|
variation.size.should == 2
|
81
81
|
variation[0].should == 'Nxf3'
|
82
82
|
end
|
83
|
+
|
84
|
+
|
85
|
+
it 'should handle files with starting position' do
|
86
|
+
games = PGN.parse(File.read('./spec/pgn_files/fen.pgn'))
|
87
|
+
game = games.first
|
88
|
+
first_pos = game.positions.first
|
89
|
+
last_pos = game.positions.last
|
90
|
+
first_pos.to_fen.to_s.should == game.tags['FEN']
|
91
|
+
last_pos.to_fen.to_s.should == '5rkn/5p1p/2b2NpP/8/2B5/1P6/2PP3P/1K6 b - - 0 4'
|
92
|
+
end
|
83
93
|
end
|
84
94
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
[Event "Event 1"]
|
2
|
+
[Site "?"]
|
3
|
+
[Date "????.??.??"]
|
4
|
+
[Round "?"]
|
5
|
+
[White "Walt Whiteman"]
|
6
|
+
[Black "Simon Schwartz"]
|
7
|
+
[Result "1-0"]
|
8
|
+
[SetUp "1"]
|
9
|
+
[FEN "4brkn/4bp1p/3q2pP/8/2B3N1/1P4N1/2PP3P/1K2Q3 w - - 0 1"]
|
10
|
+
[PlyCount "7"]
|
11
|
+
|
12
|
+
1. Qxe7 Qxe7 2. Ne4 Bc6 3. Nef6+ Qxf6 4. Nxf6# 1-0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stacey Touset
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: whittle
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- spec/pgn_files/annotations.pgn
|
99
99
|
- spec/pgn_files/comments.pgn
|
100
100
|
- spec/pgn_files/empty_variation_move.pgn
|
101
|
+
- spec/pgn_files/fen.pgn
|
101
102
|
- spec/pgn_files/multiline_comments.pgn
|
102
103
|
- spec/pgn_files/nested_comments.pgn
|
103
104
|
- spec/pgn_files/test.pgn
|
@@ -123,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.5.1
|
127
|
+
rubygems_version: 3.0.3
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: A PGN parser for Ruby
|
@@ -136,6 +136,7 @@ test_files:
|
|
136
136
|
- spec/pgn_files/annotations.pgn
|
137
137
|
- spec/pgn_files/comments.pgn
|
138
138
|
- spec/pgn_files/empty_variation_move.pgn
|
139
|
+
- spec/pgn_files/fen.pgn
|
139
140
|
- spec/pgn_files/multiline_comments.pgn
|
140
141
|
- spec/pgn_files/nested_comments.pgn
|
141
142
|
- spec/pgn_files/test.pgn
|