basiccache 0.0.22 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22d2709c9524354f74da72c0b334aa8eb8f41b1b
4
- data.tar.gz: 395bc1e79ca4a535e7bfd209e156684d9bb1adca
3
+ metadata.gz: eeab072225e6d51cb073ee6e68993040d2039e83
4
+ data.tar.gz: dccbdd3aa31ad8fe18f43d4b15885aeae380060a
5
5
  SHA512:
6
- metadata.gz: b4184929bde760bfbc19555318fd9186ae3a1728291cebc49e859c48752448bdb8e288b47e00688d984e0a9044f84b764118081ec6766f7b0f580c46f055f85f
7
- data.tar.gz: 51df167bc6fee497e09d1d77751d3b850b474136a54464fa12234653b4201ea52ba0d82c19670abe8909c4694b0a67097b0220df877a71cad38ef79e7f80353d
6
+ metadata.gz: c36f3bdba76d69d0d1020a5842db8836f5fe2fd04241d5073614232570a274b0eb8788c4f0f767f65e0d6a2b6fc55a47793fbe55679e8ccb00c2e0631a90831c
7
+ data.tar.gz: 8b130c9f62a38b5f68696379332abd334bb988b3f9f6f148177b1b9d2f1b97218c14782d3d610fcf1255e6962d90ac46f5841b6afe9840f9fa6f72ce99ad13fd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- basiccache (0.0.22)
4
+ basiccache (0.0.24)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -134,6 +134,10 @@ Does the cache include 'test'? true
134
134
  Does the cache include 'test' now? false
135
135
  ```
136
136
 
137
+ ## Important Note About Keys
138
+
139
+ BasicCache attempts to guess the key name from the stack by looking for the name of the method that called it. This is convenient for most use cases, but if you're using metaprogramming or nested code blocks, this can cause that method name to be "block (2 levels) in \<top (required)>" or similar. In this case, keys can conflict and give back weird results. The fix is for you to manually specify your own keys to .cache calls.
140
+
137
141
  ## Installation
138
142
 
139
143
  gem install basiccache
data/basiccache.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'basiccache'
3
- s.version = '0.0.22'
3
+ s.version = '0.0.24'
4
4
  s.date = Time.now.strftime("%Y-%m-%d")
5
5
  s.summary = 'Provides a minimal key/value caching layer'
6
6
  s.description = "Allows an application to dynamically cache values and retrieve them later"
data/lib/methodcacher.rb CHANGED
@@ -10,7 +10,9 @@ module MethodCacher
10
10
  uncached_name = "#{name}_uncached".to_sym
11
11
  (class << self; self; end).class_eval do
12
12
  alias_method uncached_name, name
13
- define_method(name) { |*a| cache.cache { send uncached_name, *a } }
13
+ define_method(name) do |*a, &b|
14
+ cache.cache(name) { send uncached_name, *a }
15
+ end
14
16
  end
15
17
  end
16
18
  end
@@ -16,6 +16,10 @@ class Example
16
16
  input
17
17
  end
18
18
 
19
+ def other_repeat(input)
20
+ input
21
+ end
22
+
19
23
  def time_repeat(input)
20
24
  input
21
25
  end
@@ -52,5 +56,9 @@ describe MethodCacher do
52
56
  expect(test_object.repeat_uncached 5).to eql 5
53
57
  expect(test_object.repeat_uncached 4).to eql 4
54
58
  end
59
+ it 'properly separates keys in the cache' do
60
+ expect(test_object.repeat 8).to eql 8
61
+ expect(test_object.other_repeat 3).to eql 3
62
+ end
55
63
  end
56
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basiccache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-25 00:00:00.000000000 Z
11
+ date: 2013-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop