dry-validation 0.13.1 → 0.13.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66ce6c3fe11f428f8552627416495ac25fc71367cd2baf551748c98f0cbfccf4
4
- data.tar.gz: 97d1341fc9b6b7cede1544c12a165e8a14c84178b4186bfb5595c80bd9e81ed5
3
+ metadata.gz: 1a31ac4653e7f148d6ee09543b38c81f9670bc40c51c8644414aacc000e66357
4
+ data.tar.gz: 2c84a8c6b29bb290f3e24505a9f52c1abcc31c777b54ed4140bc38225e5410d2
5
5
  SHA512:
6
- metadata.gz: a237d513a5b6695ee8a31ba7ced7d7c745941dc5694388bc669ef836184a3e01e68c95f0550836dfac6ef26f4301715e4376faa9acc4082ff8ca37e7fd4dc717
7
- data.tar.gz: 6b8b1f080122332b63877ac9b114ee4f07e3185a893452d50a4156b6360a339ed05f14ced976b4a58bfbe456f0cf7493c26dd236af802e32465e5cfd0ca56e24
6
+ metadata.gz: afb6b1de3fea9028ec2d4ffd481b9a49a79f2a9192c0101122a00c4b567d99e5d53083c130cc1789d643b9c80a5b7c98384e776d36c746a3ca1ff83ea80b1caf
7
+ data.tar.gz: d287f0d13f12c65a476de805e6fd95175eea35da74b679dd0fcb98e8ac616e000cf465db769b2e53e5db2e082173c30a3c8c16cffe0537517e96dbd499e8d004
@@ -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(*args)
63
- cache.fetch_or_store(args.hash) do
64
- path, opts = lookup(*args)
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[self]
115
+ @cache ||= self.class.cache[hash]
104
116
  end
105
117
 
106
118
  def default_locale
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Validation
3
- VERSION = '0.13.1'.freeze
3
+ VERSION = '0.13.2'.freeze
4
4
  end
5
5
  end
@@ -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.1
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-03-22 00:00:00.000000000 Z
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.1
374
+ rubygems_version: 3.0.3
375
375
  signing_key:
376
376
  specification_version: 4
377
377
  summary: A simple validation library