regexp-collection 1.0.1 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45559910057c4ccfc7fb57aee7e9d01498240fa06076fef024d92fbf55b8293c
4
- data.tar.gz: bb626104a9313351dd649bc258ed2de344644b1acff0355e30e185ce0d84852a
3
+ metadata.gz: 1a60da99e09e095dce40bd8e2426d7a1f90ebbcf05c7cc61dddd43caf13636de
4
+ data.tar.gz: f1577df60f58d153f9796ad313e0f3b387cd5455dba5254a1fbf1c4d6d860aba
5
5
  SHA512:
6
- metadata.gz: c9203a7296812da92648050be8b7559a4ba5c065b6fc3893ed53a626ba838583ac876a1c14117d25680bc824516fd5ae464bd4dc98e31a16c9bc6ecaece8430d
7
- data.tar.gz: a6ca39bc415baec308057c66e8f685c5d99344db822dfc3692b733cfc48168ae5efea76bfc8eee0b5c25a64e035f3c125325d6c849c2be160ce0ffc3b0af10c5
6
+ metadata.gz: 83385593804f1db3b824120d3d3336281dd354b1376e2dadff451909b4071b01f4214be800891ea314d746a0a01fb34af230f4d544a054ce25c6ab337aedd0f4
7
+ data.tar.gz: 6289d769ddbe2cfe1bf56bd17830b4a579ddb8df5e4e168b05fbedb5e40b0699c9cac9bdaa952055f294567155c5c5e5eadc52d035e387521f649754bb3fff99
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.1
1
+ 4.0.7
data/Gemfile CHANGED
@@ -1,9 +1,5 @@
1
- # encoding: UTF-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  source "https://rubygems.org"
5
4
 
6
5
  gemspec
7
-
8
- gem "rake", "~> 12.3"
9
- gem "test-unit", "~> 3.2"
data/Gemfile.lock CHANGED
@@ -1,24 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- regexp-collection (1.0.1)
4
+ regexp-collection (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- power_assert (1.1.3)
10
- rake (12.3.1)
11
- test-unit (3.2.8)
9
+ power_assert (3.1.0)
10
+ rake (13.4.2)
11
+ test-unit (3.7.8)
12
12
  power_assert
13
13
 
14
14
  PLATFORMS
15
15
  ruby
16
16
 
17
17
  DEPENDENCIES
18
- bundler (~> 1.7)
19
- rake (~> 12.3)
18
+ rake (~> 13.4)
20
19
  regexp-collection!
21
- test-unit (~> 3.2)
20
+ test-unit (~> 3.7)
21
+
22
+ CHECKSUMS
23
+ bundler (4.0.22) sha256=d8d5ec84c8555e0af71db63ed7aee4d1a8fb839ec46d84212d61979242a5d75a
24
+ power_assert (3.1.0) sha256=fefe98ed5d3140628138f3f9f9194d6ece01f1320e69700d3c928adca7518251
25
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
26
+ regexp-collection (2.0.0)
27
+ test-unit (3.7.8) sha256=689d1ca53f4d46f678b4e5d68d8e4294f87fc5e8b9238cc4de7c5727e8d65943
22
28
 
23
29
  BUNDLED WITH
24
- 1.16.5
30
+ 4.0.22
data/Rakefile CHANGED
@@ -1,7 +1,12 @@
1
- # encoding: UTF-8
2
1
  # frozen_string_literal: true
3
2
 
3
+ require "bundler/gem_tasks"
4
4
  require "rake/testtask"
5
5
 
6
6
  ENV["TESTOPTS"] = "--verbose"
7
- Rake::TestTask.new { |t| t.libs << "test" }
7
+ Rake::TestTask.new do |t|
8
+ t.libs << "test"
9
+ t.pattern = "test/**/test_*.rb"
10
+ end
11
+
12
+ task default: :test
@@ -1,19 +1,3 @@
1
- # encoding: UTF-8
2
1
  # frozen_string_literal: true
3
2
 
4
- module Regexp::Collection
5
- module Numbers
6
- class << self
7
- attr_accessor :integer, :decimal, :natural_including_zero, :natural_excluding_zero
8
-
9
- def natural(zero = false)
10
- zero ? natural_including_zero : natural_excluding_zero
11
- end
12
- end
13
-
14
- self.integer = /\A(?:-?[1-9]\d*\z)|(?:\A0)\z/.freeze
15
- self.decimal = /\A(?:-?[1-9]\d*(?:\.\d+)?\z)|(?:\A0(?:\.\d+)?)\z/.freeze
16
- self.natural_including_zero = /\A(?:0\z)|(?:\A[1-9]\d*)\z/.freeze
17
- self.natural_excluding_zero = /\A[1-9]\d*\z/.freeze
18
- end
19
- end
3
+ require_relative "regexp_collection"
@@ -1,6 +1,5 @@
1
- # encoding: UTF-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Regexp::Collection
5
- VERSION = "1.0.1"
4
+ VERSION = "2.0.0"
6
5
  end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regexp::Collection
4
+ module Number
5
+ class << self
6
+ attr_accessor :integer, :decimal, :natural_including_zero, :natural_excluding_zero, :hexadecimal
7
+
8
+ def natural(zero = false)
9
+ zero ? natural_including_zero : natural_excluding_zero
10
+ end
11
+ end
12
+
13
+ # Matches integers without leading zeros (except single 0), e.g., -10, 0, 42
14
+ self.integer = /\A(?:-?[1-9]\d*|0)\z/.freeze
15
+
16
+ # Matches decimals: integers or numbers with a dot followed by digits.
17
+ # Correctly supports negative decimals while rejecting -0 and -0.0
18
+ self.decimal = /\A(?:-?[1-9]\d*(?:\.\d+)?|-0\.\d*[1-9]\d*|0(?:\.\d+)?)\z/.freeze
19
+
20
+ # Matches natural numbers including 0
21
+ self.natural_including_zero = /\A(?:0|[1-9]\d*)\z/.freeze
22
+
23
+ # Matches natural numbers strictly greater than 0
24
+ self.natural_excluding_zero = /\A[1-9]\d*\z/.freeze
25
+
26
+ # Matches hexadecimal literals with 0x or 0X prefix (case-insensitive hex digits)
27
+ self.hexadecimal = /\A0[xX][a-fA-F0-9]+\z/.freeze
28
+ end
29
+
30
+ module Time
31
+ class << self
32
+ attr_accessor :seconds_required, :seconds_not_permitted, :seconds_optional
33
+ end
34
+
35
+ # HH:MM:SS (hour 0-23, single digit permitted: 0-9)
36
+ self.seconds_required = /\A(?:[01]?\d|2[0-3]):[0-5]\d:[0-5]\d\z/.freeze
37
+
38
+ # HH:MM
39
+ self.seconds_not_permitted = /\A(?:[01]?\d|2[0-3]):[0-5]\d\z/.freeze
40
+
41
+ # HH:MM or HH:MM:SS
42
+ self.seconds_optional = /\A(?:[01]?\d|2[0-3]):[0-5]\d(?::[0-5]\d)?\z/.freeze
43
+ end
44
+
45
+ module Crypto
46
+ class << self
47
+ attr_accessor \
48
+ :trx_wallet_address_base58,
49
+ :evm_wallet_address,
50
+ :evm_transaction_hash,
51
+ :tx_mainnet_wallet_address_bech32,
52
+ :tx_testnet_wallet_address_bech32,
53
+ :xrp_wallet_address_bech32
54
+ end
55
+
56
+ # Tron Base58Check address: starts with T, 34 chars total, excludes 0, O, I, l
57
+ self.trx_wallet_address_base58 = /\AT[1-9A-HJ-NP-Za-km-z]{33}\z/.freeze
58
+
59
+ # EVM address: 0x followed by exactly 40 hexadecimal characters
60
+ self.evm_wallet_address = /\A0x[a-fA-F0-9]{40}\z/.freeze
61
+
62
+ # EVM transaction hash: 0x followed by exactly 64 hexadecimal characters
63
+ self.evm_transaction_hash = /\A0x[a-fA-F0-9]{64}\z/.freeze
64
+
65
+ self.tx_mainnet_wallet_address_bech32 = /\Acore1[02-9ac-hj-np-z]{38}\z/.freeze
66
+
67
+ self.tx_testnet_wallet_address_bech32 = /\Atestcore1[02-9ac-hj-np-z]{38}\z/.freeze
68
+
69
+ # XRP Ledger uses a custom Base58 dictionary and starts with 'r', length 25-34 chars
70
+ self.xrp_wallet_address_bech32 = /\Ar[rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz]{24,33}\z/.freeze
71
+ end
72
+
73
+ module UUID
74
+ class << self
75
+ attr_accessor :v4
76
+ end
77
+
78
+ # UUID version 4 strict validation (e.g., 123e4567-e89b-12d3-a456-426614174000)
79
+ # 13th character must be '4', 17th character must be 8, 9, a, b, A, or B.
80
+ self.v4 = /\A[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\z/.freeze
81
+ end
82
+ end
@@ -1,19 +1,24 @@
1
- # encoding: UTF-8
2
1
  # frozen_string_literal: true
3
2
 
4
- require File.expand_path("../lib/regexp-collection/version", __FILE__)
3
+ require_relative "lib/regexp_collection/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
6
  s.name = "regexp-collection"
8
7
  s.version = Regexp::Collection::VERSION
9
- s.author = "Yaroslav Konoplov"
10
- s.email = "eahome00@gmail.com"
11
- s.summary = "Regular expression collection for Ruby."
12
- s.description = "A gem providing pre-made and tested typical regular expressions for applications."
8
+ s.authors = ["Yaroslav Konoplov"]
9
+ s.email = ["eahome00@gmail.com"]
10
+ s.summary = "Regular expression collection for Ruby"
11
+ s.description = "A gem providing pre-made and tested typical regular expressions for applications"
13
12
  s.homepage = "https://github.com/yivo/regexp-collection"
14
13
  s.license = "MIT"
15
- s.files = `git ls-files -z`.split("\x0")
16
- s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
14
+
15
+ s.required_ruby_version = [">= 3.0", "< 5.0"]
16
+
17
+ s.files = Dir.chdir File.expand_path(__dir__) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
19
+ end
17
20
  s.require_paths = ["lib"]
18
- s.add_development_dependency "bundler", "~> 1.7"
21
+
22
+ s.add_development_dependency "rake", "~> 13.4"
23
+ s.add_development_dependency "test-unit", "~> 3.7"
19
24
  end
@@ -0,0 +1,569 @@
1
+ This file is a merged representation of the entire codebase, combined into a single document by Repomix.
2
+
3
+ <file_summary>
4
+ This section contains a summary of this file.
5
+
6
+ <purpose>
7
+ This file contains a packed representation of the entire repository's contents.
8
+ It is designed to be easily consumable by AI systems for analysis, code review,
9
+ or other automated processes.
10
+ </purpose>
11
+
12
+ <file_format>
13
+ The content is organized as follows:
14
+ 1. This summary section
15
+ 2. Repository information
16
+ 3. Directory structure
17
+ 4. Repository files (if enabled)
18
+ 5. Multiple file entries, each consisting of:
19
+ - File path as an attribute
20
+ - Full contents of the file
21
+ </file_format>
22
+
23
+ <usage_guidelines>
24
+ - This file should be treated as read-only. Any changes should be made to the
25
+ original repository files, not this packed version.
26
+ - When processing this file, use the file path to distinguish
27
+ between different files in the repository.
28
+ - Be aware that this file may contain sensitive information. Handle it with
29
+ the same level of security as you would the original repository.
30
+ </usage_guidelines>
31
+
32
+ <notes>
33
+ - Some files may have been excluded based on .gitignore rules and Repomix's configuration
34
+ - Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files
35
+ - Files matching patterns in .gitignore are excluded
36
+ - Files matching default ignore patterns are excluded
37
+ - Files are sorted by Git change count (files with more changes are at the bottom)
38
+ </notes>
39
+
40
+ </file_summary>
41
+
42
+ <directory_structure>
43
+ lib/
44
+ regexp_collection/
45
+ version.rb
46
+ regexp_collection.rb
47
+ regexp-collection.rb
48
+ test/
49
+ test_helper.rb
50
+ test_regexp_collection.rb
51
+ .gitignore
52
+ .ruby-version
53
+ Gemfile
54
+ LICENSE
55
+ Rakefile
56
+ README.md
57
+ regexp-collection.gemspec
58
+ </directory_structure>
59
+
60
+ <files>
61
+ This section contains the contents of the repository's files.
62
+
63
+ <file path="lib/regexp_collection/version.rb">
64
+ # frozen_string_literal: true
65
+
66
+ module Regexp::Collection
67
+ VERSION = "2.0.0"
68
+ end
69
+ </file>
70
+
71
+ <file path="lib/regexp_collection.rb">
72
+ # frozen_string_literal: true
73
+
74
+ module Regexp::Collection
75
+ module Number
76
+ class << self
77
+ attr_accessor :integer, :decimal, :natural_including_zero, :natural_excluding_zero, :hexadecimal
78
+
79
+ def natural(zero = false)
80
+ zero ? natural_including_zero : natural_excluding_zero
81
+ end
82
+ end
83
+
84
+ # Matches integers without leading zeros (except single 0), e.g., -10, 0, 42
85
+ self.integer = /\A(?:-?[1-9]\d*|0)\z/.freeze
86
+
87
+ # Matches decimals: integers or numbers with a dot followed by digits.
88
+ # Correctly supports negative decimals while rejecting -0 and -0.0
89
+ self.decimal = /\A(?:-?[1-9]\d*(?:\.\d+)?|-0\.\d*[1-9]\d*|0(?:\.\d+)?)\z/.freeze
90
+
91
+ # Matches natural numbers including 0
92
+ self.natural_including_zero = /\A(?:0|[1-9]\d*)\z/.freeze
93
+
94
+ # Matches natural numbers strictly greater than 0
95
+ self.natural_excluding_zero = /\A[1-9]\d*\z/.freeze
96
+
97
+ # Matches hexadecimal literals with 0x or 0X prefix (case-insensitive hex digits)
98
+ self.hexadecimal = /\A0[xX][a-fA-F0-9]+\z/.freeze
99
+ end
100
+
101
+ module Time
102
+ class << self
103
+ attr_accessor :seconds_required, :seconds_not_permitted, :seconds_optional
104
+ end
105
+
106
+ # HH:MM:SS (hour 0-23, single digit permitted: 0-9)
107
+ self.seconds_required = /\A(?:[01]?\d|2[0-3]):[0-5]\d:[0-5]\d\z/.freeze
108
+
109
+ # HH:MM
110
+ self.seconds_not_permitted = /\A(?:[01]?\d|2[0-3]):[0-5]\d\z/.freeze
111
+
112
+ # HH:MM or HH:MM:SS
113
+ self.seconds_optional = /\A(?:[01]?\d|2[0-3]):[0-5]\d(?::[0-5]\d)?\z/.freeze
114
+ end
115
+
116
+ module Crypto
117
+ class << self
118
+ attr_accessor \
119
+ :trx_wallet_address_base58,
120
+ :evm_wallet_address,
121
+ :evm_transaction_hash,
122
+ :tx_mainnet_wallet_address_bech32,
123
+ :tx_testnet_wallet_address_bech32
124
+ end
125
+
126
+ # Tron Base58Check address: starts with T, 34 chars total, excludes 0, O, I, l
127
+ self.trx_wallet_address_base58 = /\AT[1-9A-HJ-NP-Za-km-z]{33}\z/.freeze
128
+
129
+ # EVM address: 0x followed by exactly 40 hexadecimal characters
130
+ self.evm_wallet_address = /\A0x[a-fA-F0-9]{40}\z/.freeze
131
+
132
+ # EVM transaction hash: 0x followed by exactly 64 hexadecimal characters
133
+ self.evm_transaction_hash = /\A0x[a-fA-F0-9]{64}\z/.freeze
134
+
135
+ self.tx_mainnet_wallet_address_bech32 = /\Acore1[02-9ac-hj-np-z]{38}\z/.freeze
136
+
137
+ self.tx_testnet_wallet_address_bech32 = /\Atestcore1[02-9ac-hj-np-z]{38}\z/.freeze
138
+ end
139
+ end
140
+ </file>
141
+
142
+ <file path="test/test_helper.rb">
143
+ # frozen_string_literal: true
144
+
145
+ require "test-unit"
146
+ require "regexp_collection"
147
+
148
+ Test::Unit::TestCase.test_order = :random
149
+ </file>
150
+
151
+ <file path="test/test_regexp_collection.rb">
152
+ # frozen_string_literal: true
153
+
154
+ require_relative "test_helper"
155
+
156
+ class RegexpCollectionTest < Test::Unit::TestCase
157
+ test "Version constant" do
158
+ assert_not_nil Regexp::Collection::VERSION
159
+ assert_true Regexp::Collection::VERSION.match?(/\A\d+\.\d+\.\d+\z/)
160
+ end
161
+
162
+ test "Number.integer" do
163
+ regexp = Regexp::Collection::Number.integer
164
+
165
+ # Valid
166
+ assert_true "0".match?(regexp)
167
+ assert_true "1".match?(regexp)
168
+ assert_true "2".match?(regexp)
169
+ assert_true "-1".match?(regexp)
170
+ assert_true "10".match?(regexp)
171
+ assert_true "100".match?(regexp)
172
+ assert_true "1000".match?(regexp)
173
+ assert_true "9999".match?(regexp)
174
+ assert_true "-9999".match?(regexp)
175
+ assert_true "9000000".match?(regexp)
176
+
177
+ # Invalid - zero variations
178
+ assert_false "-0".match?(regexp)
179
+ assert_false "+0".match?(regexp)
180
+ assert_false "00".match?(regexp)
181
+ assert_false "-00".match?(regexp)
182
+ assert_false "+00".match?(regexp)
183
+
184
+ # Invalid - leading plus and leading zeros
185
+ assert_false "+1".match?(regexp)
186
+ assert_false "+42".match?(regexp)
187
+ assert_false "01".match?(regexp)
188
+ assert_false "-01".match?(regexp)
189
+
190
+ # Invalid - characters and formatting
191
+ assert_false "".match?(regexp)
192
+ assert_false " ".match?(regexp)
193
+ assert_false "-".match?(regexp)
194
+ assert_false "1xx".match?(regexp)
195
+ assert_false "xx1".match?(regexp)
196
+ assert_false "-x1".match?(regexp)
197
+ assert_false "-1x".match?(regexp)
198
+ assert_false "1,000".match?(regexp)
199
+ assert_false "1.0".match?(regexp)
200
+
201
+ # Edge cases - multiline injection checks (\A and \z)
202
+ assert_false "1\n".match?(regexp)
203
+ assert_false "\n1".match?(regexp)
204
+ assert_false "1\n2".match?(regexp)
205
+ end
206
+
207
+ test "Number.decimal" do
208
+ regexp = Regexp::Collection::Number.decimal
209
+
210
+ # Valid - integers
211
+ assert_true "0".match?(regexp)
212
+ assert_true "1".match?(regexp)
213
+ assert_true "-1".match?(regexp)
214
+ assert_true "100".match?(regexp)
215
+
216
+ # Valid - standard decimals
217
+ assert_true "0.0".match?(regexp)
218
+ assert_true "0.5".match?(regexp)
219
+ assert_true "0.12345".match?(regexp)
220
+ assert_true "1.0".match?(regexp)
221
+ assert_true "-1.0".match?(regexp)
222
+ assert_true "12.34".match?(regexp)
223
+ assert_true "-12.34".match?(regexp)
224
+
225
+ # Valid - negative fractions strictly less than 0
226
+ assert_true "-0.5".match?(regexp)
227
+ assert_true "-0.01".match?(regexp)
228
+ assert_true "-0.00001".match?(regexp)
229
+
230
+ # Invalid - zero forms
231
+ assert_false "-0".match?(regexp)
232
+ assert_false "+0".match?(regexp)
233
+ assert_false "-0.0".match?(regexp)
234
+ assert_false "-0.00".match?(regexp)
235
+ assert_false "+0.0".match?(regexp)
236
+ assert_false "+00.0".match?(regexp)
237
+
238
+ # Invalid - leading plus and leading zeros
239
+ assert_false "+1".match?(regexp)
240
+ assert_false "+1.0".match?(regexp)
241
+ assert_false "+0.5".match?(regexp)
242
+ assert_false "01".match?(regexp)
243
+ assert_false "01.5".match?(regexp)
244
+
245
+ # Invalid - structure
246
+ assert_false ".".match?(regexp)
247
+ assert_false ".5".match?(regexp)
248
+ assert_false "-.5".match?(regexp)
249
+ assert_false "1.".match?(regexp)
250
+ assert_false "1.2.3".match?(regexp)
251
+ assert_false "-1.5x".match?(regexp)
252
+ assert_false "1e5".match?(regexp)
253
+ assert_false "".match?(regexp)
254
+
255
+ # Edge cases - multiline injection checks
256
+ assert_false "1.5\n".match?(regexp)
257
+ assert_false "\n1.5".match?(regexp)
258
+ end
259
+
260
+ test "Number.natural" do
261
+ # Default argument must equal natural(false)
262
+ assert_equal Regexp::Collection::Number.natural(false), Regexp::Collection::Number.natural
263
+
264
+ # natural(true) - including zero
265
+ reg_with_zero = Regexp::Collection::Number.natural(true)
266
+ assert_true "0".match?(reg_with_zero)
267
+ assert_true "1".match?(reg_with_zero)
268
+ assert_true "16".match?(reg_with_zero)
269
+ assert_true "999999".match?(reg_with_zero)
270
+ assert_false "-0".match?(reg_with_zero)
271
+ assert_false "+0".match?(reg_with_zero)
272
+ assert_false "00".match?(reg_with_zero)
273
+ assert_false "-1".match?(reg_with_zero)
274
+ assert_false "+1".match?(reg_with_zero)
275
+ assert_false "0.0".match?(reg_with_zero)
276
+ assert_false "1.0".match?(reg_with_zero)
277
+ assert_false "0foo".match?(reg_with_zero)
278
+ assert_false "0\n".match?(reg_with_zero)
279
+
280
+ # natural(false) - excluding zero
281
+ reg_without_zero = Regexp::Collection::Number.natural(false)
282
+ assert_false "0".match?(reg_without_zero)
283
+ assert_true "1".match?(reg_without_zero)
284
+ assert_true "16".match?(reg_without_zero)
285
+ assert_false "-1".match?(reg_without_zero)
286
+ assert_false "+1".match?(reg_without_zero)
287
+ assert_false "01".match?(reg_without_zero)
288
+ assert_false "".match?(reg_without_zero)
289
+ end
290
+
291
+ test "Number.hexadecimal" do
292
+ regexp = Regexp::Collection::Number.hexadecimal
293
+
294
+ # Valid
295
+ assert_true "0x0".match?(regexp)
296
+ assert_true "0x1".match?(regexp)
297
+ assert_true "0xabcdef".match?(regexp)
298
+ assert_true "0xABCDEF".match?(regexp)
299
+ assert_true "0x1a2B3c".match?(regexp)
300
+ assert_true "0X1a2b".match?(regexp)
301
+ assert_true "0XDEADBEEF".match?(regexp)
302
+
303
+ # Invalid
304
+ assert_false "".match?(regexp)
305
+ assert_false "0x".match?(regexp)
306
+ assert_false "0X".match?(regexp)
307
+ assert_false "abcdef".match?(regexp)
308
+ assert_false "x12".match?(regexp)
309
+ assert_false "0x12g".match?(regexp)
310
+ assert_false "0x12Z".match?(regexp)
311
+ assert_false "-0x12".match?(regexp)
312
+ assert_false " 0x12".match?(regexp)
313
+ assert_false "0x12\n".match?(regexp)
314
+ end
315
+
316
+ test "Time.seconds_required" do
317
+ regexp = Regexp::Collection::Time.seconds_required
318
+
319
+ # Valid
320
+ assert_true "00:00:00".match?(regexp)
321
+ assert_true "01:00:00".match?(regexp)
322
+ assert_true "1:00:00".match?(regexp)
323
+ assert_true "12:11:10".match?(regexp)
324
+ assert_true "12:10:09".match?(regexp)
325
+ assert_true "23:59:59".match?(regexp)
326
+
327
+ # Invalid - missing or excess parts
328
+ assert_false "".match?(regexp)
329
+ assert_false "12".match?(regexp)
330
+ assert_false "12:11".match?(regexp)
331
+ assert_false "12:11:".match?(regexp)
332
+ assert_false ":12:11:10".match?(regexp)
333
+ assert_false "12:0:0".match?(regexp)
334
+ assert_false "12:10:09.111".match?(regexp)
335
+
336
+ # Invalid - boundaries
337
+ assert_false "24:00:00".match?(regexp)
338
+ assert_false "25:00:00".match?(regexp)
339
+ assert_false "12:60:00".match?(regexp)
340
+ assert_false "12:11:60".match?(regexp)
341
+
342
+ # Edge cases
343
+ assert_false "+12:11:10".match?(regexp)
344
+ assert_false "12:11:10foo".match?(regexp)
345
+ assert_false "12:11:10\n".match?(regexp)
346
+ end
347
+
348
+ test "Time.seconds_optional" do
349
+ regexp = Regexp::Collection::Time.seconds_optional
350
+
351
+ # Valid
352
+ assert_true "00:00".match?(regexp)
353
+ assert_true "00:00:00".match?(regexp)
354
+ assert_true "1:00".match?(regexp)
355
+ assert_true "1:00:00".match?(regexp)
356
+ assert_true "12:11".match?(regexp)
357
+ assert_true "12:11:10".match?(regexp)
358
+ assert_true "23:59".match?(regexp)
359
+ assert_true "23:59:59".match?(regexp)
360
+
361
+ # Invalid
362
+ assert_false "".match?(regexp)
363
+ assert_false "12".match?(regexp)
364
+ assert_false "12:".match?(regexp)
365
+ assert_false "12:11:".match?(regexp)
366
+ assert_false "24:00".match?(regexp)
367
+ assert_false "24:00:00".match?(regexp)
368
+ assert_false "12:60".match?(regexp)
369
+ assert_false "12:11:60".match?(regexp)
370
+ assert_false "12:11:10\n".match?(regexp)
371
+ end
372
+
373
+ test "Time.seconds_not_permitted" do
374
+ regexp = Regexp::Collection::Time.seconds_not_permitted
375
+
376
+ # Valid
377
+ assert_true "00:00".match?(regexp)
378
+ assert_true "01:00".match?(regexp)
379
+ assert_true "1:00".match?(regexp)
380
+ assert_true "12:11".match?(regexp)
381
+ assert_true "23:59".match?(regexp)
382
+
383
+ # Invalid
384
+ assert_false "".match?(regexp)
385
+ assert_false "12:11:10".match?(regexp)
386
+ assert_false "01:00:00".match?(regexp)
387
+ assert_false "24:00".match?(regexp)
388
+ assert_false "12:60".match?(regexp)
389
+ assert_false "12:11\n".match?(regexp)
390
+ end
391
+
392
+ test "Crypto.trx_wallet_address_base58" do
393
+ regexp = Regexp::Collection::Crypto.trx_wallet_address_base58
394
+
395
+ # Valid TRON Base58 addresses (starts with T, 34 chars)
396
+ assert_true "TNDzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
397
+ assert_true "TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9".match?(regexp)
398
+ assert_true "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH".match?(regexp)
399
+
400
+ # Invalid - wrong prefix
401
+ assert_false "ANDzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
402
+ assert_false "41DzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
403
+
404
+ # Invalid - incorrect length
405
+ assert_false "TNDzfERD73nNqaTTrvNX7moW2GFp3W5am".match?(regexp) # 33 chars
406
+ assert_false "TNDzfERD73nNqaTTrvNX7moW2GFp3W5amzz".match?(regexp) # 35 chars
407
+
408
+ # Invalid - non-Base58 characters (0, O, I, l)
409
+ assert_false "T0DzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
410
+ assert_false "TODzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
411
+ assert_false "TIDzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
412
+ assert_false "TlDzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
413
+
414
+ # Invalid - spaces and newlines
415
+ assert_false " TNDzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(regexp)
416
+ assert_false "TNDzfERD73nNqaTTrvNX7moW2GFp3W5amz\n".match?(regexp)
417
+ assert_false "".match?(regexp)
418
+ end
419
+
420
+ test "Crypto.evm_wallet_address" do
421
+ regexp = Regexp::Collection::Crypto.evm_wallet_address
422
+
423
+ # Valid (40 hex chars after 0x)
424
+ assert_true "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045".match?(regexp)
425
+ assert_true "0x0000000000000000000000000000000000000000".match?(regexp)
426
+ assert_true "0xffffffffffffffffffffffffffffffffffffffff".match?(regexp)
427
+ assert_true "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF".match?(regexp)
428
+
429
+ # Invalid - non-hex characters (g-z, G-Z)
430
+ assert_false "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA9604G".match?(regexp)
431
+ assert_false "0xZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ".match?(regexp)
432
+
433
+ # Invalid - missing prefix
434
+ assert_false "d8dA6BF26964aF9D7eEd9e03E53415D37aA96045".match?(regexp)
435
+
436
+ # Invalid - incorrect length
437
+ assert_false "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA9604".match?(regexp) # 39 chars
438
+ assert_false "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA960455".match?(regexp) # 41 chars
439
+
440
+ # Invalid - spaces and newlines
441
+ assert_false " 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045".match?(regexp)
442
+ assert_false "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\n".match?(regexp)
443
+ assert_false "".match?(regexp)
444
+ end
445
+
446
+ test "Crypto.evm_transaction_hash" do
447
+ regexp = Regexp::Collection::Crypto.evm_transaction_hash
448
+
449
+ # Valid (64 hex chars after 0x)
450
+ assert_true "0x5c504ed432cb51138b309d43e110f94f6470077cbe40191498b82a8763046ad1".match?(regexp)
451
+ assert_true "0x5C504ED432CB51138B309D43E110F94F6470077CBE40191498B82A8763046AD1".match?(regexp)
452
+ assert_true "0x0000000000000000000000000000000000000000000000000000000000000000".match?(regexp)
453
+
454
+ # Invalid - non-hex characters
455
+ assert_false "0x5c504ed432cb51138b309d43e110f94f6470077cbe40191498b82a8763046adG".match?(regexp)
456
+
457
+ # Invalid - missing prefix
458
+ assert_false "5c504ed432cb51138b309d43e110f94f6470077cbe40191498b82a8763046ad1".match?(regexp)
459
+
460
+ # Invalid - length
461
+ assert_false "0x5c504ed432cb51138b309d43e110f94f6470077cbe40191498b82a8763046ad".match?(regexp) # 63 chars
462
+ assert_false "0x5c504ed432cb51138b309d43e110f94f6470077cbe40191498b82a8763046ad11".match?(regexp) # 65 chars
463
+
464
+ # Invalid - spaces and newlines
465
+ assert_false "0x5c504ed432cb51138b309d43e110f94f6470077cbe40191498b82a8763046ad1\n".match?(regexp)
466
+ assert_false "".match?(regexp)
467
+ end
468
+ end
469
+ </file>
470
+
471
+ <file path=".gitignore">
472
+ *.gem
473
+ .bundle
474
+ pkg/
475
+ tmp/
476
+ /.idea
477
+ </file>
478
+
479
+ <file path="Gemfile">
480
+ # frozen_string_literal: true
481
+
482
+ source "https://rubygems.org"
483
+
484
+ gemspec
485
+ </file>
486
+
487
+ <file path="Rakefile">
488
+ # frozen_string_literal: true
489
+
490
+ require "bundler/gem_tasks"
491
+ require "rake/testtask"
492
+
493
+ ENV["TESTOPTS"] = "--verbose"
494
+ Rake::TestTask.new do |t|
495
+ t.libs << "test"
496
+ t.pattern = "test/**/test_*.rb"
497
+ end
498
+
499
+ task default: :test
500
+ </file>
501
+
502
+ <file path="lib/regexp-collection.rb">
503
+ # frozen_string_literal: true
504
+
505
+ require_relative "regexp_collection"
506
+ </file>
507
+
508
+ <file path=".ruby-version">
509
+ 4.0.7
510
+ </file>
511
+
512
+ <file path="LICENSE">
513
+ The MIT License (MIT)
514
+
515
+ Copyright (c) 2018 Yaroslav Konoplov
516
+
517
+ Permission is hereby granted, free of charge, to any person obtaining a copy
518
+ of this software and associated documentation files (the "Software"), to deal
519
+ in the Software without restriction, including without limitation the rights
520
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
521
+ copies of the Software, and to permit persons to whom the Software is
522
+ furnished to do so, subject to the following conditions:
523
+
524
+ The above copyright notice and this permission notice shall be included in all
525
+ copies or substantial portions of the Software.
526
+
527
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
528
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
529
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
530
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
531
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
532
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
533
+ SOFTWARE.
534
+ </file>
535
+
536
+ <file path="README.md">
537
+ # regexp-collection
538
+
539
+ A gem providing pre-made and tested typical regular expressions for applications.
540
+ </file>
541
+
542
+ <file path="regexp-collection.gemspec">
543
+ # frozen_string_literal: true
544
+
545
+ require_relative "lib/regexp_collection/version"
546
+
547
+ Gem::Specification.new do |s|
548
+ s.name = "regexp-collection"
549
+ s.version = Regexp::Collection::VERSION
550
+ s.authors = ["Yaroslav Konoplov"]
551
+ s.email = ["eahome00@gmail.com"]
552
+ s.summary = "Regular expression collection for Ruby"
553
+ s.description = "A gem providing pre-made and tested typical regular expressions for applications"
554
+ s.homepage = "https://github.com/yivo/regexp-collection"
555
+ s.license = "MIT"
556
+
557
+ s.required_ruby_version = [">= 3.0", "< 5.0"]
558
+
559
+ s.files = Dir.chdir File.expand_path(__dir__) do
560
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
561
+ end
562
+ s.require_paths = ["lib"]
563
+
564
+ s.add_development_dependency "rake", "~> 13.4"
565
+ s.add_development_dependency "test-unit", "~> 3.7"
566
+ end
567
+ </file>
568
+
569
+ </files>
metadata CHANGED
@@ -1,31 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regexp-collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2018-10-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
13
+ name: rake
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '1.7'
18
+ version: '13.4'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '1.7'
27
- description: A gem providing pre-made and tested typical regular expressions for applications.
28
- email: eahome00@gmail.com
25
+ version: '13.4'
26
+ - !ruby/object:Gem::Dependency
27
+ name: test-unit
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.7'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.7'
40
+ description: A gem providing pre-made and tested typical regular expressions for applications
41
+ email:
42
+ - eahome00@gmail.com
29
43
  executables: []
30
44
  extensions: []
31
45
  extra_rdoc_files: []
@@ -38,15 +52,14 @@ files:
38
52
  - README.md
39
53
  - Rakefile
40
54
  - lib/regexp-collection.rb
41
- - lib/regexp-collection/version.rb
55
+ - lib/regexp_collection.rb
56
+ - lib/regexp_collection/version.rb
42
57
  - regexp-collection.gemspec
43
- - test/helper.rb
44
- - test/test-regexp-collection.rb
58
+ - repomix-output.xml
45
59
  homepage: https://github.com/yivo/regexp-collection
46
60
  licenses:
47
61
  - MIT
48
62
  metadata: {}
49
- post_install_message:
50
63
  rdoc_options: []
51
64
  require_paths:
52
65
  - lib
@@ -54,18 +67,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
67
  requirements:
55
68
  - - ">="
56
69
  - !ruby/object:Gem::Version
57
- version: '0'
70
+ version: '3.0'
71
+ - - "<"
72
+ - !ruby/object:Gem::Version
73
+ version: '5.0'
58
74
  required_rubygems_version: !ruby/object:Gem::Requirement
59
75
  requirements:
60
76
  - - ">="
61
77
  - !ruby/object:Gem::Version
62
78
  version: '0'
63
79
  requirements: []
64
- rubyforge_project:
65
- rubygems_version: 2.7.6
66
- signing_key:
80
+ rubygems_version: 4.0.22
67
81
  specification_version: 4
68
- summary: Regular expression collection for Ruby.
69
- test_files:
70
- - test/helper.rb
71
- - test/test-regexp-collection.rb
82
+ summary: Regular expression collection for Ruby
83
+ test_files: []
data/test/helper.rb DELETED
@@ -1,6 +0,0 @@
1
- # encoding: UTF-8
2
- # frozen_string_literal: true
3
-
4
- Bundler.require
5
-
6
- Test::Unit::TestCase.test_order = :random
@@ -1,115 +0,0 @@
1
- # encoding: UTF-8
2
- # frozen_string_literal: true
3
-
4
- require_relative "helper"
5
-
6
- class RegexpCollectionTest < Test::Unit::TestCase
7
- test "Numbers.integer" do
8
- regexp = Regexp::Collection::Numbers.integer
9
- assert_true "1".match?(regexp)
10
- assert_true "2".match?(regexp)
11
- assert_false "01".match?(regexp)
12
- assert_false "-0".match?(regexp)
13
- assert_false "-00".match?(regexp)
14
- assert_false "+0".match?(regexp)
15
- assert_false "+00".match?(regexp)
16
- assert_false "+1".match?(regexp)
17
- assert_true "-1".match?(regexp)
18
- assert_true "10".match?(regexp)
19
- assert_false "1xx".match?(regexp)
20
- assert_false "xx1".match?(regexp)
21
- assert_false "-x1".match?(regexp)
22
- assert_false "-1x".match?(regexp)
23
- assert_true "10".match?(regexp)
24
- assert_true "100".match?(regexp)
25
- assert_true "1000".match?(regexp)
26
- assert_true "9999".match?(regexp)
27
- assert_true "9000000".match?(regexp)
28
- assert_false "00".match?(regexp)
29
- assert_false " ".match?(regexp)
30
- end
31
-
32
- test "Numbers.decimal" do
33
- regexp = Regexp::Collection::Numbers.decimal
34
- assert_true "1".match?(regexp)
35
- assert_true "2".match?(regexp)
36
- assert_false "01".match?(regexp)
37
- assert_false "-0".match?(regexp)
38
- assert_false "+0".match?(regexp)
39
- assert_false "+1".match?(regexp)
40
- assert_true "-1".match?(regexp)
41
- assert_true "10".match?(regexp)
42
- assert_false "1xx".match?(regexp)
43
- assert_false "xx1".match?(regexp)
44
- assert_false "-x1".match?(regexp)
45
- assert_false "-1x".match?(regexp)
46
- assert_false "-1.5x".match?(regexp)
47
- assert_true "10".match?(regexp)
48
- assert_true "100".match?(regexp)
49
- assert_true "1000".match?(regexp)
50
- assert_true "9999".match?(regexp)
51
- assert_true "9000000".match?(regexp)
52
- assert_false "-0.0".match?(regexp)
53
- assert_false "+0.0".match?(regexp)
54
- assert_false "+1.0".match?(regexp)
55
- assert_true "-1.0".match?(regexp)
56
- assert_true "0.0".match?(regexp)
57
- assert_false "+00.0".match?(regexp)
58
- end
59
-
60
- test "Numbers.natural(true)" do
61
- regexp = Regexp::Collection::Numbers.natural(true)
62
- assert_true "0".match?(regexp)
63
- assert_false "-0".match?(regexp)
64
- assert_false "+0".match?(regexp)
65
- assert_false "0.0".match?(regexp)
66
- assert_false "-0.0".match?(regexp)
67
- assert_false "+0.0".match?(regexp)
68
- assert_false "00".match?(regexp)
69
- assert_true "1".match?(regexp)
70
- assert_false "-1".match?(regexp)
71
- assert_false "+1".match?(regexp)
72
- assert_false "1.0".match?(regexp)
73
- assert_false "-1.0".match?(regexp)
74
- assert_false "+1.0".match?(regexp)
75
- assert_false "1.1".match?(regexp)
76
- assert_false "-1.1".match?(regexp)
77
- assert_false "+1.1".match?(regexp)
78
- assert_false "foo".match?(regexp)
79
- assert_false "0foo".match?(regexp)
80
- assert_false "-0foo".match?(regexp)
81
- assert_false "+0foo".match?(regexp)
82
- assert_false "1foo".match?(regexp)
83
- assert_false "-1foo".match?(regexp)
84
- assert_false "+1foo".match?(regexp)
85
- assert_true "16".match?(regexp)
86
- end
87
-
88
- test "Numbers.natural(false)" do
89
- regexp = Regexp::Collection::Numbers.natural(false)
90
- assert_false "0".match?(regexp)
91
- assert_false "-0".match?(regexp)
92
- assert_false "+0".match?(regexp)
93
- assert_false "0.0".match?(regexp)
94
- assert_false "-0.0".match?(regexp)
95
- assert_false "+0.0".match?(regexp)
96
- assert_false "00".match?(regexp)
97
- assert_true "1".match?(regexp)
98
- assert_false "-1".match?(regexp)
99
- assert_false "+1".match?(regexp)
100
- assert_false "1.0".match?(regexp)
101
- assert_false "-1.0".match?(regexp)
102
- assert_false "+1.0".match?(regexp)
103
- assert_false "1.1".match?(regexp)
104
- assert_false "-1.1".match?(regexp)
105
- assert_false "+1.1".match?(regexp)
106
- assert_false "foo".match?(regexp)
107
- assert_false "0foo".match?(regexp)
108
- assert_false "-0foo".match?(regexp)
109
- assert_false "+0foo".match?(regexp)
110
- assert_false "1foo".match?(regexp)
111
- assert_false "-1foo".match?(regexp)
112
- assert_false "+1foo".match?(regexp)
113
- assert_true "16".match?(regexp)
114
- end
115
- end