pgn 0.2.0 → 0.3.0

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
- SHA1:
3
- metadata.gz: a5c9a8ca0a6c732bd3ec99585b21929c1710976e
4
- data.tar.gz: ff812fc594259ffa25370d3e35eed074c56a3c41
2
+ SHA256:
3
+ metadata.gz: eab5d5a85ab1fd83ffdda01cd47ff6d607f984e37ab1d6390b46c5a07b98d9d1
4
+ data.tar.gz: 1e37325c1c5c2c8798736664031d042435915191f0b0e41fac615591a166467b
5
5
  SHA512:
6
- metadata.gz: 05e7faa858c9ee725416c0c87021ac2b3440407b41de732ce6049f446ede8736e039c7f0a8658cba5dced9c6d27a07ad50e0c176e04afbede60cb959c2d267a9
7
- data.tar.gz: c5d008c3d2d579dd39b3ab76889cf697252d12eac55f5cab69665dd04b2cbc03227de4487325a476a45b1fe9a435e1fb41ad775b456fd5e5b5297fafc4624cbe
6
+ metadata.gz: ef297392b415924de383a0956c74368ffb07170d35a59f07cbfc9193077990c173b4907266978b6076c41b71b731291740ce5c4f2e981568ea923117f090a567
7
+ data.tar.gz: f797d168a2807170f543ca6d4e0a0a043b0f4188de5283f949f9f77cc9640ac8961c42dcad5f37dc5b68767b31306b39475f02ff168361f765c7c0da11311406
@@ -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 = PGN::Position.start
95
+ position = starting_position
88
96
  arr = [position]
89
97
  self.moves.each do |move|
90
98
  new_pos = position.move(move.notation)
@@ -1,3 +1,3 @@
1
1
  module PGN
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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.2.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: 2017-02-27 00:00:00.000000000 Z
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
- rubyforge_project:
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