mize 0.0.2 → 0.1.0

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: be30ca64c6c7bf18fff3e433cc4cc2e2cbb547a9
4
- data.tar.gz: 599261ccc5f8128f2cc92363f64e9bb7d0495434
3
+ metadata.gz: 31a2249fb9449c4c378dfaa53ad98e1bdb5e4003
4
+ data.tar.gz: ce2086babe68462c54578504fd6d8fe4cec24d2c
5
5
  SHA512:
6
- metadata.gz: b6da41a24aa10ebec0b9a7cab544fc0cbd169399724b213d7a6b4227fbe1c04fe44a54735d297d475dacecc8e9e11324ddec286ff5e4f2f039c720f2f0a43208
7
- data.tar.gz: 8bf5f337b540344d8c77a41bb214130b188cb085c64ccdc20cd29dfd031e562e99aa8139e57102adca1c766f487ec3fb7dc022f7731bc072492f8da8944cce09
6
+ metadata.gz: 6ea3e5de8e79a5941cf2512776170bb41054bb88db20f9a86cb920b0d534644a423479d3e9a77c681f88cb365fd50ec83171ea4d6285342347e1959e178f7b0a
7
+ data.tar.gz: 511cecd51e2655fa03fdeb5868754dd49704f5d44011cf488de8647791c90ed929743da4a466a37c6c789cf4e530eb985e5788c447f60060962cf376e0b7d656
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.1.0
@@ -8,6 +8,15 @@ module Mize::CacheMethods
8
8
  self
9
9
  end
10
10
 
11
+ # Clear all cached results for the method/function +name+.
12
+ def mize_cache_clear_name(name)
13
+ name = build_key_prefix(name)
14
+ __mize_cache__.each_name do |n|
15
+ n =~ %r{\A#{name}/} and __mize_cache__.delete(n)
16
+ end
17
+ self
18
+ end
19
+
11
20
  private
12
21
 
13
22
  # Set the cache object to +cache+.
@@ -30,4 +30,6 @@ class Mize::DefaultCache < Hash
30
30
  end
31
31
 
32
32
  alias prototype dup
33
+
34
+ # conform_to Mize::CacheProtocol
33
35
  end
@@ -1,6 +1,6 @@
1
1
  module Mize
2
2
  # Mize version
3
- VERSION = '0.0.2'
3
+ VERSION = '0.1.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: mize 0.0.2 ruby lib
2
+ # stub: mize 0.1.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mize"
6
- s.version = "0.0.2"
6
+ s.version = "0.1.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
@@ -24,6 +24,7 @@ describe Mize, 'cache_clear' do
24
24
  it 'clears cache after Mize.cache_clear' do
25
25
  expect(foo.foo).to eq 1
26
26
  expect(foo.foo).to eq 1
27
+ expect(foo.__send__(:__mize_cache__)).to be_a Mize::CacheProtocol
27
28
  Mize.cache_clear
28
29
  expect(foo.foo).to eq 2
29
30
  end
@@ -2,10 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  class FooBar
4
4
  def self.reset
5
- @@foo = nil
6
- @@bar = nil
7
- @@baz = nil
8
- mize_cache_clear
5
+ @@foo = nil
6
+ @@footsie = nil
7
+ @@bar = nil
8
+ @@baz = nil
9
+ Mize.cache_clear
9
10
  end
10
11
 
11
12
  def foo(*a)
@@ -90,6 +91,16 @@ describe Mize do
90
91
  expect(fb1.__send__(:__mize_cache__)).not_to be_empty
91
92
  expect(fb2.__send__(:__mize_cache__)).not_to be_empty
92
93
  end
94
+
95
+ it 'can clear caches for a single method' do
96
+ expect(fb1.__send__(:__mize_cache__)).to be_empty
97
+ expect(fb1.__send__(:footsie, 1, 2)).to eq 1
98
+ expect(fb1.foo(1)).to eq 1
99
+ fb1.mize_cache_clear_name :foo
100
+ expect(fb1.__send__(:__mize_cache__)).not_to be_empty
101
+ expect(fb1.__send__(:footsie, 1, 2)).to eq 1
102
+ expect(fb1.__send__(:foo, 1, 2)).to eq 2
103
+ end
93
104
  end
94
105
 
95
106
  context 'memoize function' do
@@ -120,5 +131,15 @@ describe Mize do
120
131
  expect(fb2.__send__(:baz, 1, 2)).to eq 3
121
132
  expect(FooBar.__send__(:__mize_cache__)).not_to be_empty
122
133
  end
134
+
135
+ it 'can clear caches for a single function' do
136
+ expect(FooBar.__send__(:__mize_cache__)).to be_empty
137
+ expect(fb1.__send__(:baz, 1, 2)).to eq 1
138
+ expect(fb1.bar(1)).to eq 1
139
+ fb1.mize_cache_clear_name :bar
140
+ expect(FooBar.__send__(:__mize_cache__)).not_to be_empty
141
+ expect(fb1.__send__(:baz, 1, 2)).to eq 1
142
+ expect(fb1.__send__(:bar, 1, 2)).to eq 2
143
+ end
123
144
  end
124
145
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank