memoize 1.2.1 → 1.2.2

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.
Files changed (4) hide show
  1. data/CHANGES +5 -0
  2. data/lib/memoize.rb +8 -8
  3. data/test/tc_memoize.rb +1 -1
  4. 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.
@@ -1,18 +1,18 @@
1
1
  module Memoize
2
- MEMOIZE_VERSION = "1.2.1"
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
- cache = File.open(file, "rb"){ |io| Marshal.load(io) } rescue {}
7
+ cache = File.open(file, "rb"){ |io| Marshal.load(io) } rescue {}
8
8
 
9
- (class<<self; self; end).send(:define_method, name) do |*args|
10
- unless cache[args]
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
- end
14
- cache[args]
15
- end
16
- cache
13
+ end
14
+ cache[args]
15
+ end
16
+ cache
17
17
  end
18
18
  end
@@ -35,7 +35,7 @@ class TC_Memoize < Test::Unit::TestCase
35
35
  end
36
36
 
37
37
  def test_version
38
- assert_equal("1.2.0", Memoize::MEMOIZE_VERSION)
38
+ assert_equal("1.2.2", Memoize::MEMOIZE_VERSION)
39
39
  end
40
40
 
41
41
  def test_memoize
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
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.1
7
- date: 2006-02-02 00:00:00 -07:00
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
- - !ruby/object:Gem::Version
23
- version: 0.0.0
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
- - CHANGES
33
- - MANIFEST
34
- - README
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: []