validates_subset 1.0.2 → 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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +4 -1
- data/Gemfile +1 -7
- data/Gemfile.lock +14 -49
- data/LICENSE.txt +22 -0
- data/lib/arguments.rb +1 -1
- data/lib/validates_subset.rb +15 -2
- data/locale/en.yml +4 -0
- data/locale/pl.yml +4 -0
- data/locale/sv.yml +4 -0
- data/spec/integration/modifiers/allow_blank_spec.rb +1 -1
- data/spec/integration/modifiers/allow_nil_spec.rb +1 -1
- data/spec/integration/modifiers/if_spec.rb +1 -1
- data/spec/integration/modifiers/message_spec.rb +1 -1
- data/spec/integration/modifiers/multiple_spec.rb +1 -1
- data/spec/integration/modifiers/unless_spec.rb +2 -2
- data/validates_subset.gemspec +1 -1
- data/version.rb +4 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b8541c955ec99c6f3927a09fe5b529ec4731283
|
4
|
+
data.tar.gz: f345e04b8700cc02bab8f7275566994cabf72fec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c9780c06be8db238014e199d8dd1ed70c87cca86e88eaf1fd512ec8cea7c2cc1111c30dc61b53f8d74436a563c8be1fb5eeef1ee6c4c39dd5bfe46305f322ac
|
7
|
+
data.tar.gz: b9c6e67b0cd46f8a49d82ecb06f1c119baf54e8ad852d9ba159dd85dbbcdee27498d87e192b96ef0193a33823b7e390920b100f80eb6263a510735be4895ce3f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,57 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
validates_subset (1.0.3)
|
5
|
+
activemodel (>= 3.0)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: https://rubygems.org/
|
3
9
|
specs:
|
4
|
-
activemodel (4.2.
|
5
|
-
activesupport (= 4.2.
|
10
|
+
activemodel (4.2.3)
|
11
|
+
activesupport (= 4.2.3)
|
6
12
|
builder (~> 3.1)
|
7
|
-
activesupport (4.2.
|
13
|
+
activesupport (4.2.3)
|
8
14
|
i18n (~> 0.7)
|
9
15
|
json (~> 1.7, >= 1.7.7)
|
10
16
|
minitest (~> 5.1)
|
11
17
|
thread_safe (~> 0.3, >= 0.3.4)
|
12
18
|
tzinfo (~> 1.1)
|
13
19
|
builder (3.2.2)
|
14
|
-
celluloid (0.16.0)
|
15
|
-
timers (~> 4.0.0)
|
16
|
-
coderay (1.1.0)
|
17
20
|
diff-lcs (1.2.5)
|
18
|
-
ffi (1.9.8)
|
19
|
-
formatador (0.2.5)
|
20
|
-
guard (2.12.5)
|
21
|
-
formatador (>= 0.2.4)
|
22
|
-
listen (~> 2.7)
|
23
|
-
lumberjack (~> 1.0)
|
24
|
-
nenv (~> 0.1)
|
25
|
-
notiffany (~> 0.0)
|
26
|
-
pry (>= 0.9.12)
|
27
|
-
shellany (~> 0.0)
|
28
|
-
thor (>= 0.18.1)
|
29
|
-
guard-compat (1.2.1)
|
30
|
-
guard-rspec (4.5.2)
|
31
|
-
guard (~> 2.1)
|
32
|
-
guard-compat (~> 1.1)
|
33
|
-
rspec (>= 2.99.0, < 4.0)
|
34
|
-
hitimes (1.2.2)
|
35
21
|
i18n (0.7.0)
|
36
22
|
json (1.8.3)
|
37
|
-
listen (2.10.0)
|
38
|
-
celluloid (~> 0.16.0)
|
39
|
-
rb-fsevent (>= 0.9.3)
|
40
|
-
rb-inotify (>= 0.9)
|
41
|
-
lumberjack (1.0.9)
|
42
|
-
method_source (0.8.2)
|
43
23
|
minitest (5.7.0)
|
44
|
-
|
45
|
-
notiffany (0.0.6)
|
46
|
-
nenv (~> 0.1)
|
47
|
-
shellany (~> 0.0)
|
48
|
-
pry (0.10.1)
|
49
|
-
coderay (~> 1.1.0)
|
50
|
-
method_source (~> 0.8.1)
|
51
|
-
slop (~> 3.4)
|
52
|
-
rb-fsevent (0.9.5)
|
53
|
-
rb-inotify (0.9.5)
|
54
|
-
ffi (>= 0.5.0)
|
24
|
+
rake (10.4.2)
|
55
25
|
rspec (3.2.0)
|
56
26
|
rspec-core (~> 3.2.0)
|
57
27
|
rspec-expectations (~> 3.2.0)
|
@@ -65,12 +35,7 @@ GEM
|
|
65
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
36
|
rspec-support (~> 3.2.0)
|
67
37
|
rspec-support (3.2.2)
|
68
|
-
shellany (0.0.1)
|
69
|
-
slop (3.6.0)
|
70
|
-
thor (0.19.1)
|
71
38
|
thread_safe (0.3.5)
|
72
|
-
timers (4.0.1)
|
73
|
-
hitimes
|
74
39
|
tzinfo (1.2.2)
|
75
40
|
thread_safe (~> 0.1)
|
76
41
|
|
@@ -78,7 +43,7 @@ PLATFORMS
|
|
78
43
|
ruby
|
79
44
|
|
80
45
|
DEPENDENCIES
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
46
|
+
bundler (~> 1.3)
|
47
|
+
rake (~> 10.0)
|
48
|
+
rspec (~> 3.0)
|
49
|
+
validates_subset!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Jake Yesbeck
|
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/lib/arguments.rb
CHANGED
data/lib/validates_subset.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
require 'active_model'
|
2
|
+
require 'active_support/i18n'
|
3
|
+
|
4
|
+
I18n.load_path << File.dirname(__FILE__) + '/../locale/en.yml'
|
5
|
+
I18n.load_path << File.dirname(__FILE__) + '/../locale/pl.yml'
|
6
|
+
I18n.load_path << File.dirname(__FILE__) + '/../locale/sv.yml'
|
2
7
|
|
3
8
|
require_relative './arguments'
|
4
9
|
|
@@ -14,7 +19,7 @@ module ActiveModel
|
|
14
19
|
options[:superset] = options.delete(:subset)
|
15
20
|
|
16
21
|
merged_options = {
|
17
|
-
:
|
22
|
+
message: :subset
|
18
23
|
}.merge(options)
|
19
24
|
|
20
25
|
super(merged_options)
|
@@ -50,7 +55,15 @@ module ActiveModel
|
|
50
55
|
|
51
56
|
raise error unless error.nil?
|
52
57
|
|
53
|
-
record.
|
58
|
+
value = record.send(attribute)
|
59
|
+
|
60
|
+
invalid_value = if value.is_a?(Array)
|
61
|
+
value - options[:superset]
|
62
|
+
else
|
63
|
+
value
|
64
|
+
end
|
65
|
+
|
66
|
+
record.errors.add(attribute, :subset, { subset: options[:superset], invalid_value: invalid_value }.merge(message: options[:message]))
|
54
67
|
end
|
55
68
|
|
56
69
|
# Helper method to return the base expected error:
|
data/locale/en.yml
ADDED
data/locale/pl.yml
ADDED
data/locale/sv.yml
ADDED
@@ -22,7 +22,7 @@ describe 'unless condition' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'value is not a valid subset' do
|
25
|
-
let(:value) {
|
25
|
+
let(:value) { [:a, :b, :c] }
|
26
26
|
|
27
27
|
specify do
|
28
28
|
expect(subject).to be_valid
|
@@ -58,7 +58,7 @@ describe 'unless condition' do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'value is not a valid subset' do
|
61
|
-
let(:value) {
|
61
|
+
let(:value) { [:a, :b, :c] }
|
62
62
|
|
63
63
|
specify do
|
64
64
|
expect(subject).to_not be_valid
|
data/validates_subset.gemspec
CHANGED
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_subset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Yesbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -78,9 +78,13 @@ files:
|
|
78
78
|
- Gemfile
|
79
79
|
- Gemfile.lock
|
80
80
|
- Guardfile
|
81
|
+
- LICENSE.txt
|
81
82
|
- README.md
|
82
83
|
- lib/arguments.rb
|
83
84
|
- lib/validates_subset.rb
|
85
|
+
- locale/en.yml
|
86
|
+
- locale/pl.yml
|
87
|
+
- locale/sv.yml
|
84
88
|
- spec/integration/modifiers/allow_blank_spec.rb
|
85
89
|
- spec/integration/modifiers/allow_nil_spec.rb
|
86
90
|
- spec/integration/modifiers/if_spec.rb
|