eregex 0.2.0 → 0.3.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/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +4 -0
- data/README.md +7 -0
- data/lib/eregex/version.rb +1 -1
- data/lib/eregex.rb +6 -1
- data/lib/eregex_spec.rb +21 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7cd038899c3e3ffa68b8c9427fc5067ebe75277d292d8a26d26a096b5ae3bc1
|
|
4
|
+
data.tar.gz: ab8602952fa19af027ec14931b7b9d3f52ed50153f6fbc546196778bbecea88a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6af55b72aadf593b05c0a63eb6a57d5616c461ae8275d4ef30ce7dae1fe16be792e2b25b78f6deb2b7c12ecce2a75231b91ead720cf15b60202288ef48e9bca9
|
|
7
|
+
data.tar.gz: d777a70396327fa59e301dd041e8eb860878260fcff701fd26deef2b3a4f1447320c1f987eac5f38f3ee6b4f826d2932ef74eef650814de7d81058ef849c5dbb
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -10,6 +10,7 @@ GEM
|
|
|
10
10
|
parallel (1.20.1)
|
|
11
11
|
parser (3.0.2.0)
|
|
12
12
|
ast (~> 2.4.1)
|
|
13
|
+
power_assert (2.0.0)
|
|
13
14
|
rainbow (3.0.0)
|
|
14
15
|
rake (13.0.6)
|
|
15
16
|
regexp_parser (2.1.1)
|
|
@@ -26,6 +27,8 @@ GEM
|
|
|
26
27
|
rubocop-ast (1.9.1)
|
|
27
28
|
parser (>= 3.0.1.1)
|
|
28
29
|
ruby-progressbar (1.11.0)
|
|
30
|
+
test-unit (3.4.4)
|
|
31
|
+
power_assert
|
|
29
32
|
unicode-display_width (2.0.0)
|
|
30
33
|
|
|
31
34
|
PLATFORMS
|
|
@@ -36,6 +39,7 @@ DEPENDENCIES
|
|
|
36
39
|
eregex!
|
|
37
40
|
rake (~> 13.0)
|
|
38
41
|
rubocop (~> 1.7)
|
|
42
|
+
test-unit (~> 3.4, >= 3.4.4)
|
|
39
43
|
|
|
40
44
|
BUNDLED WITH
|
|
41
45
|
2.2.21
|
data/README.md
CHANGED
|
@@ -73,6 +73,13 @@ ERegex.numeric?(subject)
|
|
|
73
73
|
```
|
|
74
74
|
Checks if the value contains anything but numeric values, including decimals and negative numbers. Does not allow for whitespace.
|
|
75
75
|
|
|
76
|
+
***
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
ERegex.uuid?(subject)
|
|
80
|
+
```
|
|
81
|
+
Checks if the value is a UUID. Does not allow whitespaces.
|
|
82
|
+
|
|
76
83
|
|
|
77
84
|
### Replace
|
|
78
85
|
|
data/lib/eregex/version.rb
CHANGED
data/lib/eregex.rb
CHANGED
|
@@ -10,8 +10,9 @@ module ERegex
|
|
|
10
10
|
PATTERN_ALPHANUMERIC = '\pL\pM\pN'
|
|
11
11
|
PATTERN_ALPHADASH = '\pL\pM\pN._-'
|
|
12
12
|
PATTERN_DIGITS = "0-9"
|
|
13
|
-
PATTERN_EMAIL = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
|
|
13
|
+
PATTERN_EMAIL = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.freeze
|
|
14
14
|
PATTERN_NUMERIC = '-?\d*(\.\d+)?'
|
|
15
|
+
PATTERN_UUID = /[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}/.freeze
|
|
15
16
|
|
|
16
17
|
def self.alpha?(subject, allow_whitespace: false)
|
|
17
18
|
match(subject, self::PATTERN_ALPHA, allow_whitespace: allow_whitespace)
|
|
@@ -37,6 +38,10 @@ module ERegex
|
|
|
37
38
|
match(subject, self::PATTERN_NUMERIC)
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
def self.uuid?(subject)
|
|
42
|
+
regex(subject, self::PATTERN_UUID)
|
|
43
|
+
end
|
|
44
|
+
|
|
40
45
|
def self.alpha(subject, replace = "")
|
|
41
46
|
self.replace(subject, self::PATTERN_ALPHA, replace)
|
|
42
47
|
end
|
data/lib/eregex_spec.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "eregex"
|
|
4
|
+
|
|
5
|
+
describe ERegex do
|
|
6
|
+
# TODO: complete the remaining specs
|
|
7
|
+
|
|
8
|
+
describe ".uuid?" do
|
|
9
|
+
it "can check valid uuid" do
|
|
10
|
+
expect(ERegex.uuid?("123e4567-e89b-12d3-a456-426614174000")).to be true
|
|
11
|
+
expect(ERegex.uuid?("123e4567-e89b-12d3-a456-4266")).to be false
|
|
12
|
+
expect(ERegex.uuid?("this is not valid uuid")).to be false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe ".uuid" do
|
|
17
|
+
it "can remove invalid characters from uuid" do
|
|
18
|
+
expect(ERegex.uuid("123e4567-e89b-12d3-a456-426614174000")).to eq("123e4567-e89b-12d3-a456-426614174000")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eregex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ahmed Sayed
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-08-
|
|
11
|
+
date: 2021-08-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Easy way to use regex
|
|
14
14
|
email:
|
|
@@ -33,6 +33,7 @@ files:
|
|
|
33
33
|
- eregex.gemspec
|
|
34
34
|
- lib/eregex.rb
|
|
35
35
|
- lib/eregex/version.rb
|
|
36
|
+
- lib/eregex_spec.rb
|
|
36
37
|
homepage: https://github.com/ahmedsayedabdelsalam/eregex/wiki
|
|
37
38
|
licenses:
|
|
38
39
|
- MIT
|