sashite-pan 1.2.0 → 1.3.0

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: ddc5404d30aecb881216eeeda12f98c7295f8dd415302f343c8ac0d0434a7289
4
- data.tar.gz: a70d32986e8e6c1f90dedd8039562089e1f40b8c64a4dcfb518f0bfdd0592904
3
+ metadata.gz: 12680869115791fc6fe8332162cbeaa71174b8ba5c5d74ebb531a805355dae1b
4
+ data.tar.gz: 1147d462de504b726ec26337bf8bfa69b28a8d3e195dbf6b2922b9b3ccaa9cf3
5
5
  SHA512:
6
- metadata.gz: f1ec2c07c1e3ecfbd9dde636595c182178891217eeea5c2724c994b8e8010f2d8ae371e48a5399ef3682ef22b6f9c35550a83123b0e2035dd0603a00c1cf101c
7
- data.tar.gz: ca173e3c7ecd0e49e9026a1f8b5ae9b7f8375c7d893e45b20b8ca7723e10dfe8701f4b4ef837414f2436014653b2accc2a9d2fb2b9b71cf9307c88d4840b745b
6
+ metadata.gz: 8bcb5c10788c3ba49269612062c6eea16251f372a176efd8c390fbe2e7967562bb4c83a27f7f70dd4f5af4af8f3a9ee33695f5d2a1394d105dff00e65043b45d
7
+ data.tar.gz: 0afbe377cfe6b68a5748f74221ef4e6084c55e0439ae6d7234e6864d5403e65a3b2d19f1c5f6579869a795c994c1ccc3f8b1ef0c8bc5ed2df8734318817c0c9a
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2020 Cyril Kato
1
+ Copyright (c) 2014-2021 Cyril Kato
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Portable Action Notation
2
2
 
3
+ [![Version](https://img.shields.io/github/v/tag/sashite/pan.rb?label=Version&logo=github)](https://github.com/sashite/pan.rb/releases)
4
+ [![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/sashite/pan.rb/main)
5
+ [![CI](https://github.com/sashite/pan.rb/workflows/CI/badge.svg?branch=main)](https://github.com/sashite/pan.rb/actions?query=workflow%3Aci+branch%3Amain)
6
+ [![RuboCop](https://github.com/sashite/pan.rb/workflows/RuboCop/badge.svg?branch=main)](https://github.com/sashite/pan.rb/actions?query=workflow%3Arubocop+branch%3Amain)
7
+ [![License](https://img.shields.io/github/license/sashite/pan.rb?label=License&logo=github)](https://github.com/sashite/pan.rb/raw/main/LICENSE.md)
8
+
3
9
  A Ruby interface for data serialization in [PAN](https://developer.sashite.com/specs/portable-action-notation) format.
4
10
 
5
11
  ## Installation
@@ -7,72 +13,90 @@ A Ruby interface for data serialization in [PAN](https://developer.sashite.com/s
7
13
  Add this line to your application's Gemfile:
8
14
 
9
15
  ```ruby
10
- gem 'sashite-pan'
16
+ gem "sashite-pan"
11
17
  ```
12
18
 
13
19
  And then execute:
14
20
 
15
- $ bundle
21
+ ```sh
22
+ bundle
23
+ ```
16
24
 
17
25
  Or install it yourself as:
18
26
 
19
- $ gem install sashite-pan
27
+ ```sh
28
+ gem install sashite-pan
29
+ ```
20
30
 
21
31
  ## Usage
22
32
 
23
33
  Working with PAN can be very simple, for example:
24
34
 
25
35
  ```ruby
26
- require 'sashite/pan'
36
+ require "sashite/pan"
27
37
 
28
38
  # Emit a PAN string
29
39
 
30
40
  actions = [
31
- [52, 36, '', nil]
41
+ [52, 36, ""]
32
42
  ]
33
43
 
34
- Sashite::PAN.dump(*actions) # => '52,36,♙'
44
+ Sashite::PAN.dump(*actions) # => "52,36,♙"
35
45
 
36
46
  # Parse a PAN string
37
47
 
38
- Sashite::PAN.parse('52,36,♙') # => [[52, 36, '', nil]]
48
+ Sashite::PAN.parse("52,36,♙") # => [[52, 36, "", nil]]
39
49
  ```
40
50
 
41
- ## Examples
51
+ ## Example
52
+
53
+ ### Promoting a chess pawn into a knight
42
54
 
43
55
  ```ruby
44
- # Black castles on king-side
56
+ Sashite::PAN.dump([12, 4, "♘"]) # => "12,4,♘"
57
+ Sashite::PAN.parse("12,4,♘") # => [[12, 4, "♘", nil]]
58
+ ```
45
59
 
46
- Sashite::PAN.dump([60, 62, '♔', nil], [63, 61, '♖', nil]) # => '60,62,♔;63,61,♖'
47
- Sashite::PAN.parse('60,62,♔;63,61,♖') # => [[60, 62, '♔', nil], [63, 61, '♖', nil]]
60
+ ### Capturing a rook and promoting a shogi pawn
48
61
 
49
- # Promoting a chess pawn into a knight
62
+ ```ruby
63
+ Sashite::PAN.dump([33, 24, "+P", "R"]) # => "33,24,+P,R"
64
+ Sashite::PAN.parse("33,24,+P,R") # => [[33, 24, "+P", "R"]]
65
+ ```
50
66
 
51
- Sashite::PAN.dump([12, 4, '♘', nil]) # => '12,4,♘'
52
- Sashite::PAN.parse('12,4,♘') # => [[12, 4, '♘', nil]]
67
+ ### Dropping a shogi pawn
53
68
 
54
- # Capturing a rook and promoting a shogi pawn
69
+ ```ruby
70
+ Sashite::PAN.dump([nil, 42, "P"]) # => "*,42,P"
71
+ Sashite::PAN.parse("*,42,P") # => [[nil, 42, "P", nil]]
72
+ ```
73
+
74
+ ***
55
75
 
56
- Sashite::PAN.dump([33, 24, '+P', 'R']) # => '33,24,+P,R'
57
- Sashite::PAN.parse('33,24,+P,R') # => [[33, 24, '+P', 'R']]
76
+ In the context of a game with several possible actions per turn, like in
77
+ Western chess, more than one action could be consider like a move, and joined
78
+ thanks to the [`portable_move_notation`](https://rubygems.org/gems/portable_move_notation) gem.
58
79
 
59
- # Dropping a shogi pawn
80
+ ### Black castles on king-side
60
81
 
61
- Sashite::PAN.dump([nil, 42, 'P', nil]) # => '*,42,P'
62
- Sashite::PAN.parse('*,42,P') # => [[nil, 42, 'P', nil]]
82
+ ```ruby
83
+ Sashite::PAN.dump([60, 62, "♔"], [63, 61, "♖"]) # => "60,62,♔;63,61,♖"
84
+ Sashite::PAN.parse("60,62,♔;63,61,♖") # => [[60, 62, "♔", nil], [63, 61, "♖", nil]]
85
+ ```
63
86
 
64
- # Capturing a white chess pawn en passant
87
+ ### Capturing a white chess pawn en passant
65
88
 
66
- Sashite::PAN.dump([33, 32, '♟', nil], [32, 40, '♟', nil]) # => '33,32,♟;32,40,♟'
67
- Sashite::PAN.parse('33,32,♟;32,40,♟') # => [[33, 32, '', nil], [32, 40, '', nil]]
89
+ ```ruby
90
+ Sashite::PAN.dump([33, 32, ""], [32, 40, ""]) # => "33,32,♟;32,40,♟"
91
+ Sashite::PAN.parse("33,32,♟;32,40,♟") # => [[33, 32, "♟", nil], [32, 40, "♟", nil]]
68
92
  ```
69
93
 
70
94
  ## License
71
95
 
72
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
96
+ The code is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
73
97
 
74
98
  ## About Sashite
75
99
 
76
- The `sashite-pan` gem is maintained by [Sashite](https://sashite.com/).
100
+ This [gem](https://rubygems.org/gems/sashite-pan) is maintained by [Sashite](https://sashite.com/).
77
101
 
78
102
  With some [lines of code](https://github.com/sashite/), let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!
data/lib/sashite-pan.rb CHANGED
@@ -3,4 +3,4 @@
3
3
  # Sashite namespace
4
4
  module Sashite; end
5
5
 
6
- require_relative 'sashite/pan'
6
+ require_relative "sashite/pan"
data/lib/sashite/pan.rb CHANGED
@@ -13,5 +13,5 @@ module Sashite
13
13
  end
14
14
  end
15
15
 
16
- require_relative 'pan/dumper'
17
- require_relative 'pan/parser'
16
+ require_relative "pan/dumper"
17
+ require_relative "pan/parser"
@@ -7,17 +7,17 @@ module Sashite
7
7
  attr_reader :src_square, :dst_square, :piece_name, :piece_hand
8
8
 
9
9
  private_class_method def self.separator
10
- ';'
10
+ ";"
11
11
  end
12
12
 
13
13
  private
14
14
 
15
15
  def separator
16
- ','
16
+ ","
17
17
  end
18
18
 
19
19
  def drop_char
20
- '*'
20
+ "*"
21
21
  end
22
22
  end
23
23
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'action'
3
+ require_relative "action"
4
4
 
5
5
  module Sashite
6
6
  module PAN
@@ -11,7 +11,9 @@ module Sashite
11
11
  .join(separator)
12
12
  end
13
13
 
14
- def initialize(src_square, dst_square, piece_name, piece_hand)
14
+ def initialize(src_square, dst_square, piece_name, piece_hand = nil)
15
+ super()
16
+
15
17
  @src_square = src_square.nil? ? drop_char : Integer(src_square)
16
18
  @dst_square = Integer(dst_square)
17
19
  @piece_name = piece_name.to_s
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'action'
3
+ require_relative "action"
4
4
 
5
5
  module Sashite
6
6
  module PAN
@@ -12,6 +12,8 @@ module Sashite
12
12
  end
13
13
 
14
14
  def initialize(serialized_action)
15
+ super()
16
+
15
17
  action_args = serialized_action.split(separator)
16
18
  src_square = action_args.fetch(0)
17
19
  @src_square = src_square.eql?(drop_char) ? nil : Integer(src_square)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sashite-pan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
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-07-05 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -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
@@ -143,7 +171,7 @@ metadata:
143
171
  bug_tracker_uri: https://github.com/sashite/pan.rb/issues
144
172
  documentation_uri: https://rubydoc.info/gems/sashite-pan/index
145
173
  source_code_uri: https://github.com/sashite/pan.rb
146
- post_install_message:
174
+ post_install_message:
147
175
  rdoc_options: []
148
176
  require_paths:
149
177
  - lib
@@ -151,15 +179,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
179
  requirements:
152
180
  - - ">="
153
181
  - !ruby/object:Gem::Version
154
- version: '0'
182
+ version: 2.7.0
155
183
  required_rubygems_version: !ruby/object:Gem::Requirement
156
184
  requirements:
157
185
  - - ">="
158
186
  - !ruby/object:Gem::Version
159
187
  version: '0'
160
188
  requirements: []
161
- rubygems_version: 3.1.2
162
- signing_key:
189
+ rubygems_version: 3.2.15
190
+ signing_key:
163
191
  specification_version: 4
164
192
  summary: Data serialization in PAN format.
165
193
  test_files: []