memoist 0.11.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae4871b19ddf0826d00aed6706f6d4e18e87b1fc
4
- data.tar.gz: 9f51de9a63090ec5e42ec3e17ca3188776f537a7
3
+ metadata.gz: b2940374d92fdc408f67414dc6aefaee449b0722
4
+ data.tar.gz: 1e695236b23a8a12790732c8f00fbe0bf7251fda
5
5
  SHA512:
6
- metadata.gz: e2d53081c9d2c4041458aedd80ef01f4ac4933882edb08315081a8ec7846ef9dcad9730a8a21458a78ad78bc913c94ca6fd06f55376706b1c0ead43254090b91
7
- data.tar.gz: 5ae1ffcf79b52f2d9b52aa59d66eeeaf7f1b1ad80a247d4549ac902ef1e2e7bdcc70c6429974faba32f085d5a5b0d859d5288927a043528718ce00d7c0ad0f55
6
+ metadata.gz: 714ba49dd47d39cfaef3d19ff8e0d56e115d059760016fd43a6d6379701422e58fb10a8b6481972d4108fc7e6db35cf82339a494dcff810f743363db6de757e8
7
+ data.tar.gz: 9a645417282d73779cdfabaad7222b6b5bc769e9d1a0968ffa51f901eb66ce3bdbadb715398a7c7853ad4607da3c63fffad3b97b684b22b69740612d47712c08
@@ -5,13 +5,10 @@ rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
7
  - 2.1.0
8
+ - 2.2.0
8
9
  - jruby-18mode
9
10
  - jruby-19mode
10
11
  - rbx-2
11
12
  - ruby-head
12
13
  - jruby-head
13
14
  - ree
14
- matrix:
15
- allow_failures:
16
- - rvm: ruby-head
17
- - rvm: jruby-head
data/README.md CHANGED
@@ -62,6 +62,25 @@ You can also memoize class methods.
62
62
 
63
63
  end
64
64
 
65
+ When a sub-class overrides one of its parent's methods and you need to memoize both.
66
+ Then you can use the `:identifier` parameter in order to help _Memoist_ distinguish between the two.
67
+
68
+ class Clock
69
+ extend Memoist
70
+ def now
71
+ "The time now is #{Time.now.hour} o'clock and #{Time.now.min} minutes"
72
+ end
73
+ memoize :now
74
+ end
75
+
76
+ class AccurateClock < Clock
77
+ extend Memoist
78
+ def now
79
+ "#{super} and #{Time.now.sec} seconds"
80
+ end
81
+ memoize :now, :identifier => :accurate_clock
82
+ end
83
+
65
84
 
66
85
  Reload
67
86
  ------
@@ -101,7 +120,7 @@ Everyone who contributed to it in the rails repository.
101
120
  Contributing
102
121
  ============
103
122
 
104
- 1. Fork it ( http://github.com/<my-github-username>/memoist/fork )
123
+ 1. Fork it ( http://github.com/*my-github-username*/memoist/fork )
105
124
  2. Create your feature branch (`git checkout -b my-new-feature`)
106
125
  3. Commit your changes (`git commit -am 'Add some feature'`)
107
126
  4. Push to the branch (`git push origin my-new-feature`)
@@ -96,7 +96,8 @@ module Memoist
96
96
  include InstanceMethods
97
97
 
98
98
  if method_defined?(unmemoized_method)
99
- raise AlreadyMemoizedError.new("Already memoized #{method_name}")
99
+ warn "Already memoized #{method_name}"
100
+ return
100
101
  end
101
102
  alias_method unmemoized_method, method_name
102
103
 
@@ -197,5 +198,4 @@ module Memoist
197
198
  method_names.length == 1 ? method_names.first : method_names
198
199
  end
199
200
 
200
- class AlreadyMemoizedError < RuntimeError; end
201
201
  end
@@ -1,3 +1,3 @@
1
1
  module Memoist
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
@@ -330,18 +330,6 @@ class MemoistTest < Minitest::Unit::TestCase
330
330
  assert_equal 2, company.sales_tax_calls
331
331
  end
332
332
 
333
- def test_double_memoization
334
- assert_raises(Memoist::AlreadyMemoizedError) { Person.memoize :name }
335
- person = Person.new
336
- person.extend Memoist
337
- assert_raises(Memoist::AlreadyMemoizedError) { person.memoize :name }
338
-
339
- company = Company.new
340
- company.extend Memoist
341
- company.memoize :name
342
- assert_raises(Memoist::AlreadyMemoizedError) { company.memoize :name }
343
- end
344
-
345
333
  def test_double_memoization_with_identifier
346
334
  Person.memoize :name, :identifier => :again
347
335
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memoist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2014-10-10 00:00:00.000000000 Z
22
+ date: 2015-04-13 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: bundler
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.2.2
116
+ rubygems_version: 2.4.5
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: memoize methods invocation