dry-validation 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +0 -5
- data/lib/dry/validation/messages/abstract.rb +16 -4
- data/lib/dry/validation/version.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a31ac4653e7f148d6ee09543b38c81f9670bc40c51c8644414aacc000e66357
|
4
|
+
data.tar.gz: 2c84a8c6b29bb290f3e24505a9f52c1abcc31c777b54ed4140bc38225e5410d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb6b1de3fea9028ec2d4ffd481b9a49a79f2a9192c0101122a00c4b567d99e5d53083c130cc1789d643b9c80a5b7c98384e776d36c746a3ca1ff83ea80b1caf
|
7
|
+
data.tar.gz: d287f0d13f12c65a476de805e6fd95175eea35da74b679dd0fcb98e8ac616e000cf465db769b2e53e5db2e082173c30a3c8c16cffe0537517e96dbd499e8d004
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v0.13.2 2019-05-12
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Caching message templates uses restricted set of known keys to calculate cache keys (solnic)
|
6
|
+
|
7
|
+
[Compare v0.13.1...v0.13.2](https://github.com/dry-rb/dry-validation/compare/v0.13.1...v0.13.2)
|
8
|
+
|
1
9
|
# v0.13.1 2019-03-22
|
2
10
|
|
3
11
|
### Changed
|
data/Gemfile
CHANGED
@@ -14,11 +14,6 @@ end
|
|
14
14
|
group :tools do
|
15
15
|
gem 'pry-byebug', platform: :mri
|
16
16
|
gem 'pry', platform: :jruby
|
17
|
-
|
18
|
-
unless ENV['TRAVIS']
|
19
|
-
gem 'mutant', git: 'https://github.com/mbj/mutant'
|
20
|
-
gem 'mutant-rspec', git: 'https://github.com/mbj/mutant'
|
21
|
-
end
|
22
17
|
end
|
23
18
|
|
24
19
|
group :benchmarks do
|
@@ -40,6 +40,8 @@ module Dry
|
|
40
40
|
String => 'string'
|
41
41
|
)
|
42
42
|
|
43
|
+
CACHE_KEYS = %i[path message_type val_type arg_type locale].freeze
|
44
|
+
|
43
45
|
def self.cache
|
44
46
|
@cache ||= Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new }
|
45
47
|
end
|
@@ -59,14 +61,24 @@ module Dry
|
|
59
61
|
get(path, options) if key?(path, options)
|
60
62
|
end
|
61
63
|
|
62
|
-
def call(
|
63
|
-
cache.fetch_or_store(
|
64
|
-
path, opts = lookup(
|
64
|
+
def call(predicate, options = EMPTY_HASH)
|
65
|
+
cache.fetch_or_store(cache_key(predicate, options)) do
|
66
|
+
path, opts = lookup(predicate, options)
|
65
67
|
get(path, opts) if path
|
66
68
|
end
|
67
69
|
end
|
68
70
|
alias_method :[], :call
|
69
71
|
|
72
|
+
if ::Hash.instance_methods.include?(:slice)
|
73
|
+
def cache_key(predicate, options)
|
74
|
+
[predicate, options.slice(*CACHE_KEYS)]
|
75
|
+
end
|
76
|
+
else
|
77
|
+
def cache_key(predicate, options)
|
78
|
+
[predicate, options.select { |key,| CACHE_KEYS.include?(key) }]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
70
82
|
def lookup(predicate, options = {})
|
71
83
|
tokens = options.merge(
|
72
84
|
root: root,
|
@@ -100,7 +112,7 @@ module Dry
|
|
100
112
|
end
|
101
113
|
|
102
114
|
def cache
|
103
|
-
@cache ||= self.class.cache[
|
115
|
+
@cache ||= self.class.cache[hash]
|
104
116
|
end
|
105
117
|
|
106
118
|
def default_locale
|
data/spec/spec_helper.rb
CHANGED
@@ -50,6 +50,10 @@ RSpec.configure do |config|
|
|
50
50
|
self
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
Dry::Validation::Messages::Abstract.instance_variable_set('@cache', nil)
|
55
|
+
Dry::Validation::Messages::YAML.instance_variable_set('@cache', nil)
|
56
|
+
Dry::Validation::Messages::I18n.instance_variable_set('@cache', nil) if defined?(I18n)
|
53
57
|
end
|
54
58
|
|
55
59
|
config.after do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Holland
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -371,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
371
371
|
- !ruby/object:Gem::Version
|
372
372
|
version: '0'
|
373
373
|
requirements: []
|
374
|
-
rubygems_version: 3.0.
|
374
|
+
rubygems_version: 3.0.3
|
375
375
|
signing_key:
|
376
376
|
specification_version: 4
|
377
377
|
summary: A simple validation library
|