sashite-pin 3.2.0 → 4.0.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 +4 -4
- data/LICENSE +201 -0
- data/README.md +197 -425
- data/lib/sashite/pin/constants.rb +35 -0
- data/lib/sashite/pin/errors/argument/messages.rb +28 -0
- data/lib/sashite/pin/errors/argument.rb +16 -0
- data/lib/sashite/pin/errors.rb +3 -0
- data/lib/sashite/pin/identifier.rb +294 -271
- data/lib/sashite/pin/parser.rb +170 -0
- data/lib/sashite/pin.rb +72 -46
- metadata +14 -13
- data/LICENSE.md +0 -22
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sashite
|
|
4
|
+
module Pin
|
|
5
|
+
# Constants for PIN (Piece Identifier Notation).
|
|
6
|
+
#
|
|
7
|
+
# This module defines the valid values for PIN attributes.
|
|
8
|
+
module Constants
|
|
9
|
+
# Valid piece types (uppercase symbols A-Z).
|
|
10
|
+
VALID_TYPES = %i[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z].freeze
|
|
11
|
+
|
|
12
|
+
# Valid player sides.
|
|
13
|
+
VALID_SIDES = %i[first second].freeze
|
|
14
|
+
|
|
15
|
+
# Valid piece states.
|
|
16
|
+
VALID_STATES = %i[normal enhanced diminished].freeze
|
|
17
|
+
|
|
18
|
+
# Maximum length of a valid PIN string.
|
|
19
|
+
# Corresponds to "+K^" (state modifier + letter + terminal marker).
|
|
20
|
+
MAX_STRING_LENGTH = 3
|
|
21
|
+
|
|
22
|
+
# State modifier for enhanced state.
|
|
23
|
+
ENHANCED_PREFIX = "+"
|
|
24
|
+
|
|
25
|
+
# State modifier for diminished state.
|
|
26
|
+
DIMINISHED_PREFIX = "-"
|
|
27
|
+
|
|
28
|
+
# Empty string (no modifier).
|
|
29
|
+
EMPTY_STRING = ""
|
|
30
|
+
|
|
31
|
+
# Terminal marker suffix.
|
|
32
|
+
TERMINAL_SUFFIX = "^"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sashite
|
|
4
|
+
module Pin
|
|
5
|
+
module Errors
|
|
6
|
+
class Argument < ::ArgumentError
|
|
7
|
+
# Centralized error messages for PIN parsing and validation.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# raise Errors::Argument, Messages::EMPTY_INPUT
|
|
11
|
+
module Messages
|
|
12
|
+
# Parsing errors
|
|
13
|
+
EMPTY_INPUT = "empty input"
|
|
14
|
+
INPUT_TOO_LONG = "input exceeds 3 characters"
|
|
15
|
+
MUST_CONTAIN_ONE_LETTER = "must contain exactly one letter"
|
|
16
|
+
INVALID_STATE_MODIFIER = "invalid state modifier"
|
|
17
|
+
INVALID_TERMINAL_MARKER = "invalid terminal marker"
|
|
18
|
+
|
|
19
|
+
# Validation errors (constructor)
|
|
20
|
+
INVALID_TYPE = "type must be a symbol from :A to :Z"
|
|
21
|
+
INVALID_SIDE = "side must be :first or :second"
|
|
22
|
+
INVALID_STATE = "state must be :normal, :enhanced, or :diminished"
|
|
23
|
+
INVALID_TERMINAL = "terminal must be true or false"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "argument/messages"
|
|
4
|
+
|
|
5
|
+
module Sashite
|
|
6
|
+
module Pin
|
|
7
|
+
module Errors
|
|
8
|
+
# Error raised when PIN parsing or validation fails.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# raise Argument, Argument::Messages::EMPTY_INPUT
|
|
12
|
+
class Argument < ::ArgumentError
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|