delorean_lang 0.4.8 → 0.5.0
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/README.md +1 -1
- data/lib/delorean/cache/adapters/ruby_cache.rb +6 -2
- data/lib/delorean/model.rb +2 -2
- data/lib/delorean/version.rb +1 -1
- data/spec/cache_spec.rb +9 -4
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 89298e290f313ade46bf260e446224804149a46f
         | 
| 4 | 
            +
              data.tar.gz: d31f413b2c391b0d98b157967693be82b86bf101
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0c19fce0e9ab539d9b95c9491c3b04e6711c1617a79fb1a4c1ae3aa6895d831809d018cc1aa52385403c5c7c7ebd2d8474ba004fa9595d6f55d2c895f0e01644
         | 
| 7 | 
            +
              data.tar.gz: 24056448d59d6ed59dfed9f8a28c89c8c9aba471f0e9d5097263f1e33eefaf7d73a8e699f853b1a7bcd54d3a49b80ba02ff1a9c3c2b61305a2994ab0a0b38f88
         | 
    
        data/README.md
    CHANGED
    
    | @@ -196,7 +196,7 @@ Delorean expects it to have methods with following signatures: | |
| 196 196 | 
             
            ```ruby
         | 
| 197 197 |  | 
| 198 198 | 
             
              cache_item(klass:, cache_key:, item:)
         | 
| 199 | 
            -
              fetch_item(klass:, cache_key:)
         | 
| 199 | 
            +
              fetch_item(klass:, cache_key:, default:)
         | 
| 200 200 | 
             
              cache_key(klass:, method_name:, args:)
         | 
| 201 201 | 
             
              clear!(klass:)
         | 
| 202 202 | 
             
              clear_all!
         | 
| @@ -17,8 +17,12 @@ module Delorean | |
| 17 17 | 
             
                      lookup_cache[klass][cache_key] = item
         | 
| 18 18 | 
             
                    end
         | 
| 19 19 |  | 
| 20 | 
            -
                    def fetch_item(klass:, cache_key:)
         | 
| 21 | 
            -
                      lookup_cache. | 
| 20 | 
            +
                    def fetch_item(klass:, cache_key:, default: nil)
         | 
| 21 | 
            +
                      subh = lookup_cache.fetch(klass, default)
         | 
| 22 | 
            +
                      return default if subh == default
         | 
| 23 | 
            +
                      v = subh.fetch(cache_key, default)
         | 
| 24 | 
            +
                      return default if v == default
         | 
| 25 | 
            +
                      v
         | 
| 22 26 | 
             
                    end
         | 
| 23 27 |  | 
| 24 28 | 
             
                    def cache_key(klass:, method_name:, args:)
         | 
    
        data/lib/delorean/model.rb
    CHANGED
    
    | @@ -45,10 +45,10 @@ module Delorean | |
| 45 45 | 
             
                        klass: self, method_name: name, args: args
         | 
| 46 46 | 
             
                      )
         | 
| 47 47 | 
             
                      cached_item = delorean_cache_adapter.fetch_item(
         | 
| 48 | 
            -
                        klass: self, cache_key: cache_key
         | 
| 48 | 
            +
                        klass: self, cache_key: cache_key, default: :NF
         | 
| 49 49 | 
             
                      )
         | 
| 50 50 |  | 
| 51 | 
            -
                      next cached_item if cached_item
         | 
| 51 | 
            +
                      next cached_item if cached_item != :NF
         | 
| 52 52 |  | 
| 53 53 | 
             
                      res = block.call(*args)
         | 
| 54 54 |  | 
    
        data/lib/delorean/version.rb
    CHANGED
    
    
    
        data/spec/cache_spec.rb
    CHANGED
    
    | @@ -44,15 +44,20 @@ describe "Delorean cache" do | |
| 44 44 | 
             
                  Dummy.returns_cached_openstruct(t, t)
         | 
| 45 45 | 
             
                end
         | 
| 46 46 |  | 
| 47 | 
            +
                item_2 = ::Delorean::Cache.adapter.fetch_item(
         | 
| 48 | 
            +
                  klass: Dummy, cache_key: [:returns_cached_openstruct, 2, 2], default: :NF
         | 
| 49 | 
            +
                )
         | 
| 50 | 
            +
                expect(item_2).to eq(:NF)
         | 
| 47 51 | 
             
                item_2 = ::Delorean::Cache.adapter.fetch_item(
         | 
| 48 52 | 
             
                  klass: Dummy, cache_key: [:returns_cached_openstruct, 2, 2]
         | 
| 49 53 | 
             
                )
         | 
| 54 | 
            +
                expect(item_2).to eq(nil)
         | 
| 50 55 |  | 
| 51 | 
            -
                item_10 = ::Delorean::Cache.adapter.fetch_item(
         | 
| 52 | 
            -
                  klass: Dummy, cache_key: [:returns_cached_openstruct, 10, 10]
         | 
| 56 | 
            +
                item_10, item_10_found = ::Delorean::Cache.adapter.fetch_item(
         | 
| 57 | 
            +
                  klass: Dummy, cache_key: [:returns_cached_openstruct, 10, 10], default: :NF
         | 
| 53 58 | 
             
                )
         | 
| 54 59 |  | 
| 55 | 
            -
                expect( | 
| 56 | 
            -
                expect(item_10).to  | 
| 60 | 
            +
                expect(item_10).to be_a(OpenStruct)
         | 
| 61 | 
            +
                expect(item_10["10"]).to eq(10)
         | 
| 57 62 | 
             
              end
         | 
| 58 63 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: delorean_lang
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Arman Bostani
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019-01- | 
| 11 | 
            +
            date: 2019-01-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: treetop
         |