eregex 0.1.2 → 0.2.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: 881d2cda12e8612a0485ee1b204f855bef50597534394b8a46cfa158602cb4f2
4
- data.tar.gz: 318a9a4ef0839aafbdef2f28a6634ac84ab129787d7cb0e29f6c4201cb4f6810
3
+ metadata.gz: 7ec0a17bc2db853baf4e640181dd032f363f9f8d735f3f6191d7cf02643f504d
4
+ data.tar.gz: 253af415163bcc12db33ff57c3fe9e9e68668c88d489bf979cbf73836f2c7ffc
5
5
  SHA512:
6
- metadata.gz: 923f2d1f2ff4648a55441179e02bb8f44576e3c690e4e2c826cea3fde8ef53c8e573884ec76baea72b7c2bda2dbc1e1c7f59dcf7522b4e951f3b1f6bc2c010f6
7
- data.tar.gz: 77dbeeb08097aeb1a3498bd65448efb611e06a3844524167e80ae78f8c98465f77975687f518937e124e319cc6df6d59bab438a0c2c735c0fe4fe214c8786929
6
+ metadata.gz: 1858bca668fa8ed510e56bc32ff50b3f0dd1dfded28e816e1723db60a79e4cbf9fcde452ab2470eb17eecc10e3eb1289838a5c2c28d72af13a402f172b07e0e0
7
+ data.tar.gz: 642bf3fcb10849a401277156790bc215502fd3980d5ab9f14a99b3c83945ba02f764e0014f5df4eee4010e0c4d4baa25d7c4056c9bde01f1e8bc75064af49e72
data/CHANGELOG.md CHANGED
@@ -7,3 +7,7 @@
7
7
  ## [0.1.2] - 2021-08-12
8
8
 
9
9
  - Fix calling methods with allow_whitespace option
10
+
11
+ ## [0.2.0] - 2021-08-12
12
+
13
+ - Add email? method
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eregex (0.1.2)
4
+ eregex (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -61,6 +61,13 @@ Checks if the value contains anything but integers.
61
61
 
62
62
  ***
63
63
 
64
+ ```ruby
65
+ ERegex.email?(subject)
66
+ ```
67
+ Checks if the value is an Email Address.
68
+
69
+ ***
70
+
64
71
  ```ruby
65
72
  ERegex.numeric?(subject)
66
73
  ```
data/eregex-0.1.2.gem ADDED
Binary file
data/lib/eregex.rb CHANGED
@@ -10,6 +10,7 @@ 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
14
  PATTERN_NUMERIC = '-?\d*(\.\d+)?'
14
15
 
15
16
  def self.alpha?(subject, allow_whitespace: false)
@@ -28,6 +29,10 @@ module ERegex
28
29
  match(subject, self::PATTERN_DIGITS, allow_whitespace: allow_whitespace)
29
30
  end
30
31
 
32
+ def self.email?(subject)
33
+ regex(subject, self::PATTERN_EMAIL)
34
+ end
35
+
31
36
  def self.numeric?(subject)
32
37
  match(subject, self::PATTERN_NUMERIC)
33
38
  end
@@ -56,6 +61,10 @@ module ERegex
56
61
  !!(subject =~ wrap_match_pattern(pattern, allow_whitespace: allow_whitespace))
57
62
  end
58
63
 
64
+ def self.regex(subject, pattern)
65
+ !!(subject =~ pattern)
66
+ end
67
+
59
68
  def self.replace(subject, pattern, replacement = "")
60
69
  subject.gsub(wrap_replace_pattern(pattern), replacement)
61
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ERegex
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eregex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmed Sayed
@@ -29,6 +29,7 @@ files:
29
29
  - Rakefile
30
30
  - bin/console
31
31
  - bin/setup
32
+ - eregex-0.1.2.gem
32
33
  - eregex.gemspec
33
34
  - lib/eregex.rb
34
35
  - lib/eregex/version.rb