spectator-validates_email 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.rdoc +5 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/validates_email.rb +9 -6
- data/test/validates_email_test.rb +8 -0
- data/validates_email.gemspec +14 -14
- metadata +12 -7
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -6,6 +6,10 @@ validates_email is a Rails 3 plugin that validates email addresses against RFC 2
|
|
6
6
|
|
7
7
|
rails plugin install git://github.com/spectator/validates_email.git
|
8
8
|
|
9
|
+
or
|
10
|
+
|
11
|
+
gem 'spectator-validates_email', :require => 'validates_email'
|
12
|
+
|
9
13
|
== Usage
|
10
14
|
|
11
15
|
class User < ActiveRecord::Base
|
@@ -45,6 +49,7 @@ Most of the code were taken from Alex Dunae (dunae.ca) plugin (see http://github
|
|
45
49
|
== Contributors
|
46
50
|
|
47
51
|
Petr Blaho
|
52
|
+
Christian Eichhorn
|
48
53
|
|
49
54
|
== Notes
|
50
55
|
|
data/Rakefile
CHANGED
@@ -10,9 +10,9 @@ begin
|
|
10
10
|
gem.email = "yury.velikanau@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/spectator/validates_email"
|
12
12
|
gem.authors = ["Yury Velikanau"]
|
13
|
-
gem.add_development_dependency "activerecord", "
|
14
|
-
gem.add_development_dependency "activesupport", "
|
15
|
-
gem.add_development_dependency "sqlite3-ruby", "
|
13
|
+
gem.add_development_dependency "activerecord", "~> 3.0.0.beta"
|
14
|
+
gem.add_development_dependency "activesupport", "~> 3.0.0.beta"
|
15
|
+
gem.add_development_dependency "sqlite3-ruby", "~> 1.3.1"
|
16
16
|
end
|
17
17
|
Jeweler::GemcutterTasks.new
|
18
18
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/validates_email.rb
CHANGED
@@ -10,7 +10,7 @@ class EmailValidator < ActiveModel::EachValidator
|
|
10
10
|
# TODO: should this decode escaped entities before counting?
|
11
11
|
begin
|
12
12
|
local, domain = email.split('@', 2)
|
13
|
-
rescue
|
13
|
+
rescue NoMethodError
|
14
14
|
return false
|
15
15
|
end
|
16
16
|
|
@@ -19,7 +19,7 @@ class EmailValidator < ActiveModel::EachValidator
|
|
19
19
|
|
20
20
|
def validates_email_domain(email, options)
|
21
21
|
require 'resolv'
|
22
|
-
a_fallback = options.is_a?(Hash) ? options[:a_fallback] :
|
22
|
+
a_fallback = options.is_a?(Hash) ? options[:a_fallback] : false
|
23
23
|
domain = email.match(/\@(.+)/)[1]
|
24
24
|
Resolv::DNS.open do |dns|
|
25
25
|
@mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
|
@@ -29,12 +29,15 @@ class EmailValidator < ActiveModel::EachValidator
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def validate_each(record, attribute, value)
|
32
|
-
|
32
|
+
if validates_email_format(value)
|
33
|
+
# only test the mx if the email format is valid first
|
34
|
+
# (missing @ raises exception in validates_email_domain)
|
35
|
+
if options[:mx] && !validates_email_domain(value, options[:mx])
|
36
|
+
record.errors[attribute] << (options[:mx_message] || I18n.t(:mx_invalid, :scope => [:activerecord, :errors, :messages]))
|
37
|
+
end
|
38
|
+
else
|
33
39
|
record.errors[attribute] << (options[:message] || I18n.t(:invalid, :scope => [:activerecord, :errors, :messages]))
|
34
40
|
end
|
35
|
-
if options[:mx] && !validates_email_domain(value, options[:mx])
|
36
|
-
record.errors[attribute] << (options[:mx_message] || I18n.t(:mx_invalid, :scope => [:activerecord, :errors, :messages]))
|
37
|
-
end
|
38
41
|
end
|
39
42
|
|
40
43
|
end
|
@@ -136,6 +136,14 @@ class ValidatesEmailTest < ActiveSupport::TestCase
|
|
136
136
|
save_passes(p, invalid_email)
|
137
137
|
end
|
138
138
|
|
139
|
+
def test_should_not_validate_mx_with_invalid_email
|
140
|
+
invalid_email = 'testexample.com'
|
141
|
+
assert_nothing_raised do
|
142
|
+
p = MxFallback.new(:email => invalid_email)
|
143
|
+
save_fails(p, invalid_email)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
139
147
|
protected
|
140
148
|
|
141
149
|
def create_person(params)
|
data/validates_email.gemspec
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{validates_email}
|
8
|
-
s.version = "0.0.
|
7
|
+
s.name = %q{spectator-validates_email}
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Yury Velikanau"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-24}
|
13
13
|
s.description = %q{validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696}
|
14
14
|
s.email = %q{yury.velikanau@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.homepage = %q{http://github.com/spectator/validates_email}
|
33
33
|
s.rdoc_options = ["--charset=UTF-8"]
|
34
34
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.
|
35
|
+
s.rubygems_version = %q{1.3.7}
|
36
36
|
s.summary = %q{Gem to validate email addresses for Rails 3}
|
37
37
|
s.test_files = [
|
38
38
|
"test/schema.rb",
|
@@ -44,19 +44,19 @@ Gem::Specification.new do |s|
|
|
44
44
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
45
|
s.specification_version = 3
|
46
46
|
|
47
|
-
if Gem::Version.new(Gem::
|
48
|
-
s.add_development_dependency(%q<activerecord>, ["
|
49
|
-
s.add_development_dependency(%q<activesupport>, ["
|
50
|
-
s.add_development_dependency(%q<sqlite3-ruby>, ["
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_development_dependency(%q<activerecord>, ["~> 3.0.0.beta"])
|
49
|
+
s.add_development_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
|
50
|
+
s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
|
51
51
|
else
|
52
|
-
s.add_dependency(%q<activerecord>, ["
|
53
|
-
s.add_dependency(%q<activesupport>, ["
|
54
|
-
s.add_dependency(%q<sqlite3-ruby>, ["
|
52
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.0.beta"])
|
53
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
|
54
|
+
s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
|
55
55
|
end
|
56
56
|
else
|
57
|
-
s.add_dependency(%q<activerecord>, ["
|
58
|
-
s.add_dependency(%q<activesupport>, ["
|
59
|
-
s.add_dependency(%q<sqlite3-ruby>, ["
|
57
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.0.beta"])
|
58
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
|
59
|
+
s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Yury Velikanau
|
@@ -14,15 +14,16 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-24 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
|
-
- -
|
26
|
+
- - ~>
|
26
27
|
- !ruby/object:Gem::Version
|
27
28
|
segments:
|
28
29
|
- 3
|
@@ -36,8 +37,9 @@ dependencies:
|
|
36
37
|
name: activesupport
|
37
38
|
prerelease: false
|
38
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
39
41
|
requirements:
|
40
|
-
- -
|
42
|
+
- - ~>
|
41
43
|
- !ruby/object:Gem::Version
|
42
44
|
segments:
|
43
45
|
- 3
|
@@ -51,8 +53,9 @@ dependencies:
|
|
51
53
|
name: sqlite3-ruby
|
52
54
|
prerelease: false
|
53
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
54
57
|
requirements:
|
55
|
-
- -
|
58
|
+
- - ~>
|
56
59
|
- !ruby/object:Gem::Version
|
57
60
|
segments:
|
58
61
|
- 1
|
@@ -92,6 +95,7 @@ rdoc_options:
|
|
92
95
|
require_paths:
|
93
96
|
- lib
|
94
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
95
99
|
requirements:
|
96
100
|
- - ">="
|
97
101
|
- !ruby/object:Gem::Version
|
@@ -99,6 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
103
|
- 0
|
100
104
|
version: "0"
|
101
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
102
107
|
requirements:
|
103
108
|
- - ">="
|
104
109
|
- !ruby/object:Gem::Version
|
@@ -108,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
113
|
requirements: []
|
109
114
|
|
110
115
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.3.
|
116
|
+
rubygems_version: 1.3.7
|
112
117
|
signing_key:
|
113
118
|
specification_version: 3
|
114
119
|
summary: Gem to validate email addresses for Rails 3
|