regexp-collection 1.1.0 → 2.0.1

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: 8def3fa3d688417ba7f665b2f125a41ca90d80441fdd16767bf394952a548d0b
4
- data.tar.gz: 616aae231617f72b5dda7e32414e9563e537a45aea1008e5ace07581852b617c
3
+ metadata.gz: 44087b7816dde7fdcc2953fa0968b3c52ac3be1bff3f7b85f466e92a7854d031
4
+ data.tar.gz: b225846a85bd09e8e56063c068be553a31442f67dabd5ff8fbb794f69b8fee7b
5
5
  SHA512:
6
- metadata.gz: ca71c386e17198ebe0ae8a87c26d06450f0941ab49765797ad3aca1fd0c194e28a2b62267f388440685489e86caf5c3089da67fc784907ceb3d5a0cd0d281216
7
- data.tar.gz: ce3c034b2dc4191d489135ca6c23508d6c5af20014c8052d511c4ba24a21438ca966681a975df2949e3f82e0adcd7a98d5c7e33dffbc1173a419b2ec4ef6770c
6
+ metadata.gz: 4f3868f59c895f42b68aeef0b5df88727f555d7108093ac4eb703f812cb0cd17691dcd9dd6b5e28a2ebd054619358343e6e955fd3da8f7307b213526ee9d540f
7
+ data.tar.gz: 4d8202fd3c2fd673548bbb40e74d39e624c95af1445657b88de59ecd379ce351f265b0b93ebb2e3c44945ad6a9ac5ce80fb1dec075e184c644177bb75f4acf1c
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.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.1.0)
4
+ regexp-collection (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- power_assert (1.2.0)
10
- rake (12.3.3)
11
- test-unit (3.3.7)
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, < 3.0)
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
- 2.1.4
30
+ 4.0.22
data/README.md CHANGED
@@ -1,3 +1,112 @@
1
1
  # regexp-collection
2
2
 
3
- A gem providing pre-made and tested typical regular expressions for applications.
3
+ A gem providing pre-made and tested typical regular expressions for Ruby applications
4
+
5
+ ## Requirements
6
+
7
+ * Ruby >= 2.7.0
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's `Gemfile`:
12
+
13
+ ```ruby
14
+ gem "regexp-collection", "~> 2.0"
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```bash
20
+ $ bundle install
21
+ ```
22
+
23
+ Or install it yourself as:
24
+
25
+ ```bash
26
+ $ gem install regexp-collection
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ The library is divided into logical modules. All regular expressions are frozen (`.freeze`) for safe and optimal use as constants
32
+
33
+ ### Numbers (`Regexp::Collection::Number`)
34
+
35
+ Strict validation for numeric formats, preventing injections and incorrect structures (like leading zeros or `-0`)
36
+
37
+ ```ruby
38
+ require "regexp_collection"
39
+
40
+ # Matches integers (-10, 0, 42). Rejects leading zeros and "-0".
41
+ "-42".match?(Regexp::Collection::Number.integer) # => true
42
+ "-0".match?(Regexp::Collection::Number.integer) # => false
43
+
44
+ # Matches decimals (-0.5, 0.0, 12.34). Rejects "-0.0".
45
+ "12.34".match?(Regexp::Collection::Number.decimal) # => true
46
+
47
+ # Matches natural numbers
48
+ "0".match?(Regexp::Collection::Number.natural(true)) # => true (including zero)
49
+ "0".match?(Regexp::Collection::Number.natural(false)) # => false (excluding zero)
50
+ "42".match?(Regexp::Collection::Number.natural_excluding_zero) # => true
51
+
52
+ # Matches hexadecimal strings (0x or 0X prefix)
53
+ "0x1a2B3c".match?(Regexp::Collection::Number.hexadecimal) # => true
54
+ ```
55
+
56
+ ### Time (`Regexp::Collection::Time`)
57
+
58
+ Validation for 24-hour time formats
59
+
60
+ ```ruby
61
+ # HH:MM:SS format
62
+ "23:59:59".match?(Regexp::Collection::Time.seconds_required) # => true
63
+ "23:59".match?(Regexp::Collection::Time.seconds_required) # => false
64
+
65
+ # HH:MM format
66
+ "23:59".match?(Regexp::Collection::Time.seconds_not_permitted) # => true
67
+
68
+ # HH:MM or HH:MM:SS format
69
+ "23:59".match?(Regexp::Collection::Time.seconds_optional) # => true
70
+ "23:59:59".match?(Regexp::Collection::Time.seconds_optional) # => true
71
+ ```
72
+
73
+ ### Crypto (`Regexp::Collection::Crypto`)
74
+
75
+ Validation for various blockchain wallet addresses and transaction hashes
76
+
77
+ ```ruby
78
+ # EVM (Ethereum, BSC, Polygon, etc.)
79
+ "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045".match?(Regexp::Collection::Crypto.evm_wallet_address) # => true
80
+ "0x5c504ed432cb51138b309d43e110f94f6470077cbe40191498b82a8763046ad1".match?(Regexp::Collection::Crypto.evm_transaction_hash) # => true
81
+
82
+ # TRON (Base58Check)
83
+ "TNDzfERD73nNqaTTrvNX7moW2GFp3W5amz".match?(Regexp::Collection::Crypto.trx_wallet_address_base58) # => true
84
+
85
+ # TX (Bech32)
86
+ "core1023456789acdefghjklmnpqrstuvwxyz023456".match?(Regexp::Collection::Crypto.tx_mainnet_wallet_address_bech32) # => true
87
+ "testcore1023456789acdefghjklmnpqrstuvwxyz023456".match?(Regexp::Collection::Crypto.tx_testnet_wallet_address_bech32) # => true
88
+
89
+ # XRP Ledger (Custom Base58)
90
+ "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn".match?(Regexp::Collection::Crypto.xrp_wallet_address_bech32) # => true
91
+ ```
92
+
93
+ ### UUID (`Regexp::Collection::UUID`)
94
+
95
+ Strict validation for UUID identifiers
96
+
97
+ ```ruby
98
+ # Strict UUID v4 validation
99
+ "123e4567-e89b-42d3-a456-426614174000".match?(Regexp::Collection::UUID.v4) # => true
100
+ ```
101
+
102
+ ## Development and Testing
103
+
104
+ To run the test suite
105
+
106
+ ```bash
107
+ $ rake test
108
+ ```
109
+
110
+ ## License
111
+
112
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT)
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,29 +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
-
20
- module Time
21
- class << self
22
- attr_accessor :seconds_required, :seconds_not_permitted, :seconds_optional
23
- end
24
-
25
- self.seconds_required = /\A([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\z/.freeze
26
- self.seconds_not_permitted = /\A([01]?[0-9]|2[0-3]):[0-5][0-9]\z/.freeze
27
- self.seconds_optional = /\A([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?\z/.freeze
28
- end
29
- 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.1.0"
4
+ VERSION = "2.0.1"
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 = [">= 2.7.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", "< 3.0"
21
+
22
+ s.add_development_dependency "rake", "~> 13.4"
23
+ s.add_development_dependency "test-unit", "~> 3.7"
19
24
  end
metadata CHANGED
@@ -1,37 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regexp-collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-11-23 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'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '3.0'
18
+ version: '13.4'
23
19
  type: :development
24
20
  prerelease: false
25
21
  version_requirements: !ruby/object:Gem::Requirement
26
22
  requirements:
27
- - - ">="
23
+ - - "~>"
28
24
  - !ruby/object:Gem::Version
29
- version: '1.7'
30
- - - "<"
25
+ version: '13.4'
26
+ - !ruby/object:Gem::Dependency
27
+ name: test-unit
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '3.0'
33
- description: A gem providing pre-made and tested typical regular expressions for applications.
34
- email: eahome00@gmail.com
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
35
43
  executables: []
36
44
  extensions: []
37
45
  extra_rdoc_files: []
@@ -44,15 +52,13 @@ files:
44
52
  - README.md
45
53
  - Rakefile
46
54
  - lib/regexp-collection.rb
47
- - lib/regexp-collection/version.rb
55
+ - lib/regexp_collection.rb
56
+ - lib/regexp_collection/version.rb
48
57
  - regexp-collection.gemspec
49
- - test/helper.rb
50
- - test/test-regexp-collection.rb
51
58
  homepage: https://github.com/yivo/regexp-collection
52
59
  licenses:
53
60
  - MIT
54
61
  metadata: {}
55
- post_install_message:
56
62
  rdoc_options: []
57
63
  require_paths:
58
64
  - lib
@@ -60,17 +66,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
66
  requirements:
61
67
  - - ">="
62
68
  - !ruby/object:Gem::Version
63
- version: '0'
69
+ version: 2.7.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '5.0'
64
73
  required_rubygems_version: !ruby/object:Gem::Requirement
65
74
  requirements:
66
75
  - - ">="
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  requirements: []
70
- rubygems_version: 3.1.2
71
- signing_key:
79
+ rubygems_version: 4.0.22
72
80
  specification_version: 4
73
- summary: Regular expression collection for Ruby.
74
- test_files:
75
- - test/helper.rb
76
- - test/test-regexp-collection.rb
81
+ summary: Regular expression collection for Ruby
82
+ 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,183 +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
-
116
- test "Time.seconds_required" do
117
- regexp = Regexp::Collection::Time.seconds_required
118
- assert_false "".match?(regexp)
119
- assert_false "foo".match?(regexp)
120
- assert_false "12".match?(regexp)
121
- assert_false "12:11".match?(regexp)
122
- assert_false "12:11:".match?(regexp)
123
- assert_true "12:11:10".match?(regexp)
124
- assert_false "+12:11:10".match?(regexp)
125
- assert_false "12:11:10foo".match?(regexp)
126
- assert_false "12:11:60".match?(regexp)
127
- assert_true "23:59:59".match?(regexp)
128
- assert_false "24:00:00".match?(regexp)
129
- assert_false "1:00".match?(regexp)
130
- assert_true "1:00:00".match?(regexp)
131
- assert_false "01:00".match?(regexp)
132
- assert_true "01:00:00".match?(regexp)
133
- assert_false "12:0:0".match?(regexp)
134
- assert_true "12:10:09".match?(regexp)
135
- assert_false "12:10:09.111".match?(regexp)
136
- end
137
-
138
- test "Time.seconds_optional" do
139
- regexp = Regexp::Collection::Time.seconds_optional
140
- assert_false "".match?(regexp)
141
- assert_false "foo".match?(regexp)
142
- assert_false "12".match?(regexp)
143
- assert_true "12:11".match?(regexp)
144
- assert_false "12:11:".match?(regexp)
145
- assert_true "12:11:10".match?(regexp)
146
- assert_false "+12:11:10".match?(regexp)
147
- assert_false "12:11:10foo".match?(regexp)
148
- assert_false "12:11:60".match?(regexp)
149
- assert_true "23:59".match?(regexp)
150
- assert_true "23:59:59".match?(regexp)
151
- assert_false "24:00:00".match?(regexp)
152
- assert_true "1:00:00".match?(regexp)
153
- assert_true "1:00".match?(regexp)
154
- assert_true "01:00:00".match?(regexp)
155
- assert_true "01:00".match?(regexp)
156
- assert_false "12:0:0".match?(regexp)
157
- assert_true "12:10:09".match?(regexp)
158
- assert_false "12:10:09.111".match?(regexp)
159
- end
160
-
161
- test "Time.seconds_not_permitted" do
162
- regexp = Regexp::Collection::Time.seconds_not_permitted
163
- assert_false "".match?(regexp)
164
- assert_false "foo".match?(regexp)
165
- assert_false "12".match?(regexp)
166
- assert_true "12:11".match?(regexp)
167
- assert_false "12:11:".match?(regexp)
168
- assert_false "12:11:10".match?(regexp)
169
- assert_false "+12:11:10".match?(regexp)
170
- assert_false "12:11:10foo".match?(regexp)
171
- assert_false "12:11:60".match?(regexp)
172
- assert_true "23:59".match?(regexp)
173
- assert_false "23:59:59".match?(regexp)
174
- assert_false "24:00:00".match?(regexp)
175
- assert_false "1:00:00".match?(regexp)
176
- assert_true "1:00".match?(regexp)
177
- assert_false "01:00:00".match?(regexp)
178
- assert_true "01:00".match?(regexp)
179
- assert_false "12:0:0".match?(regexp)
180
- assert_false "12:10:09".match?(regexp)
181
- assert_false "12:10:09.111".match?(regexp)
182
- end
183
- end