email_inquire 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b639114949de9f154873ae307bcbb047f1f2dfccf61039ca1d9e88e08d19fca4
4
- data.tar.gz: f10a40ce09d7680f64a3214483b871a9946221cf7ce86029627eab797600a9b6
3
+ metadata.gz: d902d865f00ac01fd685b1d1ec4741acc8f1867df1a22f77473f8025af286354
4
+ data.tar.gz: bf87d72da118a972b9c73509b57f91c1a15ec515102eb35f13f7ccd04351b8c2
5
5
  SHA512:
6
- metadata.gz: 6238edec60834896804ab373630846ce0f7171278bd3d51ae2f40720c9f2abb42e130bbd7b7f902e5ff02139bd4fe345d36b67c605ed5b9b46f2390617111d62
7
- data.tar.gz: 174d9daa9959771e59e5af1e3d080b2c461b2621958f75e9b03a2a8551630a91e14d91c29fffd9591e79f9054de76f7e31f2bd9430d2d1bd94e82247f7026b12
6
+ metadata.gz: 8125d4178751fac27e8eef93d7edf59431535bf962ed91419692c0843b73317debc0d5a18d8e17fc5dc4ba1db605c92969db7094d2c0788384709e2283331852
7
+ data.tar.gz: a398c148a51adb5e6346ceabdf967142cd46d196613ea7a41ff0efcf939a62155308ecdaeb03b8b11b5cf004fcf416dca77d90033076f15808fca74cbcd2a525
data/.rubocop.yml CHANGED
@@ -71,14 +71,14 @@ Lint/UnusedMethodArgument:
71
71
  IgnoreEmptyMethods: true
72
72
 
73
73
  Metrics/AbcSize:
74
- Enabled: false # todo
74
+ Enabled: true
75
75
  Max: 20 # default: 15
76
76
 
77
77
  Metrics/BlockLength:
78
- Enabled: false # todo
78
+ Enabled: true
79
79
 
80
80
  Metrics/CyclomaticComplexity:
81
- Enabled: false # todo
81
+ Enabled: true
82
82
  Max: 10 # default: 6
83
83
 
84
84
  Metrics/LineLength:
@@ -88,23 +88,26 @@ Metrics/LineLength:
88
88
  - "^ *#" # comments
89
89
 
90
90
  Metrics/MethodLength:
91
- Enabled: false # todo
91
+ Enabled: true
92
92
  Max: 12 # default: 10
93
93
 
94
94
  Metrics/PerceivedComplexity:
95
- Enabled: false # todo
95
+ Enabled: true
96
96
  Max: 10 # default: 7
97
97
 
98
98
  Naming/VariableNumber:
99
99
  EnforcedStyle: snake_case
100
100
 
101
- Style/AsciiComments:
101
+ Style/AccessModifierDeclarations:
102
102
  Enabled: false
103
103
 
104
104
  Style/AndOr:
105
105
  Enabled: true
106
106
  EnforcedStyle: conditionals
107
107
 
108
+ Style/AsciiComments:
109
+ Enabled: false
110
+
108
111
  Style/BracesAroundHashParameters:
109
112
  Enabled: false
110
113
 
@@ -115,11 +118,7 @@ Style/Documentation:
115
118
  Enabled: false
116
119
 
117
120
  Style/FrozenStringLiteralComment:
118
- Enabled: false # we'll do later
119
-
120
- Style/Lambda:
121
- Enabled: false
122
-
121
+ Enabled: true
123
122
 
124
123
  Style/MethodCallWithArgsParentheses:
125
124
  Enabled: true # false by default
@@ -167,70 +166,3 @@ Style/TrailingCommaInArrayLiteral:
167
166
 
168
167
  Style/TrailingCommaInHashLiteral:
169
168
  EnforcedStyleForMultiline: comma
170
-
171
- #
172
- # Temporary disabled
173
- #
174
-
175
- Layout/EmptyLinesAroundArguments:
176
- Enabled: false # buggy yet
177
-
178
- Lint/IneffectiveAccessModifier:
179
- Enabled: false
180
-
181
- Lint/MissingCopEnableDirective:
182
- Enabled: false
183
-
184
- Lint/RescueException:
185
- Enabled: false
186
-
187
- Lint/ShadowedException:
188
- Enabled: false
189
-
190
- Metrics/BlockNesting:
191
- Enabled: false
192
-
193
- Metrics/ClassLength:
194
- Enabled: false
195
-
196
- Metrics/ModuleLength:
197
- Enabled: false
198
-
199
- Metrics/ParameterLists:
200
- Enabled: false
201
-
202
- Naming/AccessorMethodName:
203
- Enabled: false
204
-
205
- Naming/PredicateName:
206
- Enabled: false
207
-
208
- Security/Eval:
209
- Enabled: false
210
-
211
- Style/ClassAndModuleChildren:
212
- Enabled: false
213
-
214
- Style/ClassVars:
215
- Enabled: false
216
-
217
- Style/DateTime:
218
- Enabled: false
219
-
220
- Style/FormatStringToken:
221
- Enabled: false # issue with strftime
222
-
223
- Style/GuardClause:
224
- Enabled: false
225
-
226
- Style/MixinUsage:
227
- Enabled: false
228
-
229
- Style/NumericPredicate:
230
- Enabled: false
231
-
232
- Style/SafeNavigation:
233
- Enabled: false
234
-
235
- Style/StructInheritance:
236
- Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,14 +1,29 @@
1
1
  # Change Log
2
2
 
3
3
  ## [Unreleased]
4
- [Full Changelog](https://github.com/maximeg/email_inquire/compare/v0.9.0...master)
4
+ [Full Changelog](https://github.com/maximeg/email_inquire/compare/v0.10.0...master)
5
+
6
+ ## [v0.10.0](https://github.com/maximeg/email_inquire/tree/v0.10.0) (2019-01-08)
7
+ [Full Changelog](https://github.com/maximeg/email_inquire/compare/v0.9.0...v0.10.0)
8
+
9
+ **Changed:**
10
+
11
+ - ccTLD open to registration are no longer hinted from foo.xx to foo.co.xx
12
+ (common providers are still hinted, e.g. yahoo.uk => yahoo.co.uk)
13
+ ([maximeg](https://github.com/maximeg))
14
+
15
+ **Dev:**
16
+
17
+ - Add mutant to do mutation testing ([maximeg](https://github.com/maximeg))
18
+ - Extract validators into their own class ([maximeg](https://github.com/maximeg))
19
+ - Bring mutation testing coverage to 100% ([maximeg](https://github.com/maximeg))
5
20
 
6
21
  ## [v0.9.0](https://github.com/maximeg/email_inquire/tree/v0.9.0) (2019-01-04)
7
22
  [Full Changelog](https://github.com/maximeg/email_inquire/compare/v0.8.0...v0.9.0)
8
23
 
9
24
  **Added:**
10
25
 
11
- - Custom valid domains ([maximeg](https://github.com/maximeg))
26
+ - Custom valid domains ([maximeg](https://github.com/maximeg), [kwoodard22](https://github.com/kwoodard22))
12
27
 
13
28
  **Changed:**
14
29
 
data/Gemfile CHANGED
@@ -9,6 +9,9 @@ group :local do
9
9
  # Guard
10
10
  gem "guard-rspec", require: false
11
11
  gem "terminal-notifier-guard", require: false # OS X
12
+
13
+ # Mutation testing
14
+ gem "mutant-rspec", require: false
12
15
  end
13
16
 
14
17
  # Code coverage
data/README.md CHANGED
@@ -23,9 +23,14 @@ While we can't do so much for the name part of the email address, for the domain
23
23
  And also, we don't want for users to use one-time email addresses (also called burner or disposable
24
24
  email addresses).
25
25
 
26
- ### Supported cases
26
+ ## Supported cases
27
27
 
28
- Format error. This doesn't strictly follow RFC 5322, it aims at validating email that will be
28
+ All supported cases are based on a static validation.
29
+ The gem does not check (yet) for domain existence (DNS) and prior delivery (MX entries on DNS).
30
+
31
+ ### Email format
32
+
33
+ This doesn't strictly follow RFC 5322, it aims at validating email that will be
29
34
  deliverable on Internet. It also takes into account length of email, name part and domain part as
30
35
  per SMTP specification.
31
36
 
@@ -38,6 +43,8 @@ per SMTP specification.
38
43
  - `foo+test@domain.com` => valid
39
44
  - ...
40
45
 
46
+ ### Typos
47
+
41
48
  One char typo for 43 common email providers (worldwide and from France, United Kingdom and USA):
42
49
 
43
50
  - `gmil.com` => hint `gmail.com`
@@ -46,16 +53,21 @@ One char typo for 43 common email providers (worldwide and from France, United K
46
53
  - `virinmedia.com` => hint `virginmedia.com`
47
54
  - ...
48
55
 
56
+ ### ccTLD typos
57
+
49
58
  ccTLD specificity, like United Kingdom `.xx.uk` domains:
50
59
 
51
60
  - `foo.couk` => hint `foo.co.uk`
52
61
  - `fooco.uk` => hint `foo.co.uk`
53
- - `foo.uk` => hint `foo.co.uk`
62
+ - `yahoo.uk` => hint `yahoo.co.uk`
54
63
  - `foo.judiciary.uk` => ok!
64
+ - `foo.uk` => ok, .uk is open to registration
55
65
  - ...
56
66
 
57
67
  ...and same thing with `.co.jp` & `.com.br` domains.
58
68
 
69
+ ### Email provider
70
+
59
71
  Providers with an unique domain:
60
72
 
61
73
  - `gmail.fr` => hint `gmail.com`
@@ -66,13 +78,21 @@ Providers with an unique domain:
66
78
  - `laposte.fr` => hint `laposte.net`
67
79
  - ...
68
80
 
69
- 3981 one-time email providers (a.k.a. burners, or disposable email
70
- [source](https://github.com/wesbos/burner-email-providers)):
81
+ ### Burners
82
+
83
+ 3981 one-time email providers a.k.a. burners, or disposable email
84
+ ([source](https://github.com/wesbos/burner-email-providers)):
71
85
 
72
86
  - `yopmail.com` => invalid
73
87
  - ...
74
88
 
75
- Custom invalid domains: Add your own invalid domains:
89
+ ### Known invalid domains
90
+
91
+ - `example.com` => invalid
92
+
93
+ ### Custom invalid domains
94
+
95
+ Add your own invalid domains:
76
96
 
77
97
  ```ruby
78
98
  # in config/initializers/email_inquire.rb
@@ -81,6 +101,18 @@ EmailInquire.custom_invalid_domains << "bad-domain.com"
81
101
 
82
102
  - `bad-domain.com` => invalid
83
103
 
104
+ ### Custom valid domains
105
+
106
+ Take precedence over all the above rules and make any domain in the list valid, and non hintable.
107
+ Add your own valid domains:
108
+
109
+ ```ruby
110
+ # in config/initializers/email_inquire.rb
111
+ EmailInquire.custom_valid_domains << "good-domain.com"
112
+ ```
113
+
114
+ - `good-domain.com` => valid
115
+
84
116
  ## Installation
85
117
 
86
118
  Add this line to your application's Gemfile:
@@ -201,12 +233,45 @@ tap on it should replace the email by the suggestion.
201
233
 
202
234
  Note that you could even have this validation for your Sign In form...
203
235
 
236
+ ## FAQ
237
+
238
+ ### Why does a perfectly valid corporate domain is hinted ?
239
+
240
+ There are a few cases of corporate domains that will be hinted to the related public provider domain:
241
+
242
+ - `google.com` => hint `gmail.com`
243
+ - `laposte.fr` => hint `laposte.net`
244
+ - `sfr.com` => hint `sfr.fr`
245
+
246
+ This is intended. Taking `google.com` (corp) vs. `gmail.com` (public provider):
247
+
248
+ - there are far more people with a `gmail.com` address rather than people with `google.com` address;
249
+ - employees of Google are well aware of the difference between `google.com` (their employee address)
250
+ and `gmail.com` (the public email provider offered by their company)
251
+ and will not be mistaken by a hint;
252
+ - non-tech savvy people are not, and have in mind "my email address is google",
253
+ so not hinting to `gmail.com` would let a lot of actual errors pass.
254
+
255
+ If you do not want this, add the affected domains to `EmailInquire.custom_valid_domains`.
256
+
204
257
  ## Development
205
258
 
206
259
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
207
260
 
208
261
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
209
262
 
263
+
264
+ ### Mutation testing
265
+
266
+ We use [mutant](https://github.com/mbj/mutant) to ensure that everything is well
267
+ tested and the code is minimal. Coverage reported should be close to 100%.
268
+
269
+ Run it with:
270
+
271
+ ```
272
+ bundle exec mutant --include lib --require 'email_inquire.rb' --use rspec -- 'EmailInquire*'
273
+ ```
274
+
210
275
  ## Contributing
211
276
 
212
277
  Bug reports and pull requests are welcome on GitHub at https://github.com/maximeg/email_inquire.
@@ -0,0 +1,72 @@
1
+ adm
2
+ adv
3
+ agr
4
+ am
5
+ arq
6
+ art
7
+ ato
8
+ b
9
+ bio
10
+ blog
11
+ bmd
12
+ cim
13
+ cng
14
+ cnt
15
+ com
16
+ coop
17
+ cri
18
+ def
19
+ ecn
20
+ eco
21
+ edu
22
+ emp
23
+ eng
24
+ esp
25
+ etc
26
+ eti
27
+ far
28
+ flog
29
+ fm
30
+ fnd
31
+ fot
32
+ fst
33
+ g12
34
+ ggf
35
+ gov
36
+ imb
37
+ ind
38
+ inf
39
+ jor
40
+ jus
41
+ leg
42
+ lel
43
+ mat
44
+ med
45
+ mil
46
+ mp
47
+ mus
48
+ net
49
+ nom
50
+ not
51
+ ntr
52
+ odo
53
+ org
54
+ ppg
55
+ pro
56
+ psc
57
+ psi
58
+ qsl
59
+ radio
60
+ rec
61
+ slg
62
+ srv
63
+ taxi
64
+ teo
65
+ tmp
66
+ trd
67
+ tur
68
+ tv
69
+ vet
70
+ vlog
71
+ wiki
72
+ zlg
@@ -0,0 +1,9 @@
1
+ ac
2
+ ad
3
+ co
4
+ ed
5
+ go
6
+ gr
7
+ lg
8
+ ne
9
+ or
@@ -0,0 +1,15 @@
1
+ ac
2
+ co
3
+ gov
4
+ judiciary
5
+ ltd
6
+ me
7
+ mod
8
+ net
9
+ nhs
10
+ nic
11
+ org
12
+ parliament
13
+ plc
14
+ police
15
+ sch
data/lib/email_inquire.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "email_inquire/version"
4
- require "email_inquire/email_validator"
5
4
  require "email_inquire/inquirer"
6
- require "email_inquire/response"
7
5
 
8
6
  module EmailInquire
9
7
 
@@ -13,43 +11,35 @@ module EmailInquire
13
11
  end
14
12
 
15
13
  def self.custom_invalid_domains=(domains)
16
- @@custom_invalid_domains =
14
+ @custom_invalid_domains =
17
15
  case domains
18
- when Set
16
+ when Set, nil
19
17
  domains
20
18
  when Array
21
19
  domains.to_set
22
- when nil
23
- Set.new
24
20
  else
25
21
  raise ArgumentError, "Unsupported type in `custom_invalid_domains=`"
26
22
  end
27
23
  end
28
24
 
29
25
  def self.custom_invalid_domains
30
- @@custom_invalid_domains ||= Set.new
31
-
32
- @@custom_invalid_domains
26
+ @custom_invalid_domains ||= Set.new
33
27
  end
34
28
 
35
29
  def self.custom_valid_domains=(domains)
36
- @@custom_valid_domains =
30
+ @custom_valid_domains =
37
31
  case domains
38
- when Set
32
+ when Set, nil
39
33
  domains
40
34
  when Array
41
35
  domains.to_set
42
- when nil
43
- Set.new
44
36
  else
45
37
  raise ArgumentError, "Unsupported type in `custom_valid_domains=`"
46
38
  end
47
39
  end
48
40
 
49
41
  def self.custom_valid_domains
50
- @@custom_valid_domains ||= Set.new
51
-
52
- @@custom_valid_domains
42
+ @custom_valid_domains ||= Set.new
53
43
  end
54
44
 
55
45
  end