memery 1.5.0 → 1.7.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 +4 -4
- data/.github/workflows/ci.yml +3 -3
- data/.rubocop.yml +1 -1
- data/Gemfile +11 -0
- data/Gemfile.lock +88 -67
- data/README.md +53 -20
- data/Rakefile +2 -1
- data/benchmark.rb +26 -0
- data/lib/memery/version.rb +1 -1
- data/lib/memery.rb +15 -6
- data/memery.gemspec +1 -14
- metadata +5 -160
- data/CHANGELOG.md +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56c60aff8199aebc5f2b15e9b777937eea73a7246c61b265c2f6ee980b6dbcd1
|
4
|
+
data.tar.gz: f16d9b904ded0d29ca13a7a3690f07e4ecec2cb681e56fce6c390db75a20e4cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55a891049c8df688bad894e69ece34b11e4319ce1e00c63a081b01df728918661ff1bc7148f0278c20f1c5fa150eca036fcb3b3f7a35b13c859a7552e5f2d39f
|
7
|
+
data.tar.gz: 491214a08cf1286d6dc908f8972c02c9273b5b8e571cc894e377ab425a965fe0997a5053cd6ab3faae240af0a78159e2cc3418d08b74d8639e2f133d6f54dc27
|
data/.github/workflows/ci.yml
CHANGED
@@ -12,12 +12,12 @@ jobs:
|
|
12
12
|
strategy:
|
13
13
|
fail-fast: false
|
14
14
|
matrix:
|
15
|
-
ruby: ["
|
15
|
+
ruby: ["3.0", "3.1", "3.2", "3.3", "3.4"]
|
16
16
|
|
17
17
|
name: ${{ matrix.ruby }}
|
18
18
|
|
19
19
|
steps:
|
20
|
-
- uses: actions/checkout@
|
20
|
+
- uses: actions/checkout@v4
|
21
21
|
|
22
22
|
- uses: ruby/setup-ruby@v1
|
23
23
|
with:
|
@@ -26,6 +26,6 @@ jobs:
|
|
26
26
|
|
27
27
|
- run: bundle exec rake
|
28
28
|
|
29
|
-
- uses: coverallsapp/github-action@
|
29
|
+
- uses: coverallsapp/github-action@v2
|
30
30
|
with:
|
31
31
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,100 +1,121 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
memery (1.
|
5
|
-
ruby2_keywords (~> 0.0.2)
|
4
|
+
memery (1.7.0)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
9
8
|
specs:
|
10
|
-
activesupport (
|
9
|
+
activesupport (7.1.5.1)
|
10
|
+
base64
|
11
|
+
benchmark (>= 0.3)
|
12
|
+
bigdecimal
|
11
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
connection_pool (>= 2.2.5)
|
15
|
+
drb
|
12
16
|
i18n (>= 1.6, < 2)
|
17
|
+
logger (>= 1.4.2)
|
13
18
|
minitest (>= 5.1)
|
19
|
+
mutex_m
|
20
|
+
securerandom (>= 0.3)
|
14
21
|
tzinfo (~> 2.0)
|
15
|
-
zeitwerk (~> 2.3)
|
16
22
|
ast (2.4.2)
|
17
|
-
|
18
|
-
benchmark
|
19
|
-
|
23
|
+
base64 (0.2.0)
|
24
|
+
benchmark (0.4.0)
|
25
|
+
benchmark-ips (2.14.0)
|
26
|
+
benchmark-memory (0.2.0)
|
27
|
+
memory_profiler (~> 1)
|
28
|
+
bigdecimal (3.1.9)
|
20
29
|
coderay (1.1.3)
|
21
|
-
concurrent-ruby (1.
|
22
|
-
|
23
|
-
|
24
|
-
|
30
|
+
concurrent-ruby (1.3.4)
|
31
|
+
connection_pool (2.4.1)
|
32
|
+
diff-lcs (1.5.1)
|
33
|
+
docile (1.4.1)
|
34
|
+
drb (2.2.1)
|
35
|
+
i18n (1.14.6)
|
25
36
|
concurrent-ruby (~> 1.0)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
37
|
+
json (2.9.1)
|
38
|
+
language_server-protocol (3.17.0.3)
|
39
|
+
logger (1.6.4)
|
40
|
+
memory_profiler (1.0.2)
|
41
|
+
method_source (1.1.0)
|
42
|
+
minitest (5.25.4)
|
43
|
+
mutex_m (0.3.0)
|
44
|
+
parallel (1.26.3)
|
45
|
+
parser (3.3.6.0)
|
31
46
|
ast (~> 2.4.1)
|
32
|
-
|
47
|
+
racc
|
48
|
+
pry (0.15.2)
|
33
49
|
coderay (~> 1.1)
|
34
50
|
method_source (~> 1.0)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
rspec (3.
|
41
|
-
rspec-core (~> 3.
|
42
|
-
rspec-expectations (~> 3.
|
43
|
-
rspec-mocks (~> 3.
|
44
|
-
rspec-core (3.
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-expectations (3.
|
51
|
+
racc (1.8.1)
|
52
|
+
rack (3.1.8)
|
53
|
+
rainbow (3.1.1)
|
54
|
+
rake (13.2.1)
|
55
|
+
regexp_parser (2.10.0)
|
56
|
+
rspec (3.13.0)
|
57
|
+
rspec-core (~> 3.13.0)
|
58
|
+
rspec-expectations (~> 3.13.0)
|
59
|
+
rspec-mocks (~> 3.13.0)
|
60
|
+
rspec-core (3.13.2)
|
61
|
+
rspec-support (~> 3.13.0)
|
62
|
+
rspec-expectations (3.13.3)
|
47
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.
|
49
|
-
rspec-mocks (3.
|
64
|
+
rspec-support (~> 3.13.0)
|
65
|
+
rspec-mocks (3.13.2)
|
50
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-support (3.
|
53
|
-
rubocop (1.
|
67
|
+
rspec-support (~> 3.13.0)
|
68
|
+
rspec-support (3.13.2)
|
69
|
+
rubocop (1.69.2)
|
70
|
+
json (~> 2.3)
|
71
|
+
language_server-protocol (>= 3.17.0)
|
54
72
|
parallel (~> 1.10)
|
55
|
-
parser (>= 3.
|
73
|
+
parser (>= 3.3.0.2)
|
56
74
|
rainbow (>= 2.2.2, < 4.0)
|
57
|
-
regexp_parser (>=
|
58
|
-
|
59
|
-
rubocop-ast (>= 1.2.0, < 2.0)
|
75
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
76
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
60
77
|
ruby-progressbar (~> 1.7)
|
61
|
-
unicode-display_width (>=
|
62
|
-
rubocop-ast (1.
|
63
|
-
parser (>= 3.
|
64
|
-
rubocop-config-umbrellio (1.
|
65
|
-
rubocop (
|
66
|
-
rubocop-
|
67
|
-
rubocop-
|
68
|
-
rubocop-
|
69
|
-
rubocop-
|
70
|
-
rubocop-
|
71
|
-
|
72
|
-
|
73
|
-
rubocop
|
74
|
-
rubocop-
|
78
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
79
|
+
rubocop-ast (1.37.0)
|
80
|
+
parser (>= 3.3.1.0)
|
81
|
+
rubocop-config-umbrellio (1.69.0.101)
|
82
|
+
rubocop (~> 1.69.0)
|
83
|
+
rubocop-factory_bot (~> 2.26.0)
|
84
|
+
rubocop-performance (~> 1.23.0)
|
85
|
+
rubocop-rails (~> 2.28.0)
|
86
|
+
rubocop-rake (~> 0.6.0)
|
87
|
+
rubocop-rspec (~> 3.3.0)
|
88
|
+
rubocop-sequel (~> 0.3.0)
|
89
|
+
rubocop-factory_bot (2.26.1)
|
90
|
+
rubocop (~> 1.61)
|
91
|
+
rubocop-performance (1.23.1)
|
92
|
+
rubocop (>= 1.48.1, < 2.0)
|
93
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
94
|
+
rubocop-rails (2.28.0)
|
75
95
|
activesupport (>= 4.2.0)
|
76
96
|
rack (>= 1.1)
|
77
|
-
rubocop (>=
|
78
|
-
|
79
|
-
|
80
|
-
rubocop-rspec (2.2.0)
|
97
|
+
rubocop (>= 1.52.0, < 2.0)
|
98
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
99
|
+
rubocop-rake (0.6.0)
|
81
100
|
rubocop (~> 1.0)
|
82
|
-
|
83
|
-
|
101
|
+
rubocop-rspec (3.3.0)
|
102
|
+
rubocop (~> 1.61)
|
103
|
+
rubocop-sequel (0.3.8)
|
84
104
|
rubocop (~> 1.0)
|
85
|
-
ruby-progressbar (1.
|
86
|
-
|
87
|
-
simplecov (0.
|
105
|
+
ruby-progressbar (1.13.0)
|
106
|
+
securerandom (0.3.2)
|
107
|
+
simplecov (0.22.0)
|
88
108
|
docile (~> 1.1)
|
89
109
|
simplecov-html (~> 0.11)
|
90
110
|
simplecov_json_formatter (~> 0.1)
|
91
|
-
simplecov-html (0.
|
111
|
+
simplecov-html (0.13.1)
|
92
112
|
simplecov-lcov (0.8.0)
|
93
|
-
simplecov_json_formatter (0.1.
|
94
|
-
tzinfo (2.0.
|
113
|
+
simplecov_json_formatter (0.1.4)
|
114
|
+
tzinfo (2.0.6)
|
95
115
|
concurrent-ruby (~> 1.0)
|
96
|
-
unicode-display_width (
|
97
|
-
|
116
|
+
unicode-display_width (3.1.3)
|
117
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
118
|
+
unicode-emoji (4.0.4)
|
98
119
|
|
99
120
|
PLATFORMS
|
100
121
|
ruby
|
@@ -113,4 +134,4 @@ DEPENDENCIES
|
|
113
134
|
simplecov-lcov
|
114
135
|
|
115
136
|
BUNDLED WITH
|
116
|
-
2.
|
137
|
+
2.5.23
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Memery [](https://badge.fury.io/rb/memery)  [](https://coveralls.io/github/tycooon/memery?branch=master)
|
2
2
|
|
3
|
-
Memery is a Ruby gem
|
3
|
+
Memery is a Ruby gem that simplifies memoization of method return values. In Ruby, memoization typically looks like this:
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
def user
|
@@ -8,7 +8,7 @@ def user
|
|
8
8
|
end
|
9
9
|
```
|
10
10
|
|
11
|
-
However, this approach
|
11
|
+
However, this approach fails if the calculated result can be `nil` or `false`, or if the method uses arguments. Additionally, multi-line methods require extra `begin`/`end` blocks:
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
def user
|
@@ -20,7 +20,7 @@ def user
|
|
20
20
|
end
|
21
21
|
```
|
22
22
|
|
23
|
-
|
23
|
+
To handle these situations, memoization gems like Memery exist. The example above can be rewritten using Memery as follows:
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
memoize def user
|
@@ -32,7 +32,7 @@ end
|
|
32
32
|
|
33
33
|
## Installation
|
34
34
|
|
35
|
-
|
35
|
+
Add `gem "memery"` to your Gemfile.
|
36
36
|
|
37
37
|
## Usage
|
38
38
|
|
@@ -45,7 +45,7 @@ class A
|
|
45
45
|
42
|
46
46
|
end
|
47
47
|
|
48
|
-
#
|
48
|
+
# Alternatively:
|
49
49
|
# def call
|
50
50
|
# ...
|
51
51
|
# end
|
@@ -56,13 +56,13 @@ a = A.new
|
|
56
56
|
a.call # => 42
|
57
57
|
a.call # => 42
|
58
58
|
a.call # => 42
|
59
|
-
#
|
59
|
+
# "calculating" will only be printed once.
|
60
60
|
|
61
61
|
a.call { 1 } # => 42
|
62
|
-
#
|
62
|
+
# "calculating" will be printed again because passing a block disables memoization.
|
63
63
|
```
|
64
64
|
|
65
|
-
|
65
|
+
Memoization works with methods that take arguments. The memoization is based on these arguments using an internal hash, so the following will work as expected:
|
66
66
|
|
67
67
|
```ruby
|
68
68
|
class A
|
@@ -78,7 +78,7 @@ a = A.new
|
|
78
78
|
a.call(1, 5) # => 6
|
79
79
|
a.call(2, 15) # => 17
|
80
80
|
a.call(1, 5) # => 6
|
81
|
-
#
|
81
|
+
# "calculating" will be printed twice, once for each unique argument list.
|
82
82
|
```
|
83
83
|
|
84
84
|
For class methods:
|
@@ -98,10 +98,10 @@ end
|
|
98
98
|
B.call # => 42
|
99
99
|
B.call # => 42
|
100
100
|
B.call # => 42
|
101
|
-
#
|
101
|
+
# "calculating" will only be printed once.
|
102
102
|
```
|
103
103
|
|
104
|
-
|
104
|
+
### Conditional Memoization
|
105
105
|
|
106
106
|
```ruby
|
107
107
|
class A
|
@@ -136,7 +136,7 @@ a.call # => 42
|
|
136
136
|
# with `true` result of condition block.
|
137
137
|
```
|
138
138
|
|
139
|
-
|
139
|
+
### Memoization with Time-to-Live (TTL)
|
140
140
|
|
141
141
|
```ruby
|
142
142
|
class A
|
@@ -168,7 +168,7 @@ a.call # => 42
|
|
168
168
|
a.call # => 42
|
169
169
|
```
|
170
170
|
|
171
|
-
|
171
|
+
### Checking if a Method is Memoized
|
172
172
|
|
173
173
|
```ruby
|
174
174
|
class A
|
@@ -190,8 +190,39 @@ a.memoized?(:call) # => true
|
|
190
190
|
a.memoized?(:execute) # => false
|
191
191
|
```
|
192
192
|
|
193
|
-
|
194
|
-
|
193
|
+
### Marshal-compatible Memoization
|
194
|
+
|
195
|
+
In order for objects to be marshaled and loaded in a different Ruby process,
|
196
|
+
hashed arguments must be disabled in order for memoized values to be retained.
|
197
|
+
Note that this can have a performance impact if the memoized method contains
|
198
|
+
arguments.
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
Memery.use_hashed_arguments = false
|
202
|
+
|
203
|
+
class A
|
204
|
+
include Memery
|
205
|
+
|
206
|
+
memoize def call
|
207
|
+
puts "calculating"
|
208
|
+
42
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
a = A.new
|
213
|
+
a.call
|
214
|
+
|
215
|
+
Marshal.dump(a)
|
216
|
+
# => "\x04\bo:\x06A\x06:\x1D@_memery_memoized_values{\x06:\tcallS:3Memery::ClassMethods::MemoizationModule::Cache\a:\vresulti/:\ttimef\x14663237.14822323"
|
217
|
+
|
218
|
+
# ...in another Ruby process:
|
219
|
+
a = Marshal.load("\x04\bo:\x06A\x06:\x1D@_memery_memoized_values{\x06:\tcallS:3Memery::ClassMethods::MemoizationModule::Cache\a:\vresulti/:\ttimef\x14663237.14822323")
|
220
|
+
a.call # => 42
|
221
|
+
```
|
222
|
+
|
223
|
+
## Differences from Other Gems
|
224
|
+
|
225
|
+
Memery is similar to [Memoist](https://github.com/matthewrudy/memoist), but it doesn't override methods. Instead, it uses Ruby 2's `Module.prepend` feature. This approach is cleaner, allowing you to inspect the original method body with `method(:x).super_method.source`, and it ensures that subclasses' methods function properly. If you redefine a memoized method in a subclass, it won't be memoized by default. You can memoize it normally without needing an awkward `identifier: ` argument, and it will just work:
|
195
226
|
|
196
227
|
```ruby
|
197
228
|
class A
|
@@ -217,9 +248,9 @@ b.instance_variable_get(:@_memery_memoized_values)
|
|
217
248
|
# => {:x_70318201388120=>{[1]=>2, [2]=>4, [3]=>6}, :x_70318184636620=>{[2]=>2}}
|
218
249
|
```
|
219
250
|
|
220
|
-
Note how both
|
251
|
+
Note how both methods' return values are cached separately without interfering with each other.
|
221
252
|
|
222
|
-
|
253
|
+
Another key difference is that Memery doesn't change the method's signature (no extra `reload` parameter). If you need an unmemoized result, simply create an unmemoized version of the method:
|
223
254
|
|
224
255
|
```ruby
|
225
256
|
memoize def users
|
@@ -231,19 +262,21 @@ def get_users
|
|
231
262
|
end
|
232
263
|
```
|
233
264
|
|
234
|
-
Alternatively, you can clear the
|
265
|
+
Alternatively, you can clear the entire instance's cache:
|
235
266
|
|
236
267
|
```ruby
|
237
268
|
a.clear_memery_cache!
|
238
269
|
```
|
239
270
|
|
240
|
-
|
271
|
+
You can also provide a block, though this approach is somewhat hacky:
|
241
272
|
|
242
273
|
```ruby
|
243
274
|
a.users {}
|
244
275
|
```
|
245
276
|
|
246
|
-
|
277
|
+
## Object Shape Optimization
|
278
|
+
|
279
|
+
In Ruby 3.2, a new optimization called "object shape" was introduced, which can have negative interactions with dynamically added instance variables. Memery minimizes this impact by introducing only one new instance variable after initialization (`@_memery_memoized_values`). If you need to ensure a specific object shape, you can call `clear_memery_cache!` in your initializer to set the instance variable ahead of time.
|
247
280
|
|
248
281
|
## Contributing
|
249
282
|
|
data/Rakefile
CHANGED
data/benchmark.rb
CHANGED
@@ -32,6 +32,10 @@ class Foo
|
|
32
32
|
memoize def find_new(char)
|
33
33
|
base_find(char)
|
34
34
|
end
|
35
|
+
|
36
|
+
memoize def find_optional(*)
|
37
|
+
base_find("z")
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -43,6 +47,10 @@ def test_with_args
|
|
43
47
|
Foo.find_new("d")
|
44
48
|
end
|
45
49
|
|
50
|
+
def test_empty_args
|
51
|
+
Foo.find_optional
|
52
|
+
end
|
53
|
+
|
46
54
|
Benchmark.ips do |x|
|
47
55
|
x.report("test_no_args") { test_no_args }
|
48
56
|
end
|
@@ -51,6 +59,14 @@ Benchmark.memory do |x|
|
|
51
59
|
x.report("test_no_args") { 100.times { test_no_args } }
|
52
60
|
end
|
53
61
|
|
62
|
+
Benchmark.ips do |x|
|
63
|
+
x.report("test_empty_args") { test_empty_args }
|
64
|
+
end
|
65
|
+
|
66
|
+
Benchmark.memory do |x|
|
67
|
+
x.report("test_empty_args") { 100.times { test_empty_args } }
|
68
|
+
end
|
69
|
+
|
54
70
|
Benchmark.ips do |x|
|
55
71
|
x.report("test_with_args") { test_with_args }
|
56
72
|
end
|
@@ -59,4 +75,14 @@ Benchmark.memory do |x|
|
|
59
75
|
x.report("test_with_args") { 100.times { test_with_args } }
|
60
76
|
end
|
61
77
|
|
78
|
+
Memery.use_hashed_arguments = false
|
79
|
+
Benchmark.ips do |x|
|
80
|
+
x.report("test_with_args_no_hash") { test_with_args }
|
81
|
+
end
|
82
|
+
|
83
|
+
Benchmark.memory do |x|
|
84
|
+
x.report("test_with_args_no_hash") { 100.times { test_with_args } }
|
85
|
+
end
|
86
|
+
Memery.use_hashed_arguments = true
|
87
|
+
|
62
88
|
puts "```"
|
data/lib/memery/version.rb
CHANGED
data/lib/memery.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "ruby2_keywords"
|
4
|
-
|
5
3
|
require "memery/version"
|
6
4
|
|
7
5
|
module Memery
|
8
6
|
class << self
|
7
|
+
attr_accessor :use_hashed_arguments
|
8
|
+
|
9
9
|
def monotonic_clock
|
10
10
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
@use_hashed_arguments = true
|
15
|
+
|
14
16
|
OUR_BLOCK = lambda do
|
15
17
|
extend(ClassMethods)
|
16
18
|
include(InstanceMethods)
|
@@ -70,11 +72,12 @@ module Memery
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
75
|
+
# rubocop:disable Metrics/MethodLength
|
73
76
|
def define_memoized_method!(klass, method_name, condition: nil, ttl: nil)
|
74
|
-
|
75
|
-
|
77
|
+
# Include a suffix in the method key to differentiate between methods of the same name
|
78
|
+
# being memoized throughout a class inheritance hierarchy
|
79
|
+
method_key = "#{method_name}_#{klass.name || object_id}"
|
76
80
|
original_visibility = method_visibility(klass, method_name)
|
77
|
-
original_arity = klass.instance_method(method_name).arity
|
78
81
|
|
79
82
|
define_method(method_name) do |*args, &block|
|
80
83
|
if block || (condition && !instance_exec(&condition))
|
@@ -82,7 +85,12 @@ module Memery
|
|
82
85
|
end
|
83
86
|
|
84
87
|
cache_store = (@_memery_memoized_values ||= {})
|
85
|
-
cache_key =
|
88
|
+
cache_key = if args.empty?
|
89
|
+
method_key
|
90
|
+
else
|
91
|
+
key_parts = [method_key, *args]
|
92
|
+
Memery.use_hashed_arguments ? key_parts.hash : key_parts
|
93
|
+
end
|
86
94
|
cache = cache_store[cache_key]
|
87
95
|
|
88
96
|
return cache.result if cache&.fresh?(ttl)
|
@@ -97,6 +105,7 @@ module Memery
|
|
97
105
|
ruby2_keywords(method_name)
|
98
106
|
send(original_visibility, method_name)
|
99
107
|
end
|
108
|
+
# rubocop:enable Metrics/MethodLength
|
100
109
|
|
101
110
|
private
|
102
111
|
|
data/memery.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require "memery/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.required_ruby_version = ">=
|
8
|
+
spec.required_ruby_version = ">= 3.0.0"
|
9
9
|
|
10
10
|
spec.name = "memery"
|
11
11
|
spec.version = Memery::VERSION
|
@@ -21,17 +21,4 @@ Gem::Specification.new do |spec|
|
|
21
21
|
f.match(%r{^(test|spec|features)/})
|
22
22
|
end
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
-
|
25
|
-
spec.add_runtime_dependency "ruby2_keywords", "~> 0.0.2"
|
26
|
-
|
27
|
-
spec.add_development_dependency "activesupport"
|
28
|
-
spec.add_development_dependency "benchmark-ips"
|
29
|
-
spec.add_development_dependency "benchmark-memory"
|
30
|
-
spec.add_development_dependency "bundler"
|
31
|
-
spec.add_development_dependency "pry"
|
32
|
-
spec.add_development_dependency "rake"
|
33
|
-
spec.add_development_dependency "rspec"
|
34
|
-
spec.add_development_dependency "rubocop-config-umbrellio"
|
35
|
-
spec.add_development_dependency "simplecov"
|
36
|
-
spec.add_development_dependency "simplecov-lcov"
|
37
24
|
end
|
metadata
CHANGED
@@ -1,169 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuri Smirnov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby2_keywords
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: benchmark-ips
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: benchmark-memory
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bundler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rake
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rspec
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-config-umbrellio
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: simplecov
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: simplecov-lcov
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
11
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
167
13
|
description: Memery is a gem for memoization.
|
168
14
|
email:
|
169
15
|
- tycoooon@gmail.com
|
@@ -176,7 +22,6 @@ files:
|
|
176
22
|
- ".gitignore"
|
177
23
|
- ".rspec"
|
178
24
|
- ".rubocop.yml"
|
179
|
-
- CHANGELOG.md
|
180
25
|
- Gemfile
|
181
26
|
- Gemfile.lock
|
182
27
|
- LICENSE.txt
|
@@ -198,14 +43,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
43
|
requirements:
|
199
44
|
- - ">="
|
200
45
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
46
|
+
version: 3.0.0
|
202
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
48
|
requirements:
|
204
49
|
- - ">="
|
205
50
|
- !ruby/object:Gem::Version
|
206
51
|
version: '0'
|
207
52
|
requirements: []
|
208
|
-
rubygems_version: 3.
|
53
|
+
rubygems_version: 3.5.23
|
209
54
|
signing_key:
|
210
55
|
specification_version: 4
|
211
56
|
summary: A gem for memoization.
|
data/CHANGELOG.md
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
## [Unreleased]
|
2
|
-
|
3
|
-
## [1.4.0] - 2021-03-15
|
4
|
-
### Fixed
|
5
|
-
- Fix compatibility with `ActiveSupport::Concern`. ([@tycooon] and [@AlexWayfer]) [#26]
|
6
|
-
|
7
|
-
## [1.3.0] - 2020-02-10
|
8
|
-
### Added
|
9
|
-
- Allow memoization after including module with Memery. ([@AlexWayfer]) [#23]
|
10
|
-
|
11
|
-
### Changed
|
12
|
-
- Make `memoize` return the method name to allow chaining. ([@JelF]) [#22]
|
13
|
-
|
14
|
-
### Fixed
|
15
|
-
- Fix warnings in Ruby 2.7. ([@AlexWayfer]) [#19], [#25]
|
16
|
-
|
17
|
-
## [1.2.0] - 2019-10-19
|
18
|
-
### Added
|
19
|
-
- Add `:ttl` option for `memoize` method ([@AlexWayfer]) [#11]
|
20
|
-
- Add benchmark script ([@AlexWayfer]) [#14]
|
21
|
-
- Add `.memoized?` method ([@AlexWayfer]) [#17]
|
22
|
-
|
23
|
-
## [1.1.0] - 2019-08-05
|
24
|
-
### Fixed
|
25
|
-
- Optimize speed and memory for cached values returns. ([@AlexWayfer]) [#10]
|
26
|
-
|
27
|
-
## [1.0.0] - 2018-08-31
|
28
|
-
### Added
|
29
|
-
- Add `:condition` option for `.memoize` method. ([@AlexWayfer]) [#7]
|
30
|
-
|
31
|
-
## [0.6.0] - 2018-04-20
|
32
|
-
### Added
|
33
|
-
- Readme example for memoizing class methods. ([@AlexWayfer]) [#3]
|
34
|
-
- Memery raises `ArgumentError` if method is not defined when you call `memoize`.
|
35
|
-
|
36
|
-
## [0.5.0] - 2017-06-12
|
37
|
-
- Initial public version.
|
38
|
-
|
39
|
-
[0.5.0]: https://github.com/tycooon/memery/tree/v0.5.0
|
40
|
-
[0.6.0]: https://github.com/tycooon/memery/compare/v0.5.0...v0.6.0
|
41
|
-
[1.0.0]: https://github.com/tycooon/memery/compare/v0.6.0...v1.0.0
|
42
|
-
[1.1.0]: https://github.com/tycooon/memery/compare/v1.0.0...v1.1.0
|
43
|
-
[1.2.0]: https://github.com/tycooon/memery/compare/v1.1.0...v1.2.0
|
44
|
-
[1.3.0]: https://github.com/tycooon/memery/compare/v1.2.0...v1.3.0
|
45
|
-
[1.4.0]: https://github.com/tycooon/memery/compare/v1.3.0...v1.4.0
|
46
|
-
[Unreleased]: https://github.com/tycooon/memery/compare/v1.4.0...HEAD
|
47
|
-
|
48
|
-
[@tycooon]: https://github.com/tycooon
|
49
|
-
[@AlexWayfer]: https://github.com/AlexWayfer
|
50
|
-
[@JelF]: https://github.com/JelF
|
51
|
-
|
52
|
-
[#3]: https://github.com/tycooon/memery/pull/3
|
53
|
-
[#7]: https://github.com/tycooon/memery/pull/7
|
54
|
-
[#10]: https://github.com/tycooon/memery/pull/10
|
55
|
-
[#11]: https://github.com/tycooon/memery/pull/11
|
56
|
-
[#14]: https://github.com/tycooon/memery/pull/14
|
57
|
-
[#17]: https://github.com/tycooon/memery/pull/17
|
58
|
-
[#19]: https://github.com/tycooon/memery/pull/19
|
59
|
-
[#22]: https://github.com/tycooon/memery/pull/22
|
60
|
-
[#23]: https://github.com/tycooon/memery/pull/23
|
61
|
-
[#25]: https://github.com/tycooon/memery/pull/25
|
62
|
-
[#26]: https://github.com/tycooon/memery/pull/26
|