memoize 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -0
- data/lib/memoize.rb +8 -8
- data/test/tc_memoize.rb +1 -1
- metadata +18 -24
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 1.2.2 - 4-Feb-2006
|
2
|
+
* In the last release I accidentally removed the ability to cache nil and
|
3
|
+
false. That ability has been restored. Thanks go to Brian Buckley for
|
4
|
+
the spot.
|
5
|
+
|
1
6
|
= 1.2.1 - 2-Feb-2006
|
2
7
|
* Cache files are now read in binary mode to eliminate issues with Marshal
|
3
8
|
and MS Windows. Thanks go to Brian Buckley for the spot.
|
data/lib/memoize.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
module Memoize
|
2
|
-
MEMOIZE_VERSION = "1.2.
|
2
|
+
MEMOIZE_VERSION = "1.2.2"
|
3
3
|
|
4
4
|
# Memoize the method +name+. If +file+ is provided, then the method results
|
5
5
|
# are stored on disk as well as in memory.
|
6
6
|
def memoize(name, file=nil)
|
7
|
-
|
7
|
+
cache = File.open(file, "rb"){ |io| Marshal.load(io) } rescue {}
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
(class<<self; self; end).send(:define_method, name) do |*args|
|
10
|
+
unless cache.has_key?(args)
|
11
11
|
cache[args] = super
|
12
12
|
File.open(file, "wb+"){ |f| Marshal.dump(cache, f) } if file
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
end
|
14
|
+
cache[args]
|
15
|
+
end
|
16
|
+
cache
|
17
17
|
end
|
18
18
|
end
|
data/test/tc_memoize.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: memoize
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2006-02-
|
6
|
+
version: 1.2.2
|
7
|
+
date: 2006-02-04
|
8
8
|
summary: Speeds up methods at the cost of memory (or disk space)
|
9
9
|
require_paths:
|
10
|
-
- lib
|
10
|
+
- lib
|
11
11
|
email: djberg96@gmail.com
|
12
12
|
homepage: http://www.rubyforge.org/projects/shards
|
13
13
|
rubyforge_project:
|
@@ -18,33 +18,27 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
24
25
|
version:
|
25
26
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
27
|
authors:
|
29
|
-
- Daniel J. Berger
|
28
|
+
- Daniel J. Berger
|
30
29
|
files:
|
31
|
-
- lib/memoize.rb
|
32
|
-
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
- test/tc_memoize.rb
|
30
|
+
- lib/memoize.rb
|
31
|
+
- README
|
32
|
+
- CHANGES
|
33
|
+
- MANIFEST
|
34
|
+
- test/tc_memoize.rb
|
36
35
|
test_files:
|
37
|
-
- test/tc_memoize.rb
|
36
|
+
- test/tc_memoize.rb
|
38
37
|
rdoc_options: []
|
39
|
-
|
40
38
|
extra_rdoc_files:
|
41
|
-
- README
|
42
|
-
- CHANGES
|
39
|
+
- README
|
40
|
+
- CHANGES
|
43
41
|
executables: []
|
44
|
-
|
45
42
|
extensions: []
|
46
|
-
|
47
43
|
requirements: []
|
48
|
-
|
49
|
-
dependencies: []
|
50
|
-
|
44
|
+
dependencies: []
|