dry-schema 1.0.2 → 1.0.3
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/CHANGELOG.md +10 -0
 - data/lib/dry/schema/messages/abstract.rb +2 -19
 - data/lib/dry/schema/messages/i18n.rb +1 -1
 - data/lib/dry/schema/messages/template.rb +1 -1
 - data/lib/dry/schema/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1867ad3cc77ca7f40338a9af423ebbdeb226c677e54fa2681af2efe43cc098e7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2b0a981aaaab80619e4e79b5428961fa8f68e47796c171771531fa9263f3a487
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8296a4a2e9d5972fcac050407a76c6c9ac477415f2abfeb2d5005f71a3ac6ee32101edfb785ef51048fdd1d6bf70ec24fcc53c5883004169ec20af2291e138b5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 88d64217d50a50c642a23713cd4f2a865ed16dd7da73a73dc085f7324daae9869c06c1e4024ecc2b973aea7097daae8037020fce7121cafab08732faa9362fa2
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # v1.0.3 2019-05-21
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ### Fixed
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * `Object#hash` is no longer used to calculate cache keys due to a potential risk of having hash collisions (solnic)
         
     | 
| 
      
 6 
     | 
    
         
            +
            * Predicate arguments are used again for template cache keys (solnic)
         
     | 
| 
      
 7 
     | 
    
         
            +
            * `I18n` messages backend no longer evaluates templates twice (solnic)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            [Compare v1.0.2...v1.0.3](https://github.com/dry-rb/dry-schema/compare/v1.0.2...v1.0.3)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       1 
11 
     | 
    
         
             
            # v1.0.2 2019-05-12
         
     | 
| 
       2 
12 
     | 
    
         | 
| 
       3 
13 
     | 
    
         
             
            ### Fixed
         
     | 
| 
         @@ -45,8 +45,6 @@ module Dry 
     | 
|
| 
       45 
45 
     | 
    
         
             
                      String => 'string'
         
     | 
| 
       46 
46 
     | 
    
         
             
                    )
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                    CACHE_KEYS = %i[path message_type val_type arg_type locale].freeze
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
48 
     | 
    
         
             
                    # @api private
         
     | 
| 
       51 
49 
     | 
    
         
             
                    def self.cache
         
     | 
| 
       52 
50 
     | 
    
         
             
                      @cache ||= Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new }
         
     | 
| 
         @@ -93,23 +91,13 @@ module Dry 
     | 
|
| 
       93 
91 
     | 
    
         
             
                    #
         
     | 
| 
       94 
92 
     | 
    
         
             
                    # @api public
         
     | 
| 
       95 
93 
     | 
    
         
             
                    def call(predicate, options)
         
     | 
| 
       96 
     | 
    
         
            -
                      cache.fetch_or_store( 
     | 
| 
      
 94 
     | 
    
         
            +
                      cache.fetch_or_store([predicate, options.reject { |k,| k.equal?(:input) }]) do
         
     | 
| 
       97 
95 
     | 
    
         
             
                        text, meta = lookup(predicate, options)
         
     | 
| 
       98 
96 
     | 
    
         
             
                        [Template[text], meta] if text
         
     | 
| 
       99 
97 
     | 
    
         
             
                      end
         
     | 
| 
       100 
98 
     | 
    
         
             
                    end
         
     | 
| 
       101 
99 
     | 
    
         
             
                    alias_method :[], :call
         
     | 
| 
       102 
100 
     | 
    
         | 
| 
       103 
     | 
    
         
            -
                    if ::Hash.instance_methods.include?(:slice)
         
     | 
| 
       104 
     | 
    
         
            -
                      def cache_key(predicate, options)
         
     | 
| 
       105 
     | 
    
         
            -
                        [predicate, options.slice(*CACHE_KEYS)]
         
     | 
| 
       106 
     | 
    
         
            -
                      end
         
     | 
| 
       107 
     | 
    
         
            -
                    else
         
     | 
| 
       108 
     | 
    
         
            -
                      def cache_key(predicate, options)
         
     | 
| 
       109 
     | 
    
         
            -
                        [predicate, options.select { |key,| CACHE_KEYS.include?(key) }]
         
     | 
| 
       110 
     | 
    
         
            -
                      end
         
     | 
| 
       111 
     | 
    
         
            -
                    end
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
101 
     | 
    
         
             
                    # Try to find a message for the given predicate and its options
         
     | 
| 
       114 
102 
     | 
    
         
             
                    #
         
     | 
| 
       115 
103 
     | 
    
         
             
                    # @api private
         
     | 
| 
         @@ -168,14 +156,9 @@ module Dry 
     | 
|
| 
       168 
156 
     | 
    
         
             
                      config.root
         
     | 
| 
       169 
157 
     | 
    
         
             
                    end
         
     | 
| 
       170 
158 
     | 
    
         | 
| 
       171 
     | 
    
         
            -
                    # @api private
         
     | 
| 
       172 
     | 
    
         
            -
                    def hash
         
     | 
| 
       173 
     | 
    
         
            -
                      @hash ||= config.hash
         
     | 
| 
       174 
     | 
    
         
            -
                    end
         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
159 
     | 
    
         
             
                    # @api private
         
     | 
| 
       177 
160 
     | 
    
         
             
                    def cache
         
     | 
| 
       178 
     | 
    
         
            -
                      @cache ||= self.class.cache[ 
     | 
| 
      
 161 
     | 
    
         
            +
                      @cache ||= self.class.cache[self]
         
     | 
| 
       179 
162 
     | 
    
         
             
                    end
         
     | 
| 
       180 
163 
     | 
    
         | 
| 
       181 
164 
     | 
    
         
             
                    # @api private
         
     | 
    
        data/lib/dry/schema/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dry-schema
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Piotr Solnica
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-05-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: concurrent-ruby
         
     |