email_inquire 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,6 +29,8 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency("bundler", "~> 2.0")
31
31
  spec.add_development_dependency("rake", "~> 10.0")
32
- spec.add_development_dependency("rspec", "~> 3.8.0")
33
- spec.add_development_dependency("rubocop", "0.62.0")
32
+ spec.add_development_dependency("rspec", "~> 3.9.0")
33
+ spec.add_development_dependency("rubocop", "~> 0.78.0")
34
+ spec.add_development_dependency("rubocop-performance", "~> 1.5.0")
35
+ spec.add_development_dependency("rubocop-rspec", "~> 1.37.0")
34
36
  end
@@ -17,12 +17,6 @@ require "email_inquire/validator/unique_domain_provider"
17
17
  module EmailInquire
18
18
  class Inquirer
19
19
 
20
- def initialize(email)
21
- @email = email&.downcase
22
- end
23
-
24
- attr_reader :email
25
-
26
20
  VALIDATORS = [
27
21
  # Format first
28
22
  EmailInquire::Validator::EmailFormat,
@@ -46,6 +40,12 @@ module EmailInquire
46
40
  EmailInquire::Validator::UniqueDomainProvider,
47
41
  ].freeze
48
42
 
43
+ def initialize(email)
44
+ @email = email&.downcase
45
+ end
46
+
47
+ attr_reader :email
48
+
49
49
  def validate
50
50
  response = Helper.first_value(VALIDATORS) { |validator| validator.validate(email) }
51
51
 
@@ -6,24 +6,6 @@ module EmailInquire
6
6
  module Validator
7
7
  class EmailFormat < Base
8
8
 
9
- # Relevant literature:
10
- # http://emailregex.com/email-validation-summary/
11
- # http://www.regular-expressions.info/email.html
12
-
13
- def validate
14
- response.invalid! if !email || email.length > 255 || !name_valid? || !domain_valid?
15
- end
16
-
17
- private
18
-
19
- def domain_valid?
20
- domain =~ DOMAIN_REGEXP
21
- end
22
-
23
- def name_valid?
24
- name =~ NAME_REGEXP
25
- end
26
-
27
9
  DOMAIN_REGEXP = /
28
10
  \A
29
11
  (?:
@@ -42,13 +24,33 @@ module EmailInquire
42
24
  \z
43
25
  /x.freeze
44
26
 
27
+ NAME_ALLOWED_CHARS = /[a-z0-9._%+-]/.freeze
28
+
45
29
  NAME_REGEXP = /
46
30
  \A
47
31
  [a-z0-9]
48
- [a-z0-9._%+-]{0,63}
32
+ [#{NAME_ALLOWED_CHARS}]{0,63}
49
33
  \z
50
34
  /x.freeze
51
35
 
36
+ # Relevant literature:
37
+ # http://emailregex.com/email-validation-summary/
38
+ # http://www.regular-expressions.info/email.html
39
+
40
+ def validate
41
+ response.invalid! if !email || email.length > 255 || !name_valid? || !domain_valid?
42
+ end
43
+
44
+ private
45
+
46
+ def domain_valid?
47
+ domain =~ DOMAIN_REGEXP
48
+ end
49
+
50
+ def name_valid?
51
+ name =~ NAME_REGEXP
52
+ end
53
+
52
54
  end
53
55
  end
54
56
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module EmailInquire
4
4
 
5
- VERSION = "0.10.0"
5
+ VERSION = "0.11.0"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_inquire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-08 00:00:00.000000000 Z
11
+ date: 2020-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: damerau-levenshtein
@@ -58,28 +58,56 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.8.0
61
+ version: 3.9.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.8.0
68
+ version: 3.9.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.78.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.78.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-performance
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 0.62.0
89
+ version: 1.5.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '='
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.5.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.37.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: 0.62.0
110
+ version: 1.37.0
83
111
  description: Library to validate email for format, common typos and one-time email
84
112
  providers
85
113
  email:
@@ -147,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
175
  - !ruby/object:Gem::Version
148
176
  version: '0'
149
177
  requirements: []
150
- rubygems_version: 3.0.2
178
+ rubygems_version: 3.1.2
151
179
  signing_key:
152
180
  specification_version: 4
153
181
  summary: Library to validate email for format, common typos and one-time email providers