sashite-cell 2.0.1 → 2.0.2
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/lib/sashite/cell.rb +20 -8
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2bd53ed1ca6d52f558a3b84a2ab3b4d8b169c0bdc957bc6cc2b4b3f52d52df11
|
|
4
|
+
data.tar.gz: 3174e1859f910636c3c66732beb1b75c3ea4930a35fd609a0fd914947ab6c69e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d709b3784aa4250a0e237047d9b8cee21ad330f23b18bc364f9ddde43d58200695ae5e2ea1456cb7d722c896e7f4d200066410276b9c13f7dbad40c18308752d
|
|
7
|
+
data.tar.gz: bc3f86c59a69f42581b5c8cbfed3823a62649ae4898cfb1447c9657c9bd8e4d38722571face0df3c05a5f021e3c1641d8b32db41bd088ee7421370a4a2eeb76a
|
data/lib/sashite/cell.rb
CHANGED
|
@@ -9,12 +9,15 @@ module Sashite
|
|
|
9
9
|
# This implementation is strictly compliant with CELL Specification v1.0.0
|
|
10
10
|
# @see https://sashite.dev/specs/cell/1.0.0/ CELL Specification v1.0.0
|
|
11
11
|
module Cell
|
|
12
|
-
# Regular expression
|
|
13
|
-
#
|
|
14
|
-
REGEX =
|
|
12
|
+
# Regular expression from CELL Specification v1.0.0
|
|
13
|
+
# Note: Line breaks must be rejected separately (see valid?)
|
|
14
|
+
REGEX = /^[a-z]+(?:[1-9][0-9]*[A-Z]+[a-z]+)*(?:[1-9][0-9]*[A-Z]*)?$/
|
|
15
15
|
|
|
16
16
|
# Check if a string represents a valid CELL coordinate
|
|
17
17
|
#
|
|
18
|
+
# Implements full-string matching as required by the CELL specification.
|
|
19
|
+
# Rejects any input containing line breaks (\r or \n).
|
|
20
|
+
#
|
|
18
21
|
# @param string [String] the string to validate
|
|
19
22
|
# @return [Boolean] true if the string is a valid CELL coordinate
|
|
20
23
|
#
|
|
@@ -23,11 +26,12 @@ module Sashite
|
|
|
23
26
|
# Sashite::Cell.valid?("a1A") # => true
|
|
24
27
|
# Sashite::Cell.valid?("*") # => false
|
|
25
28
|
# Sashite::Cell.valid?("a0") # => false
|
|
29
|
+
# Sashite::Cell.valid?("a1\n") # => false
|
|
26
30
|
def self.valid?(string)
|
|
27
31
|
return false unless string.is_a?(String)
|
|
28
32
|
return false if string.empty?
|
|
33
|
+
return false if string.include?("\r") || string.include?("\n")
|
|
29
34
|
|
|
30
|
-
# Use the optimized CELL v1.0.0 regex for validation
|
|
31
35
|
string.match?(REGEX)
|
|
32
36
|
end
|
|
33
37
|
|
|
@@ -104,6 +108,10 @@ module Sashite
|
|
|
104
108
|
|
|
105
109
|
# Get the validation regular expression
|
|
106
110
|
#
|
|
111
|
+
# Note: This regex alone does not guarantee full compliance. The valid?
|
|
112
|
+
# method additionally rejects strings containing line breaks, as required
|
|
113
|
+
# by the specification's anchoring requirements.
|
|
114
|
+
#
|
|
107
115
|
# @return [Regexp] the CELL validation regex from specification v1.0.0
|
|
108
116
|
def self.regex
|
|
109
117
|
REGEX
|
|
@@ -151,15 +159,15 @@ module Sashite
|
|
|
151
159
|
case type
|
|
152
160
|
when :lowercase
|
|
153
161
|
# Latin lowercase letters: [a-z]+
|
|
154
|
-
match = string.match(
|
|
162
|
+
match = string.match(/^([a-z]+)/)
|
|
155
163
|
match ? match[1] : nil
|
|
156
164
|
when :numeric
|
|
157
|
-
# Arabic numerals: [1-9]
|
|
158
|
-
match = string.match(
|
|
165
|
+
# Arabic numerals: [1-9][0-9]* (CELL specification requires positive integers only)
|
|
166
|
+
match = string.match(/^([1-9][0-9]*)/)
|
|
159
167
|
match ? match[1] : nil
|
|
160
168
|
when :uppercase
|
|
161
169
|
# Latin uppercase letters: [A-Z]+
|
|
162
|
-
match = string.match(
|
|
170
|
+
match = string.match(/^([A-Z]+)/)
|
|
163
171
|
match ? match[1] : nil
|
|
164
172
|
end
|
|
165
173
|
end
|
|
@@ -248,5 +256,9 @@ module Sashite
|
|
|
248
256
|
|
|
249
257
|
result
|
|
250
258
|
end
|
|
259
|
+
|
|
260
|
+
private_class_method :parse_recursive, :dimension_type, :extract_component
|
|
261
|
+
private_class_method :component_to_index, :index_to_component
|
|
262
|
+
private_class_method :letters_to_index, :index_to_letters
|
|
251
263
|
end
|
|
252
264
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sashite-cell
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cyril Kato
|
|
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
49
|
version: '0'
|
|
50
50
|
requirements: []
|
|
51
|
-
rubygems_version: 3.
|
|
51
|
+
rubygems_version: 3.7.2
|
|
52
52
|
specification_version: 4
|
|
53
53
|
summary: CELL (Coordinate Encoding for Layered Locations) implementation for Ruby
|
|
54
54
|
test_files: []
|