feen 3.0.2 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a0c53a0d0d53b43e1cb9f06511fe1c7bc3eee6c6552c4902b140133c32cc754
4
- data.tar.gz: 843631005e3047239e98d485907bf57870dc56e45f4aa2848bf37976dd53e00d
3
+ metadata.gz: 59e59d257cf32a7580d7a751f27046a94dc4cc042237d165a2a941d34928c0c5
4
+ data.tar.gz: d17e95bad6d8868e37f1a2dab71d198f44b9fd742400bb70d3f314b8e79c2155
5
5
  SHA512:
6
- metadata.gz: efe66d045a3780bd4ec5e019f15e4e3302a42984a360c49e583d7e7f4ddf5fd9b13fefdc0807d8c2134fb87ac7c518fcae04bf91be8dc8dfdfef51c9dbb40f92
7
- data.tar.gz: 7a003e96f398ac8c2d63f7164e182c3f6b36183f5dd1eb74e030bbeb77f54965b4922664d78766336b17a44cc0c3e87819c21976c32874724d57e8ea66da87ee
6
+ metadata.gz: d32ac92d63927327f269559bbafe824265504981178ace24f748ec3201f274669802ea3658c813df3747d5b66cbfb183de92fa9aa57444b807a6f3a5989d1fc7
7
+ data.tar.gz: 6352db3b19a703f15102ccba19bb8491605307575a901d862fa19df550558af37610d9ed720afe865975f4e7701b85efae55fcfbab9539786c03c1ec7d780921
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Sashite
3
+ Copyright (c) 2020-2021 Sashite
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # FEEN.rb
2
2
 
3
- [![Build Status](https://travis-ci.org/sashite/feen.rb.svg?branch=master)](https://travis-ci.org/sashite/feen.rb)
4
- [![Documentation](https://img.shields.io/:yard-docs-38c800.svg)](https://rubydoc.info/gems/feen/frames)
3
+ [![Version](https://img.shields.io/github/v/tag/sashite/feen.rb?label=Version&logo=github)](https://github.com/sashite/feen.rb/releases)
4
+ [![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/sashite/feen.rb/main)
5
+ [![CI](https://github.com/sashite/feen.rb/workflows/CI/badge.svg?branch=main)](https://github.com/sashite/feen.rb/actions?query=workflow%3Aci+branch%3Amain)
6
+ [![RuboCop](https://github.com/sashite/feen.rb/workflows/RuboCop/badge.svg?branch=main)](https://github.com/sashite/feen.rb/actions?query=workflow%3Arubocop+branch%3Amain)
7
+ [![License](https://img.shields.io/github/license/sashite/feen.rb?label=License&logo=github)](https://github.com/sashite/feen.rb/raw/main/LICENSE.md)
5
8
 
6
9
  > __FEEN__ (Forsyth–Edwards Expanded Notation) support for the Ruby language.
7
10
 
@@ -20,16 +23,20 @@ More exotic variants are also supported, like: [Dai dai shogi](https://en.wikipe
20
23
  Add this line to your application's Gemfile:
21
24
 
22
25
  ```ruby
23
- gem 'feen'
26
+ gem "feen"
24
27
  ```
25
28
 
26
29
  And then execute:
27
30
 
28
- $ bundle
31
+ ```sh
32
+ bundle
33
+ ```
29
34
 
30
35
  Or install it yourself as:
31
36
 
32
- $ gem install feen
37
+ ```sh
38
+ gem install feen
39
+ ```
33
40
 
34
41
  ## Usage
35
42
 
@@ -38,39 +45,22 @@ require "feen"
38
45
 
39
46
  # Dump a classic Tsume Shogi problem
40
47
  FEEN.dump(
41
- "active_side_id": 0,
42
- "board": {
43
- 3 => "s",
44
- 4 => "k" ,
45
- 5 => "s",
48
+ in_hand: %w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p],
49
+ shape: [9, 9],
50
+ side_id: 0,
51
+ square: {
52
+ 3 => "s",
53
+ 4 => "k",
54
+ 5 => "s",
46
55
  22 => "+P",
47
56
  43 => "+B"
48
- },
49
- "indexes": [9, 9],
50
- "pieces_in_hand_grouped_by_sides": [
51
- %w[S],
52
- %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
53
- ]
57
+ }
54
58
  )
55
- # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
59
+ # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
56
60
 
57
61
  # Parse a classic Tsume Shogi problem
58
- FEEN.parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
59
- # => {
60
- # "active_side_id": 0,
61
- # "board": {
62
- # 3 => "s",
63
- # 4 => "k" ,
64
- # 5 => "s",
65
- # 22 => "+P",
66
- # 43 => "+B"
67
- # },
68
- # "indexes": [9, 9],
69
- # "pieces_in_hand_grouped_by_sides": [
70
- # %w[S],
71
- # %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
72
- # ]
73
- # }
62
+ FEEN.parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
63
+ # => {:square=>{3=>"s", 4=>"k", 5=>"s", 22=>"+P", 43=>"+B"}, :shape=>[9, 9], :in_hand=>["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"], :side_id=>0}
74
64
  ```
75
65
 
76
66
  ## License
data/lib/feen.rb CHANGED
@@ -1,46 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "feen/dumper"
4
- require_relative "feen/parser"
3
+ require_relative File.join("feen", "dumper")
4
+ require_relative File.join("feen", "parser")
5
5
 
6
6
  # This module provides a Ruby interface for data serialization and
7
7
  # deserialization in FEEN format.
8
8
  #
9
9
  # @see https://developer.sashite.com/specs/forsyth-edwards-expanded-notation
10
10
  module FEEN
11
- # @example Dumps position params into a FEEN string.
11
+ # Dumps position params into a FEEN string.
12
12
  #
13
- # @param active_side_id [Integer] The identifier of the player who must play.
14
- # @param board [Hash] The indexes of each piece on the board.
15
- # @param indexes [Array] The shape of the board.
16
- # @param pieces_in_hand_grouped_by_sides [Array] The list of pieces in hand
17
- # grouped by players.
13
+ # @param in_hand [Array] The list of pieces in hand.
14
+ # @param shape [Array] The shape of the board.
15
+ # @param side_id [Integer] The identifier of the player who must play.
16
+ # @param square [Hash] The index of each piece on the board.
18
17
  #
19
18
  # @example Dump a classic Tsume Shogi problem
20
19
  # dump(
21
- # "active_side_id": 0,
22
- # "board": {
20
+ # "in_hand": %w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p],
21
+ # "shape": [9, 9],
22
+ # "side_id": 0,
23
+ # "square": {
23
24
  # 3 => "s",
24
25
  # 4 => "k",
25
26
  # 5 => "s",
26
27
  # 22 => "+P",
27
28
  # 43 => "+B"
28
- # },
29
- # "indexes": [9, 9],
30
- # "pieces_in_hand_grouped_by_sides": [
31
- # %w[S],
32
- # %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
33
- # ]
29
+ # }
34
30
  # )
35
- # # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
31
+ # # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
36
32
  #
37
33
  # @return [String] The FEEN string representing the position.
38
- def self.dump(active_side_id:, board: {}, indexes:, pieces_in_hand_grouped_by_sides:)
34
+ def self.dump(in_hand:, shape:, side_id:, square:)
39
35
  Dumper.call(
40
- active_side_id: active_side_id,
41
- board: board,
42
- indexes: indexes,
43
- pieces_in_hand_grouped_by_sides: pieces_in_hand_grouped_by_sides
36
+ in_hand: in_hand,
37
+ shape: shape,
38
+ side_id: side_id,
39
+ square: square
44
40
  )
45
41
  end
46
42
 
@@ -49,22 +45,18 @@ module FEEN
49
45
  # @param feen [String] The FEEN string representing a position.
50
46
  #
51
47
  # @example Parse a classic Tsume Shogi problem
52
- # parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
48
+ # parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
53
49
  # # => {
54
- # # "active_side_id": 0,
55
- # # "board": {
50
+ # # "in_hand": ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"],
51
+ # # "shape": [9, 9],
52
+ # # "side_id": 0,
53
+ # # "square": {
56
54
  # # 3 => "s",
57
55
  # # 4 => "k",
58
56
  # # 5 => "s",
59
57
  # # 22 => "+P",
60
58
  # # 43 => "+B"
61
- # # },
62
- # # "indexes": [9, 9],
63
- # # "pieces_in_hand_grouped_by_sides": [
64
- # # %w[S],
65
- # # %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
66
- # # ]
67
- # # }
59
+ # # }
68
60
  #
69
61
  # @return [Hash] The position params representing the position.
70
62
  def self.parse(feen)
data/lib/feen/dumper.rb CHANGED
@@ -1,44 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "dumper/board"
4
- require_relative "dumper/pieces_in_hand"
5
- require_relative "dumper/turn"
3
+ require_relative File.join("dumper", "in_hand")
4
+ require_relative File.join("dumper", "square")
5
+ require_relative File.join("dumper", "turn")
6
6
 
7
7
  module FEEN
8
8
  # The dumper module.
9
9
  module Dumper
10
10
  # Dump position params into a FEEN string.
11
11
  #
12
- # @param active_side_id [Integer] The identifier of the player who must play.
13
- # @param board [Hash] The indexes of each piece on the board.
14
- # @param indexes [Array] The shape of the board.
15
- # @param pieces_in_hand_grouped_by_sides [Array] The list of pieces in hand
16
- # grouped by players.
12
+ # @param in_hand [Array] The list of pieces in hand.
13
+ # @param shape [Array] The shape of the board.
14
+ # @param side_id [Integer] The identifier of the player who must play.
15
+ # @param square [Hash] The index of each piece on the board.
17
16
  #
18
17
  # @example Dump a classic Tsume Shogi problem
19
18
  # call(
20
- # "active_side_id": 0,
21
- # "board": {
19
+ # "in_hand": %w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p],
20
+ # "shape": [9, 9],
21
+ # "side_id": 0,
22
+ # "square": {
22
23
  # 3 => "s",
23
24
  # 4 => "k",
24
25
  # 5 => "s",
25
26
  # 22 => "+P",
26
27
  # 43 => "+B"
27
- # },
28
- # "indexes": [9, 9],
29
- # "pieces_in_hand_grouped_by_sides": [
30
- # %w[S],
31
- # %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
32
- # ]
28
+ # }
33
29
  # )
34
- # # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
30
+ # # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
35
31
  #
36
32
  # @return [String] The FEEN string representing the position.
37
- def self.call(active_side_id:, board:, indexes:, pieces_in_hand_grouped_by_sides:)
33
+ def self.call(in_hand:, shape:, side_id:, square:)
38
34
  [
39
- Board.new(indexes, board).to_s,
40
- Turn.dump(active_side_id, pieces_in_hand_grouped_by_sides.length),
41
- PiecesInHand.dump(pieces_in_hand_grouped_by_sides)
35
+ Square.new(shape, square).to_s,
36
+ Turn.dump(side_id),
37
+ InHand.dump(in_hand)
42
38
  ].join(" ")
43
39
  end
44
40
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FEEN
4
+ module Dumper
5
+ # The pieces in hand module.
6
+ module InHand
7
+ # Serialize pieces in hand lists into a string.
8
+ #
9
+ # @param piece_names [Array] A list of pieces in hand.
10
+ #
11
+ # @example Dump a list of pieces in hand
12
+ # dump(["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"])
13
+ # # => "S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
14
+ #
15
+ # @example Dump an empty list of pieces in hand
16
+ # dump([])
17
+ # # => "-"
18
+ #
19
+ # @return [String] A string representing the pieces in hand.
20
+ def self.dump(piece_names)
21
+ return "-" if piece_names.empty?
22
+
23
+ piece_names.sort.join(",")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module FEEN
4
4
  module Dumper
5
- # The board class.
5
+ # The square class.
6
6
  #
7
7
  # @example Dump an empty board of Xiangqi
8
8
  # Board.new([10, 9]).to_s # => "9/9/9/9/9/9/9/9/9/9"
@@ -45,9 +45,9 @@ module FEEN
45
45
  # 89 => "俥"
46
46
  # }
47
47
  # ).to_s # => "車,馬,象,士,將,士,象,馬,車/9/1,砲,5,砲,1/卒,1,卒,1,卒,1,卒,1,卒/9/9/兵,1,兵,1,兵,1,兵,1,兵/1,炮,5,炮,1/9/俥,傌,相,仕,帥,仕,相,傌,俥"
48
- class Board
48
+ class Square
49
49
  # @param indexes [Array] The shape of the board.
50
- # @param board [Hash] The indexes of each piece on the board.
50
+ # @param board [Hash] The index of each piece on the board.
51
51
  def initialize(indexes, board)
52
52
  @indexes = indexes
53
53
  @squares = Array.new(length) { |i| board.fetch(i, nil) }
@@ -4,15 +4,14 @@ module FEEN
4
4
  module Dumper
5
5
  # The turn module.
6
6
  module Turn
7
- # @param active_side_id [Integer] The identifier of the active player.
8
- # @param sides_count [Integer] The number of players.
7
+ # @param side_id [Integer] The identifier of the active player.
9
8
  #
10
9
  # @example Dump the number that identify the player who have to play
11
- # dump(0, 2) # => "0"
10
+ # dump(0) # => "0"
12
11
  #
13
12
  # @return [String] The number that identify the player who have to play.
14
- def self.dump(active_side_id, sides_count)
15
- String(Integer(active_side_id) % Integer(sides_count))
13
+ def self.dump(side_id)
14
+ String(side_id)
16
15
  end
17
16
  end
18
17
  end
data/lib/feen/parser.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "parser/board"
4
- require_relative "parser/pieces_in_hand"
5
- require_relative "parser/shape"
6
- require_relative "parser/turn"
3
+ require_relative File.join("parser", "in_hand")
4
+ require_relative File.join("parser", "shape")
5
+ require_relative File.join("parser", "square")
6
+ require_relative File.join("parser", "turn")
7
7
 
8
8
  module FEEN
9
9
  # The parser module.
@@ -13,32 +13,28 @@ module FEEN
13
13
  # @param feen [String] The FEEN string representing a position.
14
14
  #
15
15
  # @example Parse a classic Tsume Shogi problem
16
- # call("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
16
+ # call("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
17
17
  # # => {
18
- # # "active_side_id": 0,
19
- # # "board": {
18
+ # # "in_hand": ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"],
19
+ # # "shape": [9, 9],
20
+ # # "side_id": 0,
21
+ # # "square": {
20
22
  # # 3 => "s",
21
23
  # # 4 => "k",
22
24
  # # 5 => "s",
23
25
  # # 22 => "+P",
24
26
  # # 43 => "+B"
25
- # # },
26
- # # "indexes": [9, 9],
27
- # # "pieces_in_hand_grouped_by_sides": [
28
- # # %w[S],
29
- # # %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
30
- # # ]
31
- # # }
27
+ # # }
32
28
  #
33
29
  # @return [Hash] The position params representing the position.
34
30
  def self.call(feen)
35
- board, active_side_id, in_hand = feen.split(" ")
31
+ square_str, side_id_str, in_hand_str = feen.split
36
32
 
37
33
  {
38
- active_side_id: Turn.parse(active_side_id),
39
- board: Board.new(board).to_h,
40
- indexes: Shape.new(board).to_a,
41
- pieces_in_hand_grouped_by_sides: PiecesInHand.parse(in_hand)
34
+ in_hand: InHand.parse(in_hand_str),
35
+ shape: Shape.new(square_str).to_a,
36
+ side_id: Turn.parse(side_id_str),
37
+ square: Square.new(square_str).to_h
42
38
  }
43
39
  end
44
40
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FEEN
4
+ module Parser
5
+ # The pieces in hand module.
6
+ module InHand
7
+ # The list of pieces in hand grouped by players.
8
+ #
9
+ # @param piece_names_str [String] The serialized list of pieces in hand.
10
+ #
11
+ # @example Parse a list of serialized pieces in hand
12
+ # parse("S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
13
+ # # => ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"]
14
+ #
15
+ # @example Parse an empty list of serialized pieces in hand
16
+ # parse("-")
17
+ # # => []
18
+ #
19
+ # @return [Array] The list of pieces in hand grouped by players.
20
+ def self.parse(piece_names_str)
21
+ return [] if piece_names_str == "-"
22
+
23
+ piece_names_str.split(",")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module FEEN
4
4
  module Parser
5
- # The board class.
5
+ # The square class.
6
6
  #
7
7
  # @example Parse a Shogi problem board and return an array
8
8
  # Board.new("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9").to_a
@@ -22,12 +22,12 @@ module FEEN
22
22
  # Board.new("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9").to_h
23
23
  # # => {
24
24
  # # 3 => "s",
25
- # # 4 => "k" ,
25
+ # # 4 => "k",
26
26
  # # 5 => "s",
27
27
  # # 22 => "+P",
28
28
  # # 43 => "+B"
29
29
  # # }
30
- class Board
30
+ class Square
31
31
  # @param board [String] The flatten board.
32
32
  def initialize(board)
33
33
  @board = board
@@ -40,7 +40,7 @@ module FEEN
40
40
  .flat_map { |str| row(str) }
41
41
  end
42
42
 
43
- # @return [Hash] The indexes of each piece on the board.
43
+ # @return [Hash] The index of each piece on the board.
44
44
  def to_h
45
45
  to_a
46
46
  .each_with_index
@@ -4,15 +4,15 @@ module FEEN
4
4
  module Parser
5
5
  # The turn module.
6
6
  module Turn
7
- # @param active_side_id [String] The identifier of bottom-side and
7
+ # @param side_id [String] The identifier of bottom-side and
8
8
  # top-side.
9
9
  #
10
10
  # @example Parse the number that identify the player who have to play
11
11
  # parse("0") # => 0
12
12
  #
13
13
  # @return [Integer] The number that identify the player who have to play.
14
- def self.parse(active_side_id)
15
- Integer(active_side_id)
14
+ def self.parse(side_id)
15
+ Integer(side_id)
16
16
  end
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brutal
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-md
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop-performance
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,20 @@ dependencies:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rubocop-thread_safety
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -132,13 +160,13 @@ files:
132
160
  - README.md
133
161
  - lib/feen.rb
134
162
  - lib/feen/dumper.rb
135
- - lib/feen/dumper/board.rb
136
- - lib/feen/dumper/pieces_in_hand.rb
163
+ - lib/feen/dumper/in_hand.rb
164
+ - lib/feen/dumper/square.rb
137
165
  - lib/feen/dumper/turn.rb
138
166
  - lib/feen/parser.rb
139
- - lib/feen/parser/board.rb
140
- - lib/feen/parser/pieces_in_hand.rb
167
+ - lib/feen/parser/in_hand.rb
141
168
  - lib/feen/parser/shape.rb
169
+ - lib/feen/parser/square.rb
142
170
  - lib/feen/parser/turn.rb
143
171
  homepage: https://developer.sashite.com/specs/forsyth-edwards-expanded-notation
144
172
  licenses:
@@ -147,7 +175,7 @@ metadata:
147
175
  bug_tracker_uri: https://github.com/sashite/feen.rb/issues
148
176
  documentation_uri: https://rubydoc.info/gems/feen/index
149
177
  source_code_uri: https://github.com/sashite/feen.rb
150
- post_install_message:
178
+ post_install_message:
151
179
  rdoc_options: []
152
180
  require_paths:
153
181
  - lib
@@ -155,15 +183,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
183
  requirements:
156
184
  - - ">="
157
185
  - !ruby/object:Gem::Version
158
- version: '0'
186
+ version: 3.0.0
159
187
  required_rubygems_version: !ruby/object:Gem::Requirement
160
188
  requirements:
161
189
  - - ">="
162
190
  - !ruby/object:Gem::Version
163
191
  version: '0'
164
192
  requirements: []
165
- rubygems_version: 3.1.2
166
- signing_key:
193
+ rubygems_version: 3.2.22
194
+ signing_key:
167
195
  specification_version: 4
168
196
  summary: FEEN support for the Ruby language.
169
197
  test_files: []
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FEEN
4
- module Dumper
5
- # The pieces in hand class.
6
- #
7
- # @example Serialize a list of pieces in hand grouped by sides
8
- # PiecesInHand.dump(
9
- # %w[S],
10
- # %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
11
- # )
12
- # # => "S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
13
- class PiecesInHand
14
- # Serialize pieces in hand lists into a string.
15
- #
16
- # @param pieces_in_hand_grouped_by_sides [Array] The list of pieces in hand
17
- # grouped by players.
18
- #
19
- # @return [String] A string representing the pieces in hand of both
20
- # players.
21
- def self.dump(pieces_in_hand_grouped_by_sides)
22
- pieces_in_hand_grouped_by_sides.map { |pieces| new(pieces).to_s }.join("/")
23
- end
24
-
25
- # @param pieces [Array] A list of pieces in hand.
26
- def initialize(pieces)
27
- @pieces = pieces.sort
28
- end
29
-
30
- # @return [String] A string representing the pieces in hand.
31
- def to_s
32
- @pieces.join(",")
33
- end
34
- end
35
- end
36
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FEEN
4
- module Parser
5
- # The pieces in hand module.
6
- module PiecesInHand
7
- # The list of pieces in hand grouped by players.
8
- #
9
- # @param pieces_in_hand_grouped_by_sides_str [String] The serialized list of
10
- # pieces in hand grouped by players.
11
- #
12
- # @example Parse a list of serialized pieces in hand
13
- # parse("S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
14
- # # => [
15
- # # %w[S],
16
- # # %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
17
- # # ]
18
- #
19
- # @return [Array] The list of pieces in hand grouped by players.
20
- def self.parse(pieces_in_hand_grouped_by_sides_str)
21
- pieces_in_hand_grouped_by_sides_str
22
- .split("/", -1)
23
- .map { |pieces_in_hand_str| pieces_in_hand_str.split(",") }
24
- end
25
- end
26
- end
27
- end