pakiderm 2.0.0 → 2.0.1
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 +5 -5
- data/CHANGELOG.md +8 -0
- data/README.md +20 -47
- data/lib/pakiderm.rb +2 -2
- data/lib/pakiderm/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '08f9f75542494482d1a1a556c39f4b96c3711807aef701e90e51f9ff709515ac'
|
4
|
+
data.tar.gz: a6d903bd7a22835612c141f2cad52fbe9f28ca552ce829c46730977aae3f2f88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 301114c77d1a62bba6f9ec3405551dc5d1a89c99290baee180e2ecb0eee33f8bd8b33946e19c0c93a63b074a7e9eb253670a7cb86668eb3553d29742741d6ac9
|
7
|
+
data.tar.gz: 5e465d6aaec3106149eae792501583fe2c24660fa2ac5073e105659e0301cdacf38963624457a48e5a0cc89574ff76db9aaa1b4192275cae598d8db7f09af3a2
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
## Pakiderm 2.0.1 (2021-02-24) ##
|
2
|
+
|
3
|
+
* Remove `ruby_version` restriction from gemspec to allow usage in Ruby 3.0.
|
4
|
+
|
5
|
+
## Pakiderm 2.0.0 (2017-04-02) ##
|
6
|
+
|
7
|
+
* Use a lighter memoization stragegy based on `instance_variable_defined?`.
|
8
|
+
* Remove support for `assignable`; not that useful in practice.
|
data/README.md
CHANGED
@@ -1,35 +1,32 @@
|
|
1
|
-
Pakiderm
|
1
|
+
Pakiderm [](http://badge.fury.io/rb/pakiderm) [](https://github.com/ElMassimo/pakiderm/actions) [](https://codeclimate.com/github/ElMassimo/pakiderm) [](https://github.com/ElMassimo/queryable/blob/master/LICENSE.txt)
|
2
2
|
=====================
|
3
3
|
|
4
|
-
|
5
|
-
[](https://travis-ci.org/ElMassimo/pakiderm)
|
6
|
-
[](https://coveralls.io/github/ElMassimo/pakiderm?branch=master)
|
7
|
-
[](http://inch-ci.org/github/ElMassimo/pakiderm)
|
8
|
-
[](https://github.com/ElMassimo/queryable/blob/master/LICENSE.txt)
|
4
|
+
Allows you to unobtrusively memoize methods without parameters.
|
9
5
|
|
10
|
-
Allows you to unobtrusively memoize simple methods.
|
11
|
-
|
12
|
-
## Usage
|
13
6
|
```ruby
|
14
|
-
class
|
7
|
+
class Stopwatch
|
15
8
|
extend Pakiderm
|
16
9
|
|
10
|
+
def start
|
11
|
+
@started_at = Time.now
|
12
|
+
end
|
13
|
+
|
14
|
+
def stop
|
15
|
+
elapsed_time
|
16
|
+
end
|
17
|
+
|
17
18
|
memoize \
|
18
|
-
def
|
19
|
-
|
19
|
+
def elapsed_time
|
20
|
+
Time.now - @started_at
|
20
21
|
end
|
21
22
|
end
|
22
23
|
```
|
23
|
-
|
24
|
-
```
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
=> 1
|
30
|
-
|
31
|
-
counter.increment
|
32
|
-
=> 1
|
24
|
+
Memoized methods will only be called the first time; the result will be stored and returned on subsequent invocations.
|
25
|
+
```ruby
|
26
|
+
stopwatch = Stopwatch.new
|
27
|
+
stopwatch.start
|
28
|
+
stopwatch.stop # Example: 3.991826
|
29
|
+
stopwatch.elapsed_time # => 3.991826
|
33
30
|
```
|
34
31
|
You can also pass a list of methods that should be memoized:
|
35
32
|
```ruby
|
@@ -40,28 +37,4 @@ memoize :complex_calculation, :api_response, :db_query
|
|
40
37
|
Pakiderm adds a method by using `Module#prepend` in order to"intercept" calls to the original method and provide memoization.
|
41
38
|
|
42
39
|
### Caveat
|
43
|
-
If you override the method in a subclass, Pakiderm's method won't be able to intercept calls to the subclass' method.
|
44
|
-
|
45
|
-
License
|
46
|
-
--------
|
47
|
-
|
48
|
-
Copyright (c) 2014 Máximo Mussini
|
49
|
-
|
50
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
51
|
-
a copy of this software and associated documentation files (the
|
52
|
-
"Software"), to deal in the Software without restriction, including
|
53
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
54
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
55
|
-
permit persons to whom the Software is furnished to do so, subject to
|
56
|
-
the following conditions:
|
57
|
-
|
58
|
-
The above copyright notice and this permission notice shall be
|
59
|
-
included in all copies or substantial portions of the Software.
|
60
|
-
|
61
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
62
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
63
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
64
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
65
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
66
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
67
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
40
|
+
If you override the method in a subclass, Pakiderm's method won't be able to intercept calls to the subclass' method, so you would need to call `memoize` again in the subclass.
|
data/lib/pakiderm.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#
|
9
9
|
# memoize \
|
10
10
|
# def recent_activity
|
11
|
-
#
|
11
|
+
# Activities.get("/api/#{person.id}")
|
12
12
|
# end
|
13
13
|
# end
|
14
14
|
#
|
@@ -19,7 +19,7 @@ module Pakiderm
|
|
19
19
|
#
|
20
20
|
# Examples
|
21
21
|
#
|
22
|
-
# memoize :
|
22
|
+
# memoize :ready?, :complex_formula, :long_running_method!
|
23
23
|
#
|
24
24
|
# Returns nothing.
|
25
25
|
def memoize(*names)
|
data/lib/pakiderm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakiderm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-given
|
@@ -32,6 +32,7 @@ extensions: []
|
|
32
32
|
extra_rdoc_files:
|
33
33
|
- README.md
|
34
34
|
files:
|
35
|
+
- CHANGELOG.md
|
35
36
|
- README.md
|
36
37
|
- lib/pakiderm.rb
|
37
38
|
- lib/pakiderm/version.rb
|
@@ -39,13 +40,13 @@ homepage: https://github.com/ElMassimo/pakiderm
|
|
39
40
|
licenses:
|
40
41
|
- MIT
|
41
42
|
metadata: {}
|
42
|
-
post_install_message:
|
43
|
+
post_install_message:
|
43
44
|
rdoc_options: []
|
44
45
|
require_paths:
|
45
46
|
- lib
|
46
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
48
|
requirements:
|
48
|
-
- - "
|
49
|
+
- - ">="
|
49
50
|
- !ruby/object:Gem::Version
|
50
51
|
version: '2.0'
|
51
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -54,9 +55,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
55
|
- !ruby/object:Gem::Version
|
55
56
|
version: '0'
|
56
57
|
requirements: []
|
57
|
-
|
58
|
-
|
59
|
-
signing_key:
|
58
|
+
rubygems_version: 3.2.3
|
59
|
+
signing_key:
|
60
60
|
specification_version: 4
|
61
61
|
summary: Pakiderm will never forget the return value.
|
62
62
|
test_files: []
|