looksist 0.3.7 → 0.3.8
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/lib/looksist.rb +1 -0
 - data/lib/looksist/hash.rb +13 -0
 - data/lib/looksist/hashed.rb +6 -2
 - data/lib/looksist/version.rb +1 -1
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1ed8d09b1e799bb4e40b66a065fbe39ed049e423
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: eeec8b9db71d9a12c63cfaa18880c084a169a2b2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e28f0f4283e7aed483bcda0ba3f377b3267570d647ee4362d8a4ab16611afbfd2d363103a9b2271a140fec65894d10ce01273f35853f2127ea5e918b656a2294
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b22b1798d96ab7484845ebb4a42b819754680c150d29edcc7124b2a09e6c61100bb32474ef687ffd30cfab688ef30f189b19ad56f904a68d268ef7380284cd17
         
     | 
    
        data/lib/looksist.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Hash
         
     | 
| 
      
 2 
     | 
    
         
            +
              def find_all_values_for(key)
         
     | 
| 
      
 3 
     | 
    
         
            +
                result = []
         
     | 
| 
      
 4 
     | 
    
         
            +
                result << self[key]
         
     | 
| 
      
 5 
     | 
    
         
            +
                self.values.each do |hash_value|
         
     | 
| 
      
 6 
     | 
    
         
            +
                  values = (hash_value.is_a?(Array) ? hash_value : [hash_value])
         
     | 
| 
      
 7 
     | 
    
         
            +
                  values.each do |value|
         
     | 
| 
      
 8 
     | 
    
         
            +
                    result += value.find_all_values_for(key) if value.is_a? Hash
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
                result.compact
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/looksist/hashed.rb
    CHANGED
    
    | 
         @@ -108,8 +108,7 @@ module Looksist 
     | 
|
| 
       108 
108 
     | 
    
         
             
                      modified_array = if at.nil?
         
     | 
| 
       109 
109 
     | 
    
         
             
                                         array_of_hashes.map(&:values)
         
     | 
| 
       110 
110 
     | 
    
         
             
                                       else
         
     | 
| 
       111 
     | 
    
         
            -
                                          
     | 
| 
       112 
     | 
    
         
            -
                                         json_path.on(array_of_hashes.to_json)
         
     | 
| 
      
 111 
     | 
    
         
            +
                                         extract_values(array_of_hashes, opt[:using])
         
     | 
| 
       113 
112 
     | 
    
         
             
                                       end
         
     | 
| 
       114 
113 
     | 
    
         
             
                      keys = modified_array.flatten.compact.uniq
         
     | 
| 
       115 
114 
     | 
    
         
             
                      values = Hash[keys.zip(Looksist.redis_service.send("#{entity_name}_for", keys))]
         
     | 
| 
         @@ -118,6 +117,11 @@ module Looksist 
     | 
|
| 
       118 
117 
     | 
    
         
             
                    smart_lookup(array_of_hashes, opts, all_values, at)
         
     | 
| 
       119 
118 
     | 
    
         
             
                  end
         
     | 
| 
       120 
119 
     | 
    
         | 
| 
      
 120 
     | 
    
         
            +
                  def extract_values(array_of_hashes, using)
         
     | 
| 
      
 121 
     | 
    
         
            +
                    hash = array_of_hashes.is_a?(Array) ? {:root => array_of_hashes} : array_of_hashes
         
     | 
| 
      
 122 
     | 
    
         
            +
                    hash.find_all_values_for(using)
         
     | 
| 
      
 123 
     | 
    
         
            +
                  end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
       121 
125 
     | 
    
         
             
                  def smart_lookup(array_of_hashes, opts, all_values, at)
         
     | 
| 
       122 
126 
     | 
    
         
             
                    ## populate is not a array
         
     | 
| 
       123 
127 
     | 
    
         
             
                    array_of_hashes.collect do |elt|
         
     | 
    
        data/lib/looksist/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: looksist
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.8
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - RC
         
     | 
| 
         @@ -210,6 +210,7 @@ files: 
     | 
|
| 
       210 
210 
     | 
    
         
             
            - lib/looksist.rb
         
     | 
| 
       211 
211 
     | 
    
         
             
            - lib/looksist/common.rb
         
     | 
| 
       212 
212 
     | 
    
         
             
            - lib/looksist/core.rb
         
     | 
| 
      
 213 
     | 
    
         
            +
            - lib/looksist/hash.rb
         
     | 
| 
       213 
214 
     | 
    
         
             
            - lib/looksist/hashed.rb
         
     | 
| 
       214 
215 
     | 
    
         
             
            - lib/looksist/redis_service.rb
         
     | 
| 
       215 
216 
     | 
    
         
             
            - lib/looksist/safe_lru_cache.rb
         
     |