fake_email_validator 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -10
- data/fake_email_validator.gemspec +3 -3
- data/lib/fake_email_service.rb +24 -0
- data/lib/fake_email_validator.rb +6 -12
- data/test/test_fake_email_validator.rb +1 -1
- metadata +20 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599be7cd0cf389048ae32e54a75a0ed0c69707c5
|
4
|
+
data.tar.gz: 2ab99dd0fa353f10503dfc672ca82577af773b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f7e551c761e4e96d83a6c9287533c69876afff1d266dfae2307957995fdc2efd4e59fc489c76e7adaeb3da4839d1dce0e64e5c1c7b0d0436b55d9c01be3a863
|
7
|
+
data.tar.gz: fdbca74c44624eba2f4e13f565f75d8376d16dac507f2bab0124175396dc6c0e9c3d0e88c24063ef14c8f346ac4ee185544e6fed807c4f7b7879841b122477a7
|
data/README.md
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
# fake_email_validator [![Build Status](https://travis-ci.org/maxd/fake_email_validator.png?branch=master)](https://travis-ci.org/maxd/fake_email_validator)
|
2
2
|
|
3
|
-
E-Mail validator for
|
3
|
+
E-Mail validator for block services like mailinator.com, dropmail.me, etc. during new user registration.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'fake_email_validator'
|
9
|
+
gem 'fake_email_validator', '~> 1.0.1'
|
10
10
|
|
11
|
-
|
11
|
+
## How to use?
|
12
12
|
|
13
|
-
|
13
|
+
Just add validator to your User model:
|
14
14
|
|
15
|
-
|
15
|
+
validates :email, fake_email: true
|
16
16
|
|
17
|
-
|
17
|
+
## FAQ
|
18
18
|
|
19
|
-
|
19
|
+
### Where is a list of blocked domains?
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
validates :email, fake_email: true
|
21
|
+
It is [here](https://github.com/maxd/fake_email_validator/blob/master/config/fake_domains.list).
|
24
22
|
|
25
23
|
## Contributing
|
26
24
|
|
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'fake_email_validator'
|
7
|
-
spec.version = '1.0.
|
7
|
+
spec.version = '1.0.1'
|
8
8
|
spec.authors = ['Maxim Dobryakov']
|
9
9
|
spec.email = ['maxim.dobryakov@gmail.com']
|
10
|
-
spec.summary = %q{E-Mail validator for Rails to block fake
|
11
|
-
spec.description = %q{E-Mail validator for
|
10
|
+
spec.summary = %q{E-Mail validator for Rails to block fake email domains}
|
11
|
+
spec.description = %q{E-Mail validator for block services like mailinator.com, dropmail.me, etc. during new user registration.}
|
12
12
|
spec.homepage = 'https://github.com/maxd/fake_email_validator'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mail'
|
2
|
+
|
3
|
+
class FakeEmailService
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
fake_domains_file = File.expand_path('../../config/fake_domains.list', __FILE__)
|
7
|
+
@fake_domains = File.readlines(fake_domains_file).map {|fd| fd.strip.downcase }
|
8
|
+
end
|
9
|
+
|
10
|
+
def is_fake_email?(email)
|
11
|
+
email_address = Mail::Address.new(email)
|
12
|
+
|
13
|
+
domain = email_address.domain.strip.downcase
|
14
|
+
domain_parts = domain.split('.')
|
15
|
+
|
16
|
+
second_level_domain = Array(domain_parts[-2..-1]).join('.')
|
17
|
+
third_level_domain = Array(domain_parts[-3..-1]).join('.')
|
18
|
+
|
19
|
+
domains = [domain, second_level_domain, third_level_domain].compact
|
20
|
+
|
21
|
+
@fake_domains.any? {|fake_domain| domains.include?(fake_domain) }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/fake_email_validator.rb
CHANGED
@@ -1,26 +1,20 @@
|
|
1
1
|
require 'active_model'
|
2
|
-
require '
|
2
|
+
require 'fake_email_service'
|
3
3
|
|
4
4
|
class FakeEmailValidator < ActiveModel::EachValidator
|
5
5
|
|
6
6
|
I18N_SCOPE = 'fake_email_validator.validations.email'
|
7
7
|
|
8
|
+
cattr_accessor :fake_email_service do
|
9
|
+
FakeEmailService.new
|
10
|
+
end
|
11
|
+
|
8
12
|
def initialize(options)
|
9
13
|
super(options)
|
10
|
-
|
11
|
-
fake_domains_file = File.expand_path('../../config/fake_domains.list', __FILE__)
|
12
|
-
@fake_domains = File.readlines(fake_domains_file).map {|fd| fd.strip.downcase }
|
13
14
|
end
|
14
15
|
|
15
16
|
def validate_each(record, attribute, value)
|
16
|
-
|
17
|
-
|
18
|
-
domain = email.domain.strip.downcase
|
19
|
-
second_level_domain = domain.split('.')[-2..-1].join('.')
|
20
|
-
|
21
|
-
is_fake = @fake_domains.include?(domain) || @fake_domains.include?(second_level_domain)
|
22
|
-
|
23
|
-
record.errors.add attribute, I18n.t(:fake, scope: I18N_SCOPE) if is_fake
|
17
|
+
record.errors.add attribute, I18n.t(:fake, scope: I18N_SCOPE) if fake_email_service.is_fake_email?(value)
|
24
18
|
rescue Mail::Field::ParseError
|
25
19
|
record.errors.add attribute, I18n.t(:invalid, scope: I18N_SCOPE)
|
26
20
|
end
|
metadata
CHANGED
@@ -1,94 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_email_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Dobryakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activemodel
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mail
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: E-Mail validator for
|
83
|
+
description: E-Mail validator for block services like mailinator.com, dropmail.me,
|
84
|
+
etc. during new user registration.
|
84
85
|
email:
|
85
86
|
- maxim.dobryakov@gmail.com
|
86
87
|
executables: []
|
87
88
|
extensions: []
|
88
89
|
extra_rdoc_files: []
|
89
90
|
files:
|
90
|
-
- .gitignore
|
91
|
-
- .travis.yml
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
92
93
|
- Gemfile
|
93
94
|
- LICENSE.txt
|
94
95
|
- README.md
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- config/fake_domains.list
|
97
98
|
- config/locales/en.yml
|
98
99
|
- fake_email_validator.gemspec
|
100
|
+
- lib/fake_email_service.rb
|
99
101
|
- lib/fake_email_validator.rb
|
100
102
|
- test/minitest_helper.rb
|
101
103
|
- test/test_fake_email_validator.rb
|
@@ -109,12 +111,12 @@ require_paths:
|
|
109
111
|
- lib
|
110
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
113
|
requirements:
|
112
|
-
- -
|
114
|
+
- - ">="
|
113
115
|
- !ruby/object:Gem::Version
|
114
116
|
version: '0'
|
115
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
118
|
requirements:
|
117
|
-
- -
|
119
|
+
- - ">="
|
118
120
|
- !ruby/object:Gem::Version
|
119
121
|
version: '0'
|
120
122
|
requirements: []
|
@@ -122,7 +124,7 @@ rubyforge_project:
|
|
122
124
|
rubygems_version: 2.2.2
|
123
125
|
signing_key:
|
124
126
|
specification_version: 4
|
125
|
-
summary: E-Mail validator for Rails to block fake
|
127
|
+
summary: E-Mail validator for Rails to block fake email domains
|
126
128
|
test_files:
|
127
129
|
- test/minitest_helper.rb
|
128
130
|
- test/test_fake_email_validator.rb
|