validates_formatting_of 0.8.0 → 0.8.1
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.
- checksums.yaml +7 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +4 -0
- data/lib/validates_formatting_of/validation_addition.rb +3 -3
- data/lib/validates_formatting_of/validator.rb +5 -1
- data/lib/validates_formatting_of/version.rb +1 -1
- data/spec/validates_formatting_of/validation_addition_spec.rb +2 -2
- data/spec/validates_formatting_of/validation_spec.rb +4 -4
- data/validates_formatting_of.gemspec +1 -1
- metadata +16 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 252aa1819d51863c3f14259517c47693e15cc0e9
|
4
|
+
data.tar.gz: 1b77589cba97bc4bd7b5f1620254f005d3199b68
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 78f53eaef519be439ad5cec07dc7b508a093edc0de77f7df0bc87f52b5b0a4d3996c260208900fb597c11e8830ffb319fece4e6f051e4ce15d3a97a9737ced5d
|
7
|
+
data.tar.gz: 0cfbe50ae8897a4126f7fe37748d7267db315aeb02142c2a569fe725df136f4edcef3c0496074c6707313931a623b2b52fbe2ac18fe7bd3d5d545a088b928ca4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -13,13 +13,13 @@ module ValidatesFormattingOf
|
|
13
13
|
|
14
14
|
def add(name, regex, message = nil)
|
15
15
|
@validations ||= {}
|
16
|
-
@validations[name.
|
16
|
+
@validations[name.to_s] = Validation.new(name.to_sym, regex, message)
|
17
17
|
end
|
18
18
|
|
19
19
|
def find(attribute, opts = {})
|
20
20
|
method = opts.fetch(:using, attribute)
|
21
21
|
raise MissingValidation.new(method) if missing? method
|
22
|
-
@validations[method.
|
22
|
+
@validations[method.to_s]
|
23
23
|
end
|
24
24
|
|
25
25
|
def missing?(name)
|
@@ -27,7 +27,7 @@ module ValidatesFormattingOf
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def exists?(name)
|
30
|
-
@validations[name.
|
30
|
+
@validations[name.to_s].present?
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'active_support/core_ext/hash/reverse_merge'
|
2
|
+
require 'active_support/core_ext/string'
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'active_model/validator'
|
2
5
|
require 'active_model/validations'
|
3
6
|
|
7
|
+
|
4
8
|
module ValidatesFormattingOf
|
5
9
|
module Validations
|
6
10
|
class Validator < ActiveModel::Validations::FormatValidator
|
@@ -23,4 +27,4 @@ module ValidatesFormattingOf
|
|
23
27
|
RUBY_EVAL
|
24
28
|
end
|
25
29
|
end
|
26
|
-
end
|
30
|
+
end
|
@@ -17,8 +17,8 @@ module ValidatesFormattingOf
|
|
17
17
|
it "should be able to add new validations" do
|
18
18
|
TestAdding.add :another, /another/i
|
19
19
|
TestAdding.validations.count.should == 2
|
20
|
-
TestAdding.validations[
|
21
|
-
TestAdding.validations[
|
20
|
+
TestAdding.validations['email'].should be_instance_of Validation
|
21
|
+
TestAdding.validations['another'].should be_instance_of Validation
|
22
22
|
end
|
23
23
|
describe "find" do
|
24
24
|
context "implicit validation method" do
|
@@ -16,14 +16,14 @@ module ValidatesFormattingOf
|
|
16
16
|
end
|
17
17
|
context "invalid validation creation" do
|
18
18
|
it "should raise an error if the specified regex is not a Regexp objct" do
|
19
|
-
expect { Validation.new(:name, 123, "is an invalid value") }.to raise_error
|
19
|
+
expect { Validation.new(:name, 123, "is an invalid value") }.to raise_error
|
20
20
|
end
|
21
21
|
it "should not raise an error if the specified regex is a proc or a lambda" do
|
22
|
-
expect { Validation.new(:name, lambda { "my record" }, "is an invalid value") }.not_to raise_error
|
23
|
-
expect { Validation.new(:name, proc { "my record" }, "is an invalid value") }.not_to raise_error
|
22
|
+
expect { Validation.new(:name, lambda { "my record" }, "is an invalid value") }.not_to raise_error
|
23
|
+
expect { Validation.new(:name, proc { "my record" }, "is an invalid value") }.not_to raise_error
|
24
24
|
end
|
25
25
|
it "should not raise an error if the regex if valid" do
|
26
|
-
expect { Validation.new(:name, /something/i, "is an invalid value") }.not_to raise_error
|
26
|
+
expect { Validation.new(:name, /something/i, "is an invalid value") }.not_to raise_error
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = ValidatesFormattingOf::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency "activemodel", "~>
|
18
|
+
gem.add_dependency "activemodel", "~> 4.0"
|
19
19
|
|
20
20
|
gem.add_development_dependency "rake"
|
21
21
|
gem.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,78 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_formatting_of
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
5
|
-
prerelease:
|
4
|
+
version: 0.8.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Bridges
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activemodel
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '4.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '4.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: simplecov
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
description: Common Rails validations wrapped in a gem.
|
@@ -106,27 +97,26 @@ files:
|
|
106
97
|
- validates_formatting_of.gemspec
|
107
98
|
homepage: https://github.com/mattdbridges/validates_formatting_of
|
108
99
|
licenses: []
|
100
|
+
metadata: {}
|
109
101
|
post_install_message:
|
110
102
|
rdoc_options: []
|
111
103
|
require_paths:
|
112
104
|
- lib
|
113
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
106
|
requirements:
|
116
|
-
- -
|
107
|
+
- - '>='
|
117
108
|
- !ruby/object:Gem::Version
|
118
109
|
version: '0'
|
119
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
111
|
requirements:
|
122
|
-
- -
|
112
|
+
- - '>='
|
123
113
|
- !ruby/object:Gem::Version
|
124
114
|
version: '0'
|
125
115
|
requirements: []
|
126
116
|
rubyforge_project:
|
127
|
-
rubygems_version: 1.
|
117
|
+
rubygems_version: 2.1.1
|
128
118
|
signing_key:
|
129
|
-
specification_version:
|
119
|
+
specification_version: 4
|
130
120
|
summary: Adds several convenient methods to validate things such as emails, urls,
|
131
121
|
and phone numbers in a Rails application
|
132
122
|
test_files:
|
@@ -135,3 +125,4 @@ test_files:
|
|
135
125
|
- spec/validates_formatting_of/validation_addition_spec.rb
|
136
126
|
- spec/validates_formatting_of/validation_spec.rb
|
137
127
|
- spec/validates_formatting_of/validator_spec.rb
|
128
|
+
has_rdoc:
|