validates-email 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3af80bbf3673dd75f17f46a52d6817b861ce3a7
4
+ data.tar.gz: 2930ef23fe317955807cdbf535af0e6ab4dfd93e
5
+ SHA512:
6
+ metadata.gz: a700d3f9d519359b687ea7d51309bd1539ca3e84ce707ff674c0767cb52b5c581dc63ff213a76d86333f537071757ccd79c179cacca4daea8c5f04f68d362c47
7
+ data.tar.gz: 6b170ebedf8fc2df974525beb204fdaec1c4771d51e56385c923bb89567f19203bafb67af26c1f53fc375d389421a25a57cae11c0a2610545557112c99a312f7
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.log
2
+ *.sqlite3
3
+ /pkg/*
4
+ .bundle
5
+ .ruby-version
6
+ spec/database.yml
7
+ tmp*.sw?
8
+ *.sw?
9
+ tmp
10
+ *.gem
11
+ *.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -1,4 +1,4 @@
1
- Copyright 2012 YOURNAME
1
+ Copyright (c) 2013 Dmitry Zudochkin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,25 +1,18 @@
1
- # Validates-email gem
2
- Small gem for rails adding validates_email functionality to your Active record models.
1
+ # validates-email
3
2
 
4
- ## Installation
5
- `gem install validates-email`
3
+ Description goes here.
6
4
 
7
- ## Usage examples
5
+ ## Contributing to validates-email
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
8
14
 
9
- You can write that
15
+ ## Copyright
10
16
 
11
- class User < ActiveRecord::Base
12
- attr_accessible :email, :name
13
-
14
- validates_email :email, :message => 'custom invalid email'
15
- end
16
-
17
- or that
18
-
19
- class Person < ActiveRecord::Base
20
- attr_accessible :email, :name
21
-
22
- validates :email, :email => true
23
- end
24
-
25
- It's my first gem, likely it can contains some bugs, errors. Do not use in production yet :)
17
+ Copyright (c) 2013 Dmitry Zudochkin. See LICENSE.txt for
18
+ further details.
data/Rakefile CHANGED
@@ -1,32 +1,11 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'ValidatesEmail'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.md')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
1
+ require 'bundler/setup'
22
2
 
23
- require 'rake/testtask'
3
+ desc 'Default: run specs'
4
+ task default: :spec
24
5
 
25
- Rake::TestTask.new(:test) do |t|
26
- t.libs << 'lib'
27
- t.libs << 'test'
28
- t.pattern = 'test/**/*_test.rb'
29
- t.verbose = false
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.pattern = 'spec/**/*_spec.rb'
30
9
  end
31
10
 
32
- task :default => :test
11
+ Bundler::GemHelper.install_tasks
@@ -1,6 +1,6 @@
1
- module ActiveRecord
1
+ module ValidatesEmail
2
2
  module Validations
3
- class EmailValidator < ActiveModel::EachValidator
3
+ class EmailValidator < ::ActiveModel::EachValidator
4
4
  def validate_each(record, attribute, value)
5
5
  record.errors[attribute] << (options[:message] || 'is invalid') unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
6
6
  end
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
 
9
9
  module ClassMethods
10
10
  def validates_email(*attr_names)
11
- validates_with EmailValidator, _merge_attributes(attr_names)
11
+ validates_with ValidatesEmail::Validations::EmailValidator, _merge_attributes(attr_names)
12
12
  end
13
13
  end
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatesEmail
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -1,4 +1,7 @@
1
1
  require 'active_record'
2
+ require 'method'
2
3
 
3
- module ValidatesEmail
4
+ class ActiveRecord::Base
5
+ extend ValidatesEmail::Validations::ClassMethods
6
+ ActiveRecord::Base.send :include, ValidatesEmail::Validations
4
7
  end
@@ -0,0 +1,3 @@
1
+ sqlite3:
2
+ adapter: sqlite3
3
+ database: validates-email.sqlite3
data/spec/models.rb ADDED
@@ -0,0 +1,7 @@
1
+ class User < ActiveRecord::Base
2
+ validates_email :email
3
+ end
4
+
5
+ class Person < ActiveRecord::Base
6
+ validates :email, email: true
7
+ end
data/spec/schema.rb ADDED
@@ -0,0 +1,9 @@
1
+ ActiveRecord::Schema.define version: 0 do
2
+ create_table 'users', force: true do |t|
3
+ t.string 'email'
4
+ end
5
+
6
+ create_table 'people', force: true do |t|
7
+ t.string 'email'
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ $LOAD_PATH << '.' unless $LOAD_PATH.include?('.')
2
+ require 'logger'
3
+
4
+ Bundler.require
5
+
6
+ require File.expand_path('../../lib/validates-email', __FILE__)
7
+
8
+ db_name = ENV['DB'] || 'sqlite3'
9
+ database_yml = File.expand_path('../database.yml', __FILE__)
10
+
11
+ if File.exists? database_yml
12
+ active_record_configuration = YAML.load_file database_yml
13
+
14
+ ActiveRecord::Base.configurations = active_record_configuration
15
+ config = ActiveRecord::Base.configurations[db_name]
16
+
17
+ begin
18
+ ActiveRecord::Base.establish_connection db_name
19
+ ActiveRecord::Base.connection
20
+ end
21
+
22
+ logger = ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'debug.log'))
23
+ ActiveRecord::Base.default_timezone = :utc
24
+
25
+ begin
26
+ old_logger_level, logger.level = logger.level, ::Logger::ERROR
27
+ ActiveRecord::Migration.verbose = false
28
+
29
+ load(File.dirname(__FILE__) + '/schema.rb')
30
+ load(File.dirname(__FILE__) + '/models.rb')
31
+ ensure
32
+ logger.level = old_logger_level
33
+ end
34
+ else
35
+ raise "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
36
+ end
37
+
38
+
39
+
40
+ RSpec.configure do |config|
41
+ config.treat_symbols_as_metadata_keys_with_true_values = true
42
+ config.run_all_when_everything_filtered = true
43
+ config.filter_run :focus
44
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ValidatesEmail' do
4
+ context '#validates_email notation' do
5
+ it 'should not be valid without an email' do
6
+ User.new.should_not be_valid
7
+ end
8
+
9
+ it 'should be valid with right email' do
10
+ User.new(email: 'kiesy@mail.ru').should be_valid
11
+ end
12
+ end
13
+
14
+ context '#validates notation' do
15
+ it 'should not be valid without an email' do
16
+ Person.new.should_not be_valid
17
+ end
18
+
19
+ it 'should be valid with right email' do
20
+ Person.new(email: 'kiesy@mail.ru').should be_valid
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'validates-email/version'
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = "validates-email"
10
+ gem.homepage = "http://github.com/vredniy/validates-email"
11
+ gem.license = "MIT"
12
+ gem.summary = %Q{Adding validates_email functionality}
13
+ gem.description = %Q{Some description for validates-gem}
14
+ gem.email = "dnd.pliz@gmail.com"
15
+ gem.authors = ["Dmitry Zudochkin"]
16
+ gem.version = ValidatesEmail::VERSION
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib"]
22
+
23
+ gem.add_runtime_dependency 'rails', ['>= 3', '< 5']
24
+
25
+ gem.add_development_dependency 'rspec-rails'
26
+ gem.add_development_dependency 'rspec'
27
+ gem.add_development_dependency 'sqlite3'
28
+ gem.add_development_dependency 'pry'
29
+ end
metadata CHANGED
@@ -1,84 +1,140 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates-email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dmitry Zudochkin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
11
+ date: 2013-06-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.9
19
+ version: '3'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
- - - ~>
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3'
30
+ - - <
28
31
  - !ruby/object:Gem::Version
29
- version: 3.2.9
32
+ version: '5'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec-rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
30
61
  - !ruby/object:Gem::Dependency
31
62
  name: sqlite3
32
63
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
64
  requirements:
35
- - - ! '>='
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: pry
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
36
80
  - !ruby/object:Gem::Version
37
81
  version: '0'
38
82
  type: :development
39
83
  prerelease: false
40
84
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
85
  requirements:
43
- - - ! '>='
86
+ - - '>='
44
87
  - !ruby/object:Gem::Version
45
88
  version: '0'
46
- description: In your models you can write validates_email :field instead of using
47
- regexp
48
- email:
49
- - dnd.pliz@gmail.com
89
+ description: Some description for validates-gem
90
+ email: dnd.pliz@gmail.com
50
91
  executables: []
51
92
  extensions: []
52
93
  extra_rdoc_files: []
53
94
  files:
54
- - lib/validates-email/version.rb
55
- - lib/active_record.rb
56
- - lib/validates-email.rb
57
- - MIT-LICENSE
58
- - Rakefile
95
+ - .document
96
+ - .gitignore
97
+ - .rspec
98
+ - Gemfile
99
+ - LICENSE.txt
59
100
  - README.md
60
- homepage: ''
61
- licenses: []
101
+ - Rakefile
102
+ - lib/method.rb
103
+ - lib/validates-email.rb
104
+ - lib/validates-email/version.rb
105
+ - spec/database.yml.sample
106
+ - spec/models.rb
107
+ - spec/schema.rb
108
+ - spec/spec_helper.rb
109
+ - spec/validates-email/validates-email_spec.rb
110
+ - validates-email.gemspec
111
+ homepage: http://github.com/vredniy/validates-email
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
62
115
  post_install_message:
63
116
  rdoc_options: []
64
117
  require_paths:
65
118
  - lib
66
119
  required_ruby_version: !ruby/object:Gem::Requirement
67
- none: false
68
120
  requirements:
69
- - - ! '>='
121
+ - - '>='
70
122
  - !ruby/object:Gem::Version
71
123
  version: '0'
72
124
  required_rubygems_version: !ruby/object:Gem::Requirement
73
- none: false
74
125
  requirements:
75
- - - ! '>='
126
+ - - '>='
76
127
  - !ruby/object:Gem::Version
77
128
  version: '0'
78
129
  requirements: []
79
130
  rubyforge_project:
80
- rubygems_version: 1.8.24
131
+ rubygems_version: 2.0.3
81
132
  signing_key:
82
- specification_version: 3
133
+ specification_version: 4
83
134
  summary: Adding validates_email functionality
84
- test_files: []
135
+ test_files:
136
+ - spec/database.yml.sample
137
+ - spec/models.rb
138
+ - spec/schema.rb
139
+ - spec/spec_helper.rb
140
+ - spec/validates-email/validates-email_spec.rb