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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ec0a17bc2db853baf4e640181dd032f363f9f8d735f3f6191d7cf02643f504d
4
- data.tar.gz: 253af415163bcc12db33ff57c3fe9e9e68668c88d489bf979cbf73836f2c7ffc
3
+ metadata.gz: b7cd038899c3e3ffa68b8c9427fc5067ebe75277d292d8a26d26a096b5ae3bc1
4
+ data.tar.gz: ab8602952fa19af027ec14931b7b9d3f52ed50153f6fbc546196778bbecea88a
5
5
  SHA512:
6
- metadata.gz: 1858bca668fa8ed510e56bc32ff50b3f0dd1dfded28e816e1723db60a79e4cbf9fcde452ab2470eb17eecc10e3eb1289838a5c2c28d72af13a402f172b07e0e0
7
- data.tar.gz: 642bf3fcb10849a401277156790bc215502fd3980d5ab9f14a99b3c83945ba02f764e0014f5df4eee4010e0c4d4baa25d7c4056c9bde01f1e8bc75064af49e72
6
+ metadata.gz: 6af55b72aadf593b05c0a63eb6a57d5616c461ae8275d4ef30ce7dae1fe16be792e2b25b78f6deb2b7c12ecce2a75231b91ead720cf15b60202288ef48e9bca9
7
+ data.tar.gz: d777a70396327fa59e301dd041e8eb860878260fcff701fd26deef2b3a4f1447320c1f987eac5f38f3ee6b4f826d2932ef74eef650814de7d81058ef849c5dbb
data/CHANGELOG.md CHANGED
@@ -11,3 +11,7 @@
11
11
  ## [0.2.0] - 2021-08-12
12
12
 
13
13
  - Add email? method
14
+
15
+ ## [0.3.0] - 2021-08-29
16
+
17
+ - Add uuid? method
data/Gemfile CHANGED
@@ -8,3 +8,7 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rubocop", "~> 1.7"
11
+
12
+ group :test, :development do
13
+ gem "test-unit", "~> 3.4", ">= 3.4.4"
14
+ end
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ERegex
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
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
@@ -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.2.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-12 00:00:00.000000000 Z
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