email_inquire 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
  SHA1:
3
- metadata.gz: 054c0718956f4988d89e7334f330bcb9c8b40daa
4
- data.tar.gz: 371dc37d1317eb263dd215bbed23f522dcb60b5c
3
+ metadata.gz: 33910bcf568803231698aa77ddb9eca49c793129
4
+ data.tar.gz: 14cc507b4cf1d85d57886d70273c7e59f799bf23
5
5
  SHA512:
6
- metadata.gz: 7f0f4313682a4cf9e742c17e2da191156d15f9b855c6eab44312c980fcd9dd64a25580a993b9701fb0da8c3211dfe27c9fca66d1ddad85c6ef4abde30a298701
7
- data.tar.gz: 1a3b8191e89fda41a981f1f4f5670831f282599b4257b6aa90d1b82a133e12534d1bcf0fad7b01842fefd9401e8f14e65159a146800249328c11dfb2bfa550a8
6
+ metadata.gz: e046cccc9bb04c860eb16c8f09247b9217e11bf63a7484ac26c334afdab59dc97077f71c1c7c302df743f433d3a6f85c2e61eb167d19ccb8e962b67887560dc4
7
+ data.tar.gz: c9ca590cd4169a068312a82e27c3db3ecedfb61f860ae3a5b46aa226271c9f599be4f6bc690a4a461bbbf46bab8fcdee19d1b4078fe5bc0c308f42076e04f6a5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # EmailInquire
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/email_inquire.svg)](https://badge.fury.io/rb/email_inquire) [![Build Status](https://travis-ci.org/maximeg/email_inquire.svg?branch=master)](https://travis-ci.org/maximeg/email_inquire)
3
+ [![Gem Version](https://badge.fury.io/rb/email_inquire.svg)](https://badge.fury.io/rb/email_inquire) [![Build Status](https://travis-ci.org/maximeg/email_inquire.svg?branch=master)](https://travis-ci.org/maximeg/email_inquire) [![Code Climate](https://codeclimate.com/github/maximeg/email_inquire/badges/gpa.svg)](https://codeclimate.com/github/maximeg/email_inquire)
4
4
 
5
5
  EmailInquire is a library to validate email for common typos and one-time email providers.
6
6
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require "damerau-levenshtein"
3
+ require "set"
3
4
 
4
5
  module EmailInquire
5
6
 
@@ -21,7 +22,6 @@ module EmailInquire
21
22
 
22
23
  def initialize(email)
23
24
  @email = email.downcase
24
- response.email = email
25
25
 
26
26
  parse_email
27
27
  end
@@ -41,18 +41,22 @@ module EmailInquire
41
41
  end
42
42
 
43
43
  def response
44
- @response ||= Response.new
44
+ @response ||= Response.new.tap do |response|
45
+ response.email = email
46
+ end
45
47
  end
46
48
 
49
+ VALIDATORS = [
50
+ :validate_common_domains,
51
+ :validate_one_time_providers,
52
+ :validate_common_domain_mistakes,
53
+ :validate_uk_tld,
54
+ :validate_common_tld_mistakes,
55
+ :validate_domains_with_unique_tld,
56
+ ].freeze
57
+
47
58
  def validate_typos
48
- [
49
- :validate_common_domains,
50
- :validate_one_time_providers,
51
- :validate_common_domain_mistakes,
52
- :validate_uk_tld,
53
- :validate_common_tld_mistakes,
54
- :validate_domains_with_unique_tld,
55
- ].each do |validator|
59
+ VALIDATORS.each do |validator|
56
60
  send(validator)
57
61
  break if response.valid? || response.invalid?
58
62
  end
@@ -117,10 +121,9 @@ module EmailInquire
117
121
  end
118
122
 
119
123
  new_domain = domain.dup
124
+ new_domain.gsub!(/\.[a-z]{2}\.uk\z/, ".co.uk")
120
125
  new_domain.gsub!(/(?<!\.)co\.uk\z/, ".co.uk")
121
- new_domain.gsub!(/\.c[^o]\.uk\z/, ".co.uk")
122
- new_domain.gsub!(/\.[^c]o\.uk\z/, ".co.uk")
123
- new_domain.gsub!(/(?<!co)\.uk\z/, ".co.uk")
126
+ new_domain.gsub!(/(?<!\.co)\.uk\z/, ".co.uk")
124
127
 
125
128
  response.hint!(domain: new_domain) if new_domain != domain
126
129
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module EmailInquire
3
3
 
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
 
6
6
  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.2.0
4
+ version: 0.3.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: 2017-03-19 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: damerau-levenshtein
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.6.10
130
+ rubygems_version: 2.6.11
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Library to validate email for common typos and one-time email provider