aurels-misc_validators 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/Manifest +11 -0
- data/README.rdoc +30 -0
- data/Rakefile +36 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/misc_validators.rb +23 -0
- data/misc_validators.gemspec +32 -0
- data/tasks/misc_validators_tasks.rake +4 -0
- data/test/misc_validators_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +72 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
== MiscValidators
|
2
|
+
|
3
|
+
A compilation of simple validators we need in most rails apps (AR based).
|
4
|
+
|
5
|
+
== Examples
|
6
|
+
|
7
|
+
Validation of an email address:
|
8
|
+
|
9
|
+
class MyModel < ActiveRecord::Base
|
10
|
+
validates_email :my_email_field
|
11
|
+
end
|
12
|
+
|
13
|
+
Validation of an URL:
|
14
|
+
|
15
|
+
class MyModel < ActiveRecord::Base
|
16
|
+
validates_url :my_url_field
|
17
|
+
end
|
18
|
+
|
19
|
+
== Installation
|
20
|
+
|
21
|
+
As a gem:
|
22
|
+
|
23
|
+
sudo sources -a http://gems.github.com
|
24
|
+
sudo gem install aurels-misc_validators
|
25
|
+
|
26
|
+
As a plugin in your app:
|
27
|
+
|
28
|
+
script/plugin install git://github.com/aurels/misc_validators.git
|
29
|
+
|
30
|
+
Copyright (c) 2009 Aurélien Malisart, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'echoe'
|
6
|
+
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc 'Test the misc_validators plugin.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate documentation for the misc_validators plugin.'
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'MiscValidators'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
26
|
+
|
27
|
+
Echoe.new('misc_validators', '0.1') do |p|
|
28
|
+
p.description = 'A collection of misc usefull validators for ActiveRecord::Base'
|
29
|
+
p.url = 'http://github.com/aurels/misc_validators'
|
30
|
+
p.author = 'Aurélien Malisart'
|
31
|
+
p.email = 'aurelien.malisart@gmail.com'
|
32
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
33
|
+
p.development_dependencies = []
|
34
|
+
end
|
35
|
+
|
36
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module MiscValidators
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def validates_email(field_sym, options = {})
|
9
|
+
validates_format_of(field_sym,
|
10
|
+
options.merge(
|
11
|
+
:with => /(\A(\s*)\Z)|(\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z)/i
|
12
|
+
))
|
13
|
+
end
|
14
|
+
|
15
|
+
def validates_url(field_sym, options = {})
|
16
|
+
validates_format_of(field_sym,
|
17
|
+
options.merge(
|
18
|
+
:with => /^(http|https):\/\/[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
|
19
|
+
))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{misc_validators}
|
5
|
+
s.version = "0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Aur\303\251lien Malisart"]
|
9
|
+
s.date = %q{2009-05-14}
|
10
|
+
s.description = %q{A collection of misc usefull validators for ActiveRecord::Base}
|
11
|
+
s.email = %q{aurelien.malisart@gmail.com}
|
12
|
+
s.extra_rdoc_files = ["lib/misc_validators.rb", "README.rdoc", "tasks/misc_validators_tasks.rake"]
|
13
|
+
s.files = ["init.rb", "install.rb", "lib/misc_validators.rb", "MIT-LICENSE", "Rakefile", "README.rdoc", "tasks/misc_validators_tasks.rake", "test/misc_validators_test.rb", "test/test_helper.rb", "uninstall.rb", "Manifest", "misc_validators.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/aurels/misc_validators}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Misc_validators", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{misc_validators}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{A collection of misc usefull validators for ActiveRecord::Base}
|
21
|
+
s.test_files = ["test/misc_validators_test.rb", "test/test_helper.rb"]
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 2
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
+
else
|
29
|
+
end
|
30
|
+
else
|
31
|
+
end
|
32
|
+
end
|
data/test/test_helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aurels-misc_validators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Aur\xC3\xA9lien Malisart"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-14 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A collection of misc usefull validators for ActiveRecord::Base
|
17
|
+
email: aurelien.malisart@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- lib/misc_validators.rb
|
24
|
+
- README.rdoc
|
25
|
+
- tasks/misc_validators_tasks.rake
|
26
|
+
files:
|
27
|
+
- init.rb
|
28
|
+
- install.rb
|
29
|
+
- lib/misc_validators.rb
|
30
|
+
- MIT-LICENSE
|
31
|
+
- Rakefile
|
32
|
+
- README.rdoc
|
33
|
+
- tasks/misc_validators_tasks.rake
|
34
|
+
- test/misc_validators_test.rb
|
35
|
+
- test/test_helper.rb
|
36
|
+
- uninstall.rb
|
37
|
+
- Manifest
|
38
|
+
- misc_validators.gemspec
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/aurels/misc_validators
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --line-numbers
|
44
|
+
- --inline-source
|
45
|
+
- --title
|
46
|
+
- Misc_validators
|
47
|
+
- --main
|
48
|
+
- README.rdoc
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "1.2"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: misc_validators
|
66
|
+
rubygems_version: 1.2.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: A collection of misc usefull validators for ActiveRecord::Base
|
70
|
+
test_files:
|
71
|
+
- test/misc_validators_test.rb
|
72
|
+
- test/test_helper.rb
|