validates_email-san 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -13
- data/lib/validates_email_san.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/validates_email_san_test.rb +7 -6
- metadata +24 -32
- data/validates_email-san.gemspec +0 -45
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
|
-
require '
|
3
|
+
require 'rdoc/task'
|
4
4
|
|
5
5
|
desc 'Default: run unit tests.'
|
6
6
|
task :default => :test
|
@@ -21,15 +21,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
21
21
|
rdoc.rdoc_files.include('README')
|
22
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
23
|
end
|
24
|
-
|
25
|
-
begin
|
26
|
-
require 'jeweler'
|
27
|
-
Jeweler::Tasks.new do |s|
|
28
|
-
s.name = "validates_email-san"
|
29
|
-
s.summary = s.description = "A simple Rails plugin which adds a validates_email class method to ActiveRecord::Base."
|
30
|
-
s.homepage = "http://fingertips.github.com"
|
31
|
-
s.email = "eloy@fngtps.com"
|
32
|
-
s.authors = ["Eloy Duran", "Manfred Stienstra"]
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
end
|
data/lib/validates_email_san.rb
CHANGED
@@ -2,7 +2,7 @@ module ActiveRecord
|
|
2
2
|
module Validations #:nodoc:
|
3
3
|
module ClassMethods
|
4
4
|
local_part_illegal_chars = '[^@<>\(\)\[\]:;\\\\\s\.]'
|
5
|
-
EMAIL_REGEXP =
|
5
|
+
EMAIL_REGEXP = /\A[^\.](#{local_part_illegal_chars}|\.#{local_part_illegal_chars})*@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
|
6
6
|
|
7
7
|
# Takes a list of attributes that should be validated to be valid
|
8
8
|
# formatted email addresses. Takes all other options that
|
@@ -20,4 +20,4 @@ module ActiveRecord
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -27,6 +27,7 @@ class ValidatesEmailTest < ActiveSupport::TestCase
|
|
27
27
|
ML+foo@example.com
|
28
28
|
foo@bar.example.com
|
29
29
|
foo@in.nl
|
30
|
+
f@example.com
|
30
31
|
}.each do |email|
|
31
32
|
assert_valid_email email
|
32
33
|
end
|
@@ -89,7 +90,7 @@ class ValidatesEmailTest < ActiveSupport::TestCase
|
|
89
90
|
|
90
91
|
test "adds a sensible default error message" do
|
91
92
|
@obj.email = 'foo.@example.com'; @obj.valid?
|
92
|
-
assert_match /is not a valid email address/, @obj.errors
|
93
|
+
assert_match /is not a valid email address/, @obj.errors['email'].to_s
|
93
94
|
end
|
94
95
|
|
95
96
|
test "allows the passing of all options allowed by validates_format_of" do
|
@@ -98,11 +99,11 @@ class ValidatesEmailTest < ActiveSupport::TestCase
|
|
98
99
|
|
99
100
|
def @obj.run_validation?; false; end
|
100
101
|
@obj.valid?
|
101
|
-
assert_no_match(/dude, that's sooo not an email address/, @obj.errors
|
102
|
+
assert_no_match(/dude, that's sooo not an email address/, @obj.errors['email'].to_s)
|
102
103
|
|
103
104
|
def @obj.run_validation?; true; end
|
104
105
|
@obj.valid?
|
105
|
-
assert_match /dude, that's sooo not an email address/, @obj.errors
|
106
|
+
assert_match /dude, that's sooo not an email address/, @obj.errors['email'].to_s
|
106
107
|
end
|
107
108
|
|
108
109
|
private
|
@@ -110,12 +111,12 @@ class ValidatesEmailTest < ActiveSupport::TestCase
|
|
110
111
|
def assert_valid_email(email)
|
111
112
|
@obj.email = email
|
112
113
|
@obj.valid?
|
113
|
-
assert @obj.errors
|
114
|
+
assert @obj.errors[:email].blank?, "Expected `#{email}' to be valid"
|
114
115
|
end
|
115
116
|
|
116
117
|
def assert_not_valid_email(email)
|
117
118
|
@obj.email = email
|
118
119
|
@obj.valid?
|
119
|
-
assert !@obj.errors
|
120
|
+
assert !@obj.errors[:email].blank?, "Expected `#{email}' to NOT be valid"
|
120
121
|
end
|
121
|
-
end
|
122
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,25 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_email-san
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Eloy Duran
|
8
9
|
- Manfred Stienstra
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2010-03-26 00:00:00 +01:00
|
14
|
-
default_executable:
|
13
|
+
date: 2009-09-07 00:00:00.000000000 Z
|
15
14
|
dependencies: []
|
16
|
-
|
17
15
|
description: A simple Rails plugin which adds a validates_email class method to ActiveRecord::Base.
|
18
16
|
email: eloy@fngtps.com
|
19
17
|
executables: []
|
20
|
-
|
21
18
|
extensions: []
|
22
|
-
|
23
|
-
extra_rdoc_files:
|
19
|
+
extra_rdoc_files:
|
24
20
|
- LICENSE
|
25
21
|
- README.rdoc
|
26
|
-
files:
|
22
|
+
files:
|
27
23
|
- LICENSE
|
28
24
|
- README.rdoc
|
29
25
|
- Rakefile
|
@@ -32,35 +28,31 @@ files:
|
|
32
28
|
- rails/init.rb
|
33
29
|
- test/test_helper.rb
|
34
30
|
- test/validates_email_san_test.rb
|
35
|
-
- validates_email-san.gemspec
|
36
|
-
has_rdoc: true
|
37
31
|
homepage: http://fingertips.github.com
|
38
32
|
licenses: []
|
39
|
-
|
40
33
|
post_install_message:
|
41
|
-
rdoc_options:
|
34
|
+
rdoc_options:
|
42
35
|
- --charset=UTF-8
|
43
|
-
require_paths:
|
36
|
+
require_paths:
|
44
37
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
57
50
|
requirements: []
|
58
|
-
|
59
51
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.
|
52
|
+
rubygems_version: 1.8.23
|
61
53
|
signing_key:
|
62
54
|
specification_version: 3
|
63
55
|
summary: A simple Rails plugin which adds a validates_email class method to ActiveRecord::Base.
|
64
|
-
test_files:
|
56
|
+
test_files:
|
65
57
|
- test/test_helper.rb
|
66
58
|
- test/validates_email_san_test.rb
|
data/validates_email-san.gemspec
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{validates_email-san}
|
5
|
-
s.version = "0.1.1"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Eloy Duran", "Manfred Stienstra"]
|
9
|
-
s.date = %q{2009-09-07}
|
10
|
-
s.description = %q{A simple Rails plugin which adds a validates_email class method to ActiveRecord::Base.}
|
11
|
-
s.email = %q{eloy@fngtps.com}
|
12
|
-
s.extra_rdoc_files = [
|
13
|
-
"LICENSE",
|
14
|
-
"README.rdoc"
|
15
|
-
]
|
16
|
-
s.files = [
|
17
|
-
"LICENSE",
|
18
|
-
"README.rdoc",
|
19
|
-
"Rakefile",
|
20
|
-
"VERSION.yml",
|
21
|
-
"lib/validates_email_san.rb",
|
22
|
-
"rails/init.rb",
|
23
|
-
"test/test_helper.rb",
|
24
|
-
"test/validates_email_san_test.rb"
|
25
|
-
]
|
26
|
-
s.homepage = %q{http://fingertips.github.com}
|
27
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
28
|
-
s.require_paths = ["lib"]
|
29
|
-
s.rubygems_version = %q{1.3.5}
|
30
|
-
s.summary = %q{A simple Rails plugin which adds a validates_email class method to ActiveRecord::Base.}
|
31
|
-
s.test_files = [
|
32
|
-
"test/test_helper.rb",
|
33
|
-
"test/validates_email_san_test.rb"
|
34
|
-
]
|
35
|
-
|
36
|
-
if s.respond_to? :specification_version then
|
37
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
|
-
s.specification_version = 3
|
39
|
-
|
40
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
41
|
-
else
|
42
|
-
end
|
43
|
-
else
|
44
|
-
end
|
45
|
-
end
|