email_validation 1.0.0 → 1.1.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.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -cfs
data/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
1
  source :rubygems
2
2
 
3
- # DEPENDENCIES
4
3
  gem 'localized_each_validator', '>= 1.0.1'
5
4
 
6
- # DEVELOPMENT
7
- gem 'jeweler'
8
- gem 'yard'
9
- gem 'RedCloth', require: 'redcloth'
10
-
5
+ group :development do
6
+ gem 'jeweler'
7
+ gem 'yard'
8
+ gem 'RedCloth', require: 'redcloth'
9
+ gem 'rspec'
10
+ end
data/Gemfile.lock CHANGED
@@ -1,35 +1,40 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- RedCloth (4.2.3)
5
- activemodel (3.0.1)
6
- activesupport (= 3.0.1)
4
+ RedCloth (4.2.7)
5
+ activemodel (3.0.5)
6
+ activesupport (= 3.0.5)
7
7
  builder (~> 2.1.2)
8
- i18n (~> 0.4.1)
9
- activerecord (3.0.1)
10
- activemodel (= 3.0.1)
11
- activesupport (= 3.0.1)
12
- arel (~> 1.0.0)
8
+ i18n (~> 0.4)
9
+ activerecord (3.0.5)
10
+ activemodel (= 3.0.5)
11
+ activesupport (= 3.0.5)
12
+ arel (~> 2.0.2)
13
13
  tzinfo (~> 0.3.23)
14
- activesupport (3.0.1)
15
- arel (1.0.1)
16
- activesupport (~> 3.0.0)
14
+ activesupport (3.0.5)
15
+ arel (2.0.9)
17
16
  builder (2.1.2)
18
- gemcutter (0.6.1)
17
+ diff-lcs (1.1.2)
19
18
  git (1.2.5)
20
- i18n (0.4.2)
21
- jeweler (1.4.0)
22
- gemcutter (>= 0.1.0)
19
+ i18n (0.5.0)
20
+ jeweler (1.5.2)
21
+ bundler (~> 1.0.0)
23
22
  git (>= 1.2.5)
24
- rubyforge (>= 2.0.0)
25
- json_pure (1.4.6)
23
+ rake
26
24
  localized_each_validator (1.0.1)
27
25
  activerecord (>= 3.0)
28
26
  activesupport (>= 3.0)
29
- rubyforge (2.0.4)
30
- json_pure (>= 1.1.7)
31
- tzinfo (0.3.23)
32
- yard (0.6.1)
27
+ rake (0.8.7)
28
+ rspec (2.5.0)
29
+ rspec-core (~> 2.5.0)
30
+ rspec-expectations (~> 2.5.0)
31
+ rspec-mocks (~> 2.5.0)
32
+ rspec-core (2.5.1)
33
+ rspec-expectations (2.5.0)
34
+ diff-lcs (~> 1.1.2)
35
+ rspec-mocks (2.5.0)
36
+ tzinfo (0.3.25)
37
+ yard (0.6.5)
33
38
 
34
39
  PLATFORMS
35
40
  ruby
@@ -38,4 +43,5 @@ DEPENDENCIES
38
43
  RedCloth
39
44
  jeweler
40
45
  localized_each_validator (>= 1.0.1)
46
+ rspec
41
47
  yard
data/README.textile CHANGED
@@ -1,7 +1,7 @@
1
1
  h1. email_validation -- Simple email validator for Rails 3
2
2
 
3
3
  | *Author* | Tim Morgan |
4
- | *Version* | 1.0 (Oct 30, 2010) |
4
+ | *Version* | 1.1 (Mar 23, 2011) |
5
5
  | *License* | Released under the MIT license. |
6
6
 
7
7
  h2. About
data/Rakefile CHANGED
@@ -1,13 +1,15 @@
1
- require 'rake'
1
+ require 'rubygems'
2
+ require 'bundler'
2
3
  begin
3
- require 'bundler'
4
- rescue LoadError
5
- puts "Bundler is not installed; install with `gem install bundler`."
6
- exit 1
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
7
9
  end
10
+ require 'rake'
8
11
 
9
- Bundler.require :default
10
-
12
+ require 'jeweler'
11
13
  Jeweler::Tasks.new do |gem|
12
14
  gem.name = "email_validation"
13
15
  gem.summary = %Q{Simple email validation in Rails 3}
@@ -15,10 +17,10 @@ Jeweler::Tasks.new do |gem|
15
17
  gem.email = "git@timothymorgan.info"
16
18
  gem.homepage = "http://github.com/riscfuture/email_validation"
17
19
  gem.authors = [ "Tim Morgan" ]
18
- gem.add_dependency 'localized_each_validator', '>= 1.0.1'
19
20
  end
20
- Jeweler::GemcutterTasks.new
21
+ Jeweler::RubygemsDotOrgTasks.new
21
22
 
23
+ require 'yard'
22
24
  YARD::Rake::YardocTask.new('doc') do |doc|
23
25
  doc.options << "-m" << "textile"
24
26
  doc.options << "--protected"
@@ -28,3 +30,8 @@ YARD::Rake::YardocTask.new('doc') do |doc|
28
30
 
29
31
  doc.files = [ 'lib/*_validator.rb', 'README.textile' ]
30
32
  end
33
+
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new
36
+
37
+ task(default: :spec)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -1,50 +1,66 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{email_validation}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tim Morgan"]
12
- s.date = %q{2010-10-31}
12
+ s.date = %q{2011-03-23}
13
13
  s.description = %q{A simple, localizable EachValidator for email address fields in ActiveRecord 3.0.}
14
14
  s.email = %q{git@timothymorgan.info}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.textile"
17
+ "README.textile"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE",
25
- "README.textile",
26
- "Rakefile",
27
- "VERSION",
28
- "email_validation.gemspec",
29
- "lib/email_validation.rb"
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.textile",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "email_validation.gemspec",
29
+ "lib/email_validation.rb",
30
+ "spec/email_validator_spec.rb",
31
+ "spec/spec_helper.rb"
30
32
  ]
31
33
  s.homepage = %q{http://github.com/riscfuture/email_validation}
32
- s.rdoc_options = ["--charset=UTF-8"]
33
34
  s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.3.7}
35
+ s.rubygems_version = %q{1.6.2}
35
36
  s.summary = %q{Simple email validation in Rails 3}
37
+ s.test_files = [
38
+ "spec/email_validator_spec.rb",
39
+ "spec/spec_helper.rb"
40
+ ]
36
41
 
37
42
  if s.respond_to? :specification_version then
38
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
43
  s.specification_version = 3
40
44
 
41
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
46
  s.add_runtime_dependency(%q<localized_each_validator>, [">= 1.0.1"])
47
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
48
+ s.add_development_dependency(%q<yard>, [">= 0"])
49
+ s.add_development_dependency(%q<RedCloth>, [">= 0"])
50
+ s.add_development_dependency(%q<rspec>, [">= 0"])
43
51
  else
44
52
  s.add_dependency(%q<localized_each_validator>, [">= 1.0.1"])
53
+ s.add_dependency(%q<jeweler>, [">= 0"])
54
+ s.add_dependency(%q<yard>, [">= 0"])
55
+ s.add_dependency(%q<RedCloth>, [">= 0"])
56
+ s.add_dependency(%q<rspec>, [">= 0"])
45
57
  end
46
58
  else
47
59
  s.add_dependency(%q<localized_each_validator>, [">= 1.0.1"])
60
+ s.add_dependency(%q<jeweler>, [">= 0"])
61
+ s.add_dependency(%q<yard>, [">= 0"])
62
+ s.add_dependency(%q<RedCloth>, [">= 0"])
63
+ s.add_dependency(%q<rspec>, [">= 0"])
48
64
  end
49
65
  end
50
66
 
@@ -11,10 +11,13 @@ require 'localized_each_validator'
11
11
  # | @:allow_nil@ | If true, @nil@ values are allowed. |
12
12
 
13
13
  class EmailValidator < LocalizedEachValidator
14
+ # Regular expression describing valid emails
15
+ EMAIL_REGEX = "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}"
16
+
14
17
  error_key :invalid_email
15
18
 
16
19
  # @private
17
20
  def valid?(_, _, value)
18
- value =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
21
+ value =~ /^#{EMAIL_REGEX}$/i || value =~ /^.+\s+<#{EMAIL_REGEX}>$/i
19
22
  end
20
23
  end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe EmailValidator do
4
+ before :each do
5
+ @validator = EmailValidator.new({ attributes: [ :foo, :bar ] })
6
+ end
7
+
8
+ it "should validate an email address" do
9
+ @validator.valid?(nil, nil, 'foo@bar.com').should be_true
10
+ end
11
+
12
+ it "should validate a name and email pair" do
13
+ @validator.valid?(nil, nil, 'Foo Bar <foo@bar.com>').should be_true
14
+ end
15
+
16
+ it "should not validate an improper email address" do
17
+ @validator.valid?(nil, nil, 'foo@bar').should be_false
18
+ @validator.valid?(nil, nil, 'fo oo@bar.com').should be_false
19
+ @validator.valid?(nil, nil, 'foo@bar@bar.com').should be_false
20
+ @validator.valid?(nil, nil, 'foo@.com').should be_false
21
+ end
22
+
23
+ it "should not validate an improper name and email pair" do
24
+ @validator.valid?(nil, nil, 'Foo Bar <foo@bar>').should be_false
25
+ @validator.valid?(nil, nil, 'Foo Bar <fo oo@bar.com>').should be_false
26
+ @validator.valid?(nil, nil, 'Foo Bar <foo@bar@bar.com>').should be_false
27
+ @validator.valid?(nil, nil, 'Foo Bar <foo@.com>').should be_false
28
+ @validator.valid?(nil, nil, '<foo@bar.com> Foo Bar').should be_false
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ Bundler.require :default, :test
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+
6
+ require 'email_validation'
7
+
8
+ RSpec.configure do |c|
9
+ c.mock_with :rspec
10
+ end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_validation
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 0
9
- version: 1.0.0
4
+ prerelease:
5
+ version: 1.1.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Tim Morgan
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-10-31 00:00:00 -07:00
13
+ date: 2011-03-23 00:00:00 -07:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -24,14 +20,54 @@ dependencies:
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 0
30
- - 1
31
23
  version: 1.0.1
32
24
  type: :runtime
33
25
  prerelease: false
34
26
  version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: jeweler
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: yard
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: RedCloth
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
35
71
  description: A simple, localizable EachValidator for email address fields in ActiveRecord 3.0.
36
72
  email: git@timothymorgan.info
37
73
  executables: []
@@ -43,7 +79,7 @@ extra_rdoc_files:
43
79
  - README.textile
44
80
  files:
45
81
  - .document
46
- - .gitignore
82
+ - .rspec
47
83
  - Gemfile
48
84
  - Gemfile.lock
49
85
  - LICENSE
@@ -52,13 +88,15 @@ files:
52
88
  - VERSION
53
89
  - email_validation.gemspec
54
90
  - lib/email_validation.rb
91
+ - spec/email_validator_spec.rb
92
+ - spec/spec_helper.rb
55
93
  has_rdoc: true
56
94
  homepage: http://github.com/riscfuture/email_validation
57
95
  licenses: []
58
96
 
59
97
  post_install_message:
60
- rdoc_options:
61
- - --charset=UTF-8
98
+ rdoc_options: []
99
+
62
100
  require_paths:
63
101
  - lib
64
102
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -66,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
104
  requirements:
67
105
  - - ">="
68
106
  - !ruby/object:Gem::Version
69
- hash: -2013038120930311290
107
+ hash: 318508982850022341
70
108
  segments:
71
109
  - 0
72
110
  version: "0"
@@ -75,15 +113,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
113
  requirements:
76
114
  - - ">="
77
115
  - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
116
  version: "0"
81
117
  requirements: []
82
118
 
83
119
  rubyforge_project:
84
- rubygems_version: 1.3.7
120
+ rubygems_version: 1.6.2
85
121
  signing_key:
86
122
  specification_version: 3
87
123
  summary: Simple email validation in Rails 3
88
- test_files: []
89
-
124
+ test_files:
125
+ - spec/email_validator_spec.rb
126
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,25 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
- .bundle
21
- .rvmrc
22
-
23
- ## PROJECT::DOCUMENTATION
24
- .yardoc
25
- doc