email_inquire 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/data/uk_tld.txt ADDED
@@ -0,0 +1,15 @@
1
+ .ac.uk
2
+ .co.uk
3
+ .gov.uk
4
+ .judiciary.uk
5
+ .ltd.uk
6
+ .me.uk
7
+ .mod.uk
8
+ .net.uk
9
+ .nhs.uk
10
+ .nic.uk
11
+ .org.uk
12
+ .parliament.uk
13
+ .plc.uk
14
+ .police.uk
15
+ .sch.uk
@@ -0,0 +1,5 @@
1
+ free.fr
2
+ gmail.com
3
+ laposte.net
4
+ sfr.fr
5
+ wanadoo.fr
@@ -5,6 +5,20 @@ module EmailInquire
5
5
 
6
6
  class Inquirer
7
7
 
8
+ class << self
9
+
10
+ private
11
+
12
+ def load_data(filename)
13
+ data = File.read("#{__dir__}/../../data/#{filename}.txt")
14
+ lines = data.split("\n")
15
+ lines.reject! { |line| line[0] == "#" }
16
+
17
+ lines.to_set
18
+ end
19
+
20
+ end
21
+
8
22
  def initialize(email)
9
23
  @email = email.downcase
10
24
  response.email = email
@@ -63,51 +77,7 @@ module EmailInquire
63
77
  end
64
78
  end
65
79
 
66
- COMMON_DOMAINS = %w(
67
- aim.com
68
- aliceadsl.fr
69
- aol.co.uk
70
- aol.com
71
- att.net
72
- bbox.fr
73
- bellsouth.net
74
- blueyonder.co.uk
75
- btinternet.com
76
- charter.net
77
- cox.net
78
- free.fr
79
- gmail.com
80
- gmx.fr
81
- googlemail.com
82
- hotmail.co.uk
83
- hotmail.com
84
- hotmail.fr
85
- icloud.com
86
- laposte.net
87
- live.co.uk
88
- live.com
89
- live.fr
90
- me.com
91
- msn.com
92
- neuf.fr
93
- ntlworld.com
94
- numericable.fr
95
- orange.fr
96
- outlook.com
97
- outlook.fr
98
- rocketmail.com
99
- sbcglobal.net
100
- sfr.fr
101
- sky.com
102
- talktalk.net
103
- verizon.net
104
- virginmedia.com
105
- wanadoo.fr
106
- yahoo.co.uk
107
- yahoo.com
108
- yahoo.fr
109
- ymail.com
110
- ).freeze
80
+ COMMON_DOMAINS = load_data("common_providers").freeze
111
81
 
112
82
  def validate_common_domains
113
83
  return response.valid! if COMMON_DOMAINS.include?(domain)
@@ -137,23 +107,7 @@ module EmailInquire
137
107
  end
138
108
  end
139
109
 
140
- VALID_UK_TLD = %w(
141
- .ac.uk
142
- .co.uk
143
- .gov.uk
144
- .judiciary.uk
145
- .ltd.uk
146
- .me.uk
147
- .mod.uk
148
- .net.uk
149
- .nhs.uk
150
- .nic.uk
151
- .org.uk
152
- .parliament.uk
153
- .plc.uk
154
- .police.uk
155
- .sch.uk
156
- ).freeze
110
+ VALID_UK_TLD = load_data("uk_tld").freeze
157
111
 
158
112
  def validate_uk_tld
159
113
  return unless domain.end_with?(".uk")
@@ -171,13 +125,7 @@ module EmailInquire
171
125
  response.hint!(domain: new_domain) if new_domain != domain
172
126
  end
173
127
 
174
- UNIQUE_TLD_DOMAINS = %w(
175
- free.fr
176
- gmail.com
177
- laposte.net
178
- sfr.fr
179
- wanadoo.fr
180
- ).freeze
128
+ UNIQUE_TLD_DOMAINS = load_data("unique_domain_providers").freeze
181
129
 
182
130
  def validate_domains_with_unique_tld
183
131
  base, tld = domain.split(".")
@@ -192,10 +140,7 @@ module EmailInquire
192
140
  end
193
141
  end
194
142
 
195
- # https://github.com/wesbos/burner-email-providers
196
- ONE_TIME_EMAIL_PROVIDERS = %w(
197
- yopmail.com
198
- ).freeze
143
+ ONE_TIME_EMAIL_PROVIDERS = load_data("one_time_email_providers").freeze
199
144
 
200
145
  def validate_one_time_providers
201
146
  response.invalid! if ONE_TIME_EMAIL_PROVIDERS.include?(domain)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module EmailInquire
3
3
 
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_inquire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Garcia
@@ -98,6 +98,10 @@ files:
98
98
  - Rakefile
99
99
  - bin/console
100
100
  - bin/setup
101
+ - data/common_providers.txt
102
+ - data/one_time_email_providers.txt
103
+ - data/uk_tld.txt
104
+ - data/unique_domain_providers.txt
101
105
  - email_inquire.gemspec
102
106
  - lib/email_inquire.rb
103
107
  - lib/email_inquire/inquirer.rb