portable_move_notation 2.0.0 → 2.1.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
2
  SHA256:
3
- metadata.gz: 235dc58e056f7f8191c003a52248c1dadec9baabb5cc0393fd741bc7109abefa
4
- data.tar.gz: f694111d3222b01a42e93eb39f72bd6dbaf369639ed8f7a5874dde60d09d66ef
3
+ metadata.gz: bae8f26119505e33c79cbf389b10c8f737a60aca132e4c39b7f1b0dcd820e2c9
4
+ data.tar.gz: 735910e4fa03d366cb8d7a63889637a3e3bc4d360e168a2fbe85d28416ae33cb
5
5
  SHA512:
6
- metadata.gz: d294c9796295c57415879911ab0aabfc370aff963f772fd088f1be7f8f9532f93773fe0c1f4748f89534fd20609c1b303e68f0962d4e43e39ee8e48410cda5ad
7
- data.tar.gz: 7f2e37453b62b9407240cead2ac809d230fe464f2a9ce2a4877262e5b6531384d564fe43ec20089d22b4b9337b3a3c05507eb9d4acc562de1ca7eb11cc533d22
6
+ metadata.gz: 91d8644574aad3f7b1224198cc8505aad36c35380bafe257640add785baa273237616187f6c93fa9db0433edc6436483106be7396fa68f33921ca4264f3bfdb1
7
+ data.tar.gz: 1271f9c59dcff69bdf8a305b4f03daa4cc71982d5e92db7fd28fac6e2ee8d3663b9a63d989db076a7c14d7c544b9b92c212d0ca3b4624ba86c203fe64db5d08f
data/README.md CHANGED
@@ -226,7 +226,7 @@ After white plays a double pawn move from e2 (52) to e4 (36), black captures en
226
226
  initial_move = PortableMoveNotation::Action.new(
227
227
  src_square: 52,
228
228
  dst_square: 36,
229
- piece_name: "P",
229
+ piece_name: "P'",
230
230
  piece_hand: nil
231
231
  )
232
232
 
@@ -242,7 +242,7 @@ capture_action2 = PortableMoveNotation::Action.new(
242
242
  src_square: 36,
243
243
  dst_square: 44,
244
244
  piece_name: "p",
245
- piece_hand: null
245
+ piece_hand: nil
246
246
  )
247
247
 
248
248
  en_passant_move = PortableMoveNotation::Move.new(capture_action1, capture_action2)
@@ -24,6 +24,12 @@ module PortableMoveNotation
24
24
  # @see https://sashite.dev/documents/pmn/1.0.0/ PMN Specification
25
25
  # @see https://sashite.dev/documents/pnn/1.0.0/ PNN Specification for piece format
26
26
  class Action
27
+ # Regular expression pattern for validating PNN piece names
28
+ # Format: [prefix]letter[suffix]
29
+ # - prefix: optional '+' or '-'
30
+ # - letter: required 'a-z' or 'A-Z'
31
+ # - suffix: optional "'"
32
+ PIECE_NAME_PATTERN = /\A[-+]?[a-zA-Z][']?\z/
27
33
  # Validates a PMN action hash
28
34
  #
29
35
  # @param action_data [Hash] PMN action data to validate
@@ -141,7 +147,7 @@ module PortableMoveNotation
141
147
  # @param piece_name [Object] Piece name to validate
142
148
  # @raise [ArgumentError] if the format is invalid
143
149
  def validate_piece_name(piece_name)
144
- return if piece_name.is_a?(::String) && piece_name.match?(/\A[-+]?[a-zA-Z][=<>]?\z/)
150
+ return if piece_name.is_a?(::String) && piece_name.match?(PIECE_NAME_PATTERN)
145
151
 
146
152
  raise ::ArgumentError, "Invalid piece_name format: #{piece_name}"
147
153
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portable_move_notation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato