validates 0.0.7 → 0.0.8

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/.gitignore CHANGED
@@ -2,3 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ doc/
6
+ .yardoc
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ script: "bundle exec turn -Itest test/lib"
@@ -0,0 +1,4 @@
1
+ --title "validates"
2
+ --readme README.md
3
+ -
4
+ LICENSE
data/Gemfile CHANGED
@@ -1,8 +1,7 @@
1
- source "http://rubygems.org"
1
+ source :rubygems
2
2
 
3
- # Specify your gem's dependencies in validates.gemspec
4
3
  gemspec
5
4
 
6
- gem 'minitest'
7
- gem 'turn'
8
5
  gem 'rake'
6
+ gem 'turn'
7
+ gem 'minitest'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Mikhail Stolbov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
- # Validates
1
+ # Validates [![Build Status](https://travis-ci.org/kaize/validates.png)](https://travis-ci.org/kaize/validates)
2
2
 
3
- [![Build Status](https://travis-ci.org/kaize/validates.png)](https://travis-ci.org/kaize/validates)
3
+ Collection of useful custom validators for Rails 3 applications, including:
4
4
 
5
- Simple format validators for Rails 3
5
+ - EmailValidator
6
+ - UrlValidator
7
+ - SlugValidator
8
+ - MoneyValidator
9
+ - InnValidator
10
+ - AssociationLengthValidator
6
11
 
7
12
  ## Installation
8
13
 
@@ -10,17 +15,26 @@ Add this line to your application's Gemfile:
10
15
 
11
16
  gem 'validates'
12
17
 
13
- And then execute:
14
-
15
- $ bundle
16
-
17
18
  Or install it yourself as:
18
19
 
19
20
  $ gem install 'validates'
20
21
 
21
22
  ## Usage
22
23
 
23
- Availables validators: AssociationLength, Email, Existence, Slug, Url, Money
24
+ For most of the validators you just want to add this line to your model:
25
+
26
+ validates :attribute, <validator_underscore>: true
27
+
28
+ where `<validator_underscore>` is an underscored, lowercase form from the validator's name (see the examples section below).
29
+
30
+ ### AssociationLengthValidator
31
+
32
+ Because this is the successor of ActiveModel::Validations::LengthValidator
33
+ validator, it inherits all the options of the latter, such as `:is`, `:minimum`,
34
+ `:maximum`, etc. Another option, which you may be interested in is `:select` option,
35
+ which allows you to filter the collection of the associated objects.
36
+
37
+ ## Examples
24
38
 
25
39
  class User < ActiveRecord::Base
26
40
  validates :email, :email => true
@@ -55,9 +69,6 @@ Availables validators: AssociationLength, Email, Existence, Slug, Url, Money
55
69
  1. Fork it
56
70
  2. Create your feature branch (`git checkout -b my-new-feature`)
57
71
  3. Commit your changes (`git commit -am 'Added some feature'`)
58
- 4. Push to the branch (`git push origin my-new-feature`)
59
- 5. Create new Pull Request
60
-
61
- run tests:
62
-
63
- turn -Itest test/lib
72
+ 4. Test your changes by running `turn -Itest test/lib` command
73
+ 5. Push to the branch (`git push origin my-new-feature`)
74
+ 6. Create new Pull Request
@@ -20,7 +20,7 @@ class EmailValidator < ActiveModel::EachValidator
20
20
  LOCAL_ALLOWED_CHARS = '(?:[a-z0-9A-Z\!\#\$\%\&\'\*\-\/\=\?\+\-\^\_\`\{\|\}\~]|(?<!(?:^|\.))\.(?!$))'
21
21
 
22
22
  def valid?(value)
23
- email_format_valid?(value)
23
+ email_format_valid?(value.to_s)
24
24
  end
25
25
 
26
26
  private
@@ -1,8 +1,9 @@
1
- [:email, :existence, :inn, :money, :slug, :url].each do |name|
2
- autoload :"#{name.capitalize}Validator", "#{name}_validator"
3
- end
1
+ require 'active_support/core_ext/string/inflections'
2
+ require 'active_model'
4
3
 
5
- require 'active_model' # why i need do it?
4
+ [:email, :association_length, :inn, :money, :slug, :url].each do |name|
5
+ autoload :"#{name.to_s.classify}Validator", "#{name}_validator"
6
+ end
6
7
 
7
8
  module Validates
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module Validates
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -7,18 +7,23 @@ Gem::Specification.new do |s|
7
7
  s.version = Validates::VERSION
8
8
  s.authors = ["Mikhail Stolbov","Anton Taraev","Konstantin Kosmatov","Andrey Subbota"]
9
9
  s.email = ["mstolbov@gmail.com","anti191@gmail.com","key@kosmatov.su","subbota@gmail.com"]
10
- s.homepage = "https://github.com/kaize/validates"
11
- s.summary = "Collection of simple validators for Rails 3"
12
- s.description = "Email, Slug, Url, Money, INN validators for Rails 3"
10
+ s.homepage = "http://github.com/kaize/validates"
11
+ s.summary = %q{Collection of useful custom validators for Rails 3 applications}
12
+ s.description = %q{validates provides a set of commonly required validators (such as Email, Url, etc.) for Rails 3 applications}
13
13
 
14
14
  s.rubyforge_project = "validates"
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+
19
20
  s.require_paths = ["lib"]
20
21
 
22
+ s.rdoc_options = %w(--line-numbers --inline-source --title validates --main README.md)
23
+ s.extra_rdoc_files = %w(README.md LICENSE)
24
+
21
25
  # specify any dependencies here; for example:
22
26
  # s.add_development_dependency "rspec"
23
- s.add_runtime_dependency "activemodel", [">= 3.0.0"]
27
+ s.add_dependency "activemodel", [">= 3.0.0"]
28
+ s.add_dependency "activesupport", [">= 3.0.0"]
24
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-10-23 00:00:00.000000000 Z
15
+ date: 2012-11-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activemodel
@@ -30,7 +30,24 @@ dependencies:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.0.0
33
- description: Email, Slug, Url, Money, INN validators for Rails 3
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ requirement: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: 3.0.0
49
+ description: validates provides a set of commonly required validators (such as Email,
50
+ Url, etc.) for Rails 3 applications
34
51
  email:
35
52
  - mstolbov@gmail.com
36
53
  - anti191@gmail.com
@@ -38,10 +55,15 @@ email:
38
55
  - subbota@gmail.com
39
56
  executables: []
40
57
  extensions: []
41
- extra_rdoc_files: []
58
+ extra_rdoc_files:
59
+ - README.md
60
+ - LICENSE
42
61
  files:
43
62
  - .gitignore
63
+ - .travis.yml
64
+ - .yardopts
44
65
  - Gemfile
66
+ - LICENSE
45
67
  - README.md
46
68
  - Rakefile
47
69
  - lib/association_length_validator.rb
@@ -55,10 +77,16 @@ files:
55
77
  - test/lib/email_validator_test.rb
56
78
  - test/test_helper.rb
57
79
  - validates.gemspec
58
- homepage: https://github.com/kaize/validates
80
+ homepage: http://github.com/kaize/validates
59
81
  licenses: []
60
82
  post_install_message:
61
- rdoc_options: []
83
+ rdoc_options:
84
+ - --line-numbers
85
+ - --inline-source
86
+ - --title
87
+ - validates
88
+ - --main
89
+ - README.md
62
90
  require_paths:
63
91
  - lib
64
92
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -78,6 +106,6 @@ rubyforge_project: validates
78
106
  rubygems_version: 1.8.24
79
107
  signing_key:
80
108
  specification_version: 3
81
- summary: Collection of simple validators for Rails 3
109
+ summary: Collection of useful custom validators for Rails 3 applications
82
110
  test_files: []
83
111
  has_rdoc: