trick_bag 0.51.0 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d5d7bf7f9d42de360c17f2c0086fb8d4e5286c8
|
4
|
+
data.tar.gz: 7fe3d0612c0354ae7e44b539f08aeb5610d1ec2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18df24c9efffab6eb3f515f2a041f36ac168d6eee769a0482899d147652d41c14b4453e8f244ebff19663ae65ec2ab9a9e2a493cf77508e49d95c66f976df7d6
|
7
|
+
data.tar.gz: 6def0aeb779f614446b072f68dffcea124a53fbaa5a3fb22a9f77845fe67712a793b7bb1a15f98113db02faa15a8441758e62fe171eb69c8a0a2dc6af35f76c4
|
data/RELEASE_NOTES.md
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
module TrickBag
|
2
|
+
module Validations
|
3
|
+
|
4
|
+
module_function
|
5
|
+
|
6
|
+
|
7
|
+
# @return whether or not the passed string matches *any* of the regexes in the passed array
|
8
|
+
# @param regexes array of regexes to test against
|
9
|
+
# @param string the string to test against the regexes
|
10
|
+
def matches_any_regex?(regexes, string)
|
11
|
+
regexes.any? { |regex| regex === string }
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
# @return whether or not the passed string matches *all* of the regexes in the passed array
|
16
|
+
# @param regexes array of regexes to test against
|
17
|
+
# @param string the string to test against the regexes
|
18
|
+
def matches_all_regexes?(regexes, string)
|
19
|
+
regexes.all? { |regex| regex === string }
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# @return whether or not the passed string matches *none* of the regexes in the passed array
|
24
|
+
# @param regexes array of regexes to test against
|
25
|
+
# @param string the string to test against the regexes
|
26
|
+
def matches_no_regexes?(regexes, string)
|
27
|
+
regexes.none? { |regex| regex === string }
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/trick_bag/version.rb
CHANGED
@@ -17,11 +17,13 @@ describe CollectionAccess do
|
|
17
17
|
|
18
18
|
it 'works with 2 keys' do
|
19
19
|
h = { 'a' => { 'b' => 234 }}
|
20
|
+
# instead of h['a']['b']:
|
20
21
|
expect(CollectionAccess.access(h, 'a.b')).to eq(234)
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'works with 3 keys' do
|
24
25
|
h = { 'a' => { 'bb' => { 'ccc' => 345 }}}
|
26
|
+
# instead of h['a']['bb']['ccc']:
|
25
27
|
expect(CollectionAccess.access(h, 'a.bb.ccc')).to eq(345)
|
26
28
|
end
|
27
29
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative '../../spec_helper.rb'
|
2
|
+
|
3
|
+
require 'trick_bag/validations/regex_validations'
|
4
|
+
|
5
|
+
module TrickBag
|
6
|
+
|
7
|
+
describe Validations do
|
8
|
+
|
9
|
+
include Validations
|
10
|
+
|
11
|
+
let(:regexes) { [/a/, /m/, /z/] }
|
12
|
+
|
13
|
+
context '#matches_any_regex?' do
|
14
|
+
|
15
|
+
it 'should return true on any match' do
|
16
|
+
expect(matches_any_regex?(regexes, 'a')).to eq(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return false on no match' do
|
20
|
+
expect(matches_any_regex?(regexes, 'b')).to eq(false)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
context '#matches_all_regexes?' do
|
27
|
+
|
28
|
+
it 'should return true on match all' do
|
29
|
+
expect(matches_all_regexes?(regexes, 'amz')).to eq(true)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should return false on no match or match some' do
|
33
|
+
expect(matches_all_regexes?(regexes, 'b')).to eq(false)
|
34
|
+
expect(matches_all_regexes?(regexes, 'am')).to eq(false)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
context '#matches_no_regexes?' do
|
41
|
+
|
42
|
+
it 'should return true on match' do
|
43
|
+
expect(matches_no_regexes?(regexes, 'bny')).to eq(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should return false on any or all matches' do
|
47
|
+
expect(matches_no_regexes?(regexes, 'a')).to eq(false)
|
48
|
+
expect(matches_no_regexes?(regexes, 'amz')).to eq(false)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trick_bag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.52.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Bennett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/trick_bag/validations/hash_validations.rb
|
120
120
|
- lib/trick_bag/validations/object_validations.rb
|
121
121
|
- lib/trick_bag/validations/other_validations.rb
|
122
|
+
- lib/trick_bag/validations/regex_validations.rb
|
122
123
|
- lib/trick_bag/version.rb
|
123
124
|
- spec/spec_helper.rb
|
124
125
|
- spec/trick_bag/collections/collection_access_spec.rb
|
@@ -144,6 +145,7 @@ files:
|
|
144
145
|
- spec/trick_bag/validations/hash_validations_spec.rb
|
145
146
|
- spec/trick_bag/validations/object_validations_spec.rb
|
146
147
|
- spec/trick_bag/validations/other_validations_spec.rb
|
148
|
+
- spec/trick_bag/validations/regex_validations_spec.rb
|
147
149
|
- trick_bag.gemspec
|
148
150
|
homepage: https://github.com/keithrbennett/trick_bag
|
149
151
|
licenses:
|
@@ -194,3 +196,4 @@ test_files:
|
|
194
196
|
- spec/trick_bag/validations/hash_validations_spec.rb
|
195
197
|
- spec/trick_bag/validations/object_validations_spec.rb
|
196
198
|
- spec/trick_bag/validations/other_validations_spec.rb
|
199
|
+
- spec/trick_bag/validations/regex_validations_spec.rb
|