memo_wise 1.10.0 → 1.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 +4 -4
- data/CHANGELOG.md +50 -17
- data/README.md +20 -34
- data/lib/memo_wise/internal_api.rb +1 -1
- data/lib/memo_wise/version.rb +1 -1
- data/lib/memo_wise.rb +13 -36
- metadata +4 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a910792fbcb5c44a6b7e82d8c62b4c11c64fef9d59ac79a326a34e8fde9b87
|
4
|
+
data.tar.gz: b00093fd37b3f9ff175d41db4eafde58b6af04037f07b1c02328e1aab84d674b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e93861cd450870d06793d72a19452354a983f0a2211e65086d699cb3b6c710b9d34e52bf7afa3a4e26a60e831fea9cc8b7596324f4daae83d1af84dfa9095a5
|
7
|
+
data.tar.gz: 49855e1a33e75516493a7d6ddb89b22d5856e4a8f86ccdf32ace6adde03a1873e49e504ece5d2c10122d4eeff09967257495732006e00f8d1f01966096572e8f
|
data/CHANGELOG.md
CHANGED
@@ -5,58 +5,91 @@ follows a format inspired by [Keep a Changelog](https://keepachangelog.com/en/1.
|
|
5
5
|
|
6
6
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [Unreleased](https://github.com/panorama-ed/memo_wise/compare/v1.
|
8
|
+
## [Unreleased](https://github.com/panorama-ed/memo_wise/compare/v1.12.0...HEAD)
|
9
9
|
|
10
|
-
**Gem enhancements:**
|
10
|
+
**Gem enhancements:** none
|
11
11
|
|
12
12
|
_No breaking changes!_
|
13
13
|
|
14
|
+
**Project enhancements:** none
|
15
|
+
|
16
|
+
## [v1.12.0](https://github.com/panorama-ed/memo_wise/compare/v1.11.0...v1.12.0)
|
17
|
+
|
18
|
+
**Gem enhancements:** none
|
19
|
+
|
20
|
+
- Allowed memoization when `include`d modules `prepend MemoWise` and define `initialize` [[#327]](https://github.com/panorama-ed/memo_wise/pull/327)
|
21
|
+
|
22
|
+
_Breaking changes:_
|
23
|
+
- Removed Ruby 2.7 (EOL) and 3.0 (EOL) support to allow enhancement noted above [[#327]](https://github.com/panorama-ed/memo_wise/pull/327)
|
24
|
+
|
25
|
+
**Project enhancements:**
|
26
|
+
|
27
|
+
- Updated official test coverage to support Ruby 3.4 [[#335](https://github.com/panorama-ed/memo_wise/pull/335)]
|
28
|
+
- Updated `memery` gem version to 1.7.0 in benchmarks [[#380](https://github.com/panorama-ed/memo_wise/pull/380)]
|
29
|
+
- Added `short_circu_it` gem to benchmarks [[#384](https://github.com/panorama-ed/memo_wise/pull/384)]
|
30
|
+
- Increased benchmark warmup time to reduce warmup artifacts when benchmarking locally [[#355](https://github.com/panorama-ed/memo_wise/pull/355)]
|
31
|
+
|
32
|
+
## [v1.11.0](https://github.com/panorama-ed/memo_wise/compare/v1.10.0...v1.11.0)
|
33
|
+
|
34
|
+
**Gem enhancements:**
|
35
|
+
|
36
|
+
- Stopped `preset_memo_wise` (and `reset_memo_wise` with an argument) from raising errors when called on module methods [[#377]](https://github.com/panorama-ed/memo_wise/pull/377)
|
37
|
+
- Changed internal `require`s to `require_relative` to make code less dependent on the load path [[#350](https://github.com/panorama-ed/memo_wise/pull/350)]
|
38
|
+
|
39
|
+
_Breaking changes:_
|
40
|
+
- Removed Ruby 2.5 (EOL) and 2.6 (EOL) support to allow upgrading rexml dependency version from a version that includes a [CVE](https://www.ruby-lang.org/en/news/2024/10/28/redos-rexml-cve-2024-49761/) [[#362]](https://github.com/panorama-ed/memo_wise/pull/362)
|
41
|
+
|
14
42
|
**Project enhancements:**
|
15
43
|
|
44
|
+
- Updated `webrick` in `Gemfile.lock` to resolve CVE-2024-47220. This vulnerability does not impact `memo_wise` users.
|
45
|
+
- Allowed more tests to run on JRuby [[#377]](https://github.com/panorama-ed/memo_wise/pull/377)
|
46
|
+
|
16
47
|
## [v1.10.0](https://github.com/panorama-ed/memo_wise/compare/v1.9.0...v1.10.0)
|
17
48
|
|
18
49
|
**Gem enhancements:**
|
19
50
|
|
20
|
-
- Reduced gem size from 173 kB compressed (312 kB unpacked) to
|
51
|
+
- Reduced gem size from 173 kB compressed (312 kB unpacked) to 18.5 kB (68 kB unpacked) [[#345](https://github.com/panorama-ed/memo_wise/pull/345)]
|
21
52
|
|
22
53
|
_No breaking changes!_
|
23
54
|
|
24
55
|
**Project enhancements:**
|
25
56
|
|
26
57
|
- Updated official test coverage to support Ruby 3.3 [[#335](https://github.com/panorama-ed/memo_wise/pull/335)]
|
58
|
+
- Added `alt_memery` and `memoist3` to benchmarks [[#339](https://github.com/panorama-ed/memo_wise/pull/339)]
|
59
|
+
- Updated `memery` gem version to 1.6.0 in benchmarks [[#339](https://github.com/panorama-ed/memo_wise/pull/339)]
|
60
|
+
- Updated benchmark results in `README.md` to Ruby 3.3.5 [[#339](https://github.com/panorama-ed/memo_wise/pull/339)]
|
27
61
|
|
28
62
|
## [v1.9.0](https://github.com/panorama-ed/memo_wise/compare/v1.8.0...v1.9.0)
|
29
63
|
|
30
64
|
**Gem enhancements:**
|
31
65
|
|
32
|
-
- Fixed a bug that overwrote existing self.extended method definitions. [[#324]
|
33
|
-
- Fixed a bug that overwrote existing self.inherited method definitions. [[#325]
|
66
|
+
- Fixed a bug that overwrote existing self.extended method definitions. [[#324](https://github.com/panorama-ed/memo_wise/pull/314)]
|
67
|
+
- Fixed a bug that overwrote existing self.inherited method definitions. [[#325](https://github.com/panorama-ed/memo_wise/pull/315)]
|
34
68
|
|
35
69
|
_Breaking changes:_
|
36
|
-
- Removed Ruby 2.4 (EOL) support to allow upgrading rexml dependency version from a version that includes a [CVE](https://www.ruby-lang.org/en/news/2024/05/16/dos-rexml-cve-2024-35176/) [[#336]
|
70
|
+
- Removed Ruby 2.4 (EOL) support to allow upgrading rexml dependency version from a version that includes a [CVE](https://www.ruby-lang.org/en/news/2024/05/16/dos-rexml-cve-2024-35176/) [[#336](https://github.com/panorama-ed/memo_wise/pull/336)]
|
37
71
|
|
38
72
|
**Project enhancements:**
|
39
73
|
|
40
|
-
- Fixed `bundle exec yard server --reload` and related documentation [[#333]
|
41
|
-
- Fixed Codecov rate limiting errors affecting pull requests by upgrading `codecov/codecov-action` and using a Codecov token [[#317]
|
74
|
+
- Fixed `bundle exec yard server --reload` and related documentation [[#333](https://github.com/panorama-ed/memo_wise/pull/333)]
|
75
|
+
- Fixed Codecov rate limiting errors affecting pull requests by upgrading `codecov/codecov-action` and using a Codecov token [[#317](https://github.com/panorama-ed/memo_wise/pull/317)]
|
42
76
|
|
43
77
|
## [v1.8.0](https://github.com/panorama-ed/memo_wise/compare/v1.7.0...v1.8.0) - 2023-10-25
|
44
78
|
|
45
79
|
**Gem enhancements:**
|
46
80
|
|
47
|
-
- In Ruby3.2+, for singleton classes, use `#attached_object` instead of `ObjectSpace` [[#318]
|
81
|
+
- In Ruby3.2+, for singleton classes, use `#attached_object` instead of `ObjectSpace` [[#318](https://github.com/panorama-ed/memo_wise/pull/318)]
|
48
82
|
|
49
83
|
_No breaking changes!_
|
50
84
|
|
51
85
|
**Project enhancements:**
|
52
86
|
|
53
|
-
- Switched RuboCop configuration from `panolint` to `panolint-ruby` [[#312]
|
54
|
-
- Updated benchmark results in `README.md` to Ruby 3.2.2 and 2.7.8 [[#313]
|
55
|
-
- Updated `
|
56
|
-
- Updated `
|
57
|
-
- Updated `
|
58
|
-
- Reorganized `CHANGELOG.md` for improved clarity and completeness
|
59
|
-
[[#282](https://github.com/panorama-ed/memo_wise/pull/282)]
|
87
|
+
- Switched RuboCop configuration from `panolint` to `panolint-ruby` [[#312](https://github.com/panorama-ed/memo_wise/pull/312)]
|
88
|
+
- Updated benchmark results in `README.md` to Ruby 3.2.2 and 2.7.8 [[#313](https://github.com/panorama-ed/memo_wise/pull/297)]
|
89
|
+
- Updated `dry-core` gem version to 1.0.0 in benchmarks [[#297](https://github.com/panorama-ed/memo_wise/pull/297)]
|
90
|
+
- Updated `memery` gem version to 1.5.0 in benchmarks [[#313](https://github.com/panorama-ed/memo_wise/pull/313)]
|
91
|
+
- Updated `memoized` gem version to 1.1.1 in benchmarks [[#288](https://github.com/panorama-ed/memo_wise/pull/288)]
|
92
|
+
- Reorganized `CHANGELOG.md` for improved clarity and completeness [[#282](https://github.com/panorama-ed/memo_wise/pull/282)]
|
60
93
|
|
61
94
|
## [v1.7.0](https://github.com/panorama-ed/memo_wise/compare/v1.6.0...v1.7.0) - 2022-04-04
|
62
95
|
|
@@ -240,7 +273,7 @@ _No breaking changes!_
|
|
240
273
|
|
241
274
|
**Project enhancements:**
|
242
275
|
|
243
|
-
- Tests now assert that memoization works with the `
|
276
|
+
- Tests now assert that memoization works with the `values` gem
|
244
277
|
[[#46](https://github.com/panorama-ed/memo_wise/pull/46)]
|
245
278
|
- Added `README.md` badges for tests, docs, and RubyGems
|
246
279
|
[[#47](https://github.com/panorama-ed/memo_wise/pull/47)]
|
data/README.md
CHANGED
@@ -112,39 +112,25 @@ For more usage details, see our detailed [documentation](#documentation).
|
|
112
112
|
|
113
113
|
## Benchmarks
|
114
114
|
|
115
|
-
Benchmarks are run in GitHub Actions, and the tables below are updated with every code change. **Values >1.00x represent how much _slower_ each gem’s memoized value retrieval is than the latest commit of `MemoWise`**, according to [`benchmark-ips`](https://github.com/evanphx/benchmark-ips) (2.
|
116
|
-
|
117
|
-
Results using Ruby 3.3
|
118
|
-
|
119
|
-
|Method arguments|`
|
120
|
-
|
121
|
-
|`()` (none)|0.
|
122
|
-
|`(a)`|
|
123
|
-
|`(a, b)`|0.
|
124
|
-
|`(a:)`|1.00x|
|
125
|
-
|`(a:, b:)`|0.
|
126
|
-
|`(a, b:)`|0.
|
127
|
-
|`(a, *args)`|0.
|
128
|
-
|`(a:, **kwargs)`|0.
|
129
|
-
|`(a, *args, b:, **kwargs)`|0.
|
130
|
-
|
131
|
-
\* `
|
115
|
+
Benchmarks are run in GitHub Actions, and the tables below are updated with every code change. **Values >1.00x represent how much _slower_ each gem’s memoized value retrieval is than the latest commit of `MemoWise`**, according to [`benchmark-ips`](https://github.com/evanphx/benchmark-ips) (2.14.0).
|
116
|
+
|
117
|
+
Results using Ruby 3.4.3:
|
118
|
+
|
119
|
+
|Method arguments|`alt_memery` (2.1.0)|`dry-core`\* (1.1.0)|`memery` (1.7.0)|`memoist3` (1.0.0)|`short_circu_it` (0.29.3)|
|
120
|
+
|--|--|--|--|--|--|
|
121
|
+
|`()` (none)|12.27x|0.58x|3.36x|2.79x|18.43x|
|
122
|
+
|`(a)`|9.50x|0.99x|3.79x|14.93x|14.16x|
|
123
|
+
|`(a, b)`|7.51x|0.83x|2.96x|11.84x|11.19x|
|
124
|
+
|`(a:)`|14.32x|1.00x|6.46x|19.60x|12.81x|
|
125
|
+
|`(a:, b:)`|12.24x|0.86x|5.56x|20.89x|10.78x|
|
126
|
+
|`(a, b:)`|11.98x|0.85x|5.42x|16.25x|10.76x|
|
127
|
+
|`(a, *args)`|1.91x|0.66x|0.75x|2.96x|2.80x|
|
128
|
+
|`(a:, **kwargs)`|2.73x|0.71x|1.22x|4.69x|2.41x|
|
129
|
+
|`(a, *args, b:, **kwargs)`|1.76x|0.63x|0.84x|3.00x|1.52x|
|
130
|
+
|
131
|
+
\* `dry-core`
|
132
132
|
[may cause incorrect behavior caused by hash collisions](https://github.com/dry-rb/dry-core/issues/63).
|
133
133
|
|
134
|
-
Results using Ruby 2.7.8 (because these gems raise errors in Ruby 3.x):
|
135
|
-
|
136
|
-
|Method arguments|`DDMemoize` (1.0.0)|`Memoist` (0.16.2)|`Memoized` (1.1.1)|`Memoizer` (1.0.3)|
|
137
|
-
|--|--|--|--|--|
|
138
|
-
|`()` (none)|22.57x|2.27x|23.46x|2.63x|
|
139
|
-
|`(a)`|20.96x|14.29x|20.54x|11.97x|
|
140
|
-
|`(a, b)`|18.22x|13.21x|17.76x|11.34x|
|
141
|
-
|`(a:)`|30.66x|23.52x|25.37x|21.61x|
|
142
|
-
|`(a:, b:)`|27.31x|21.98x|23.02x|20.31x|
|
143
|
-
|`(a, b:)`|26.21x|20.85x|21.57x|19.20x|
|
144
|
-
|`(a, *args)`|3.06x|2.23x|3.10x|1.92x|
|
145
|
-
|`(a:, **kwargs)`|2.67x|2.18x|2.39x|2.02x|
|
146
|
-
|`(a, *args, b:, **kwargs)`|2.14x|1.80x|1.89x|1.70x|
|
147
|
-
|
148
134
|
You can run benchmarks yourself with:
|
149
135
|
|
150
136
|
```bash
|
@@ -153,7 +139,8 @@ $ bundle install
|
|
153
139
|
$ bundle exec ruby benchmarks.rb
|
154
140
|
```
|
155
141
|
|
156
|
-
If your results differ from what's posted here,
|
142
|
+
If your results differ from what's posted here, or if there's another gem we
|
143
|
+
should be benchmarking,
|
157
144
|
[let us know](https://github.com/panorama-ed/memo_wise/issues/new)!
|
158
145
|
|
159
146
|
## Thread Safety
|
@@ -195,7 +182,7 @@ To edit documentation locally and see it rendered in your browser
|
|
195
182
|
using hot reloading, run:
|
196
183
|
|
197
184
|
```bash
|
198
|
-
bundle exec yard server --reload
|
185
|
+
BUNDLE_WITH=docs bundle exec yard server --reload
|
199
186
|
```
|
200
187
|
|
201
188
|
You can then open your web browser to `http://127.0.0.1:8808/`. As you
|
@@ -299,7 +286,6 @@ Then carry out these steps:
|
|
299
286
|
|
300
287
|
**Project enhancements:** none
|
301
288
|
```
|
302
|
-
- Commit with title `Update CHANGELOG.md for x.y.z`
|
303
289
|
|
304
290
|
2. Update `lib/memo_wise/version.rb`
|
305
291
|
- Replace with upcoming version _x.y.z_
|
@@ -188,7 +188,7 @@ module MemoWise
|
|
188
188
|
# The class to which we are prepending MemoWise to provide memoization.
|
189
189
|
# @return [Class] where we look for method definitions
|
190
190
|
def self.target_class(target)
|
191
|
-
if target.instance_of?(Class)
|
191
|
+
if target.instance_of?(Class) || target.instance_of?(Module)
|
192
192
|
# A class's methods are defined in its singleton class
|
193
193
|
target.singleton_class
|
194
194
|
else
|
data/lib/memo_wise/version.rb
CHANGED
data/lib/memo_wise.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require "set" # Ruby < 3.2 does not load `set` by default.
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
require_relative "memo_wise/internal_api"
|
6
|
+
require_relative "memo_wise/version"
|
7
7
|
|
8
8
|
# MemoWise is the wise choice for memoization in Ruby.
|
9
9
|
#
|
@@ -41,37 +41,8 @@ module MemoWise
|
|
41
41
|
# example, classes created by the
|
42
42
|
# [Values](https://github.com/tcrayford/Values)
|
43
43
|
# [gem](https://rubygems.org/gems/values).
|
44
|
-
#
|
45
|
-
# To support syntax differences with keyword and positional arguments starting
|
46
|
-
# with ruby 2.7, we have to set up the initializer with some slightly
|
47
|
-
# different syntax for the different versions. This variance in syntax is not
|
48
|
-
# included in coverage reports since the branch chosen will never differ
|
49
|
-
# within a single ruby version. This means it is impossible for us to get
|
50
|
-
# 100% coverage of this line within a single CI run.
|
51
|
-
#
|
52
|
-
# See
|
53
|
-
# [this article](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/)
|
54
|
-
# for more information.
|
55
|
-
#
|
56
|
-
# :nocov:
|
57
|
-
all_args = RUBY_VERSION < "2.7" ? "*" : "..."
|
58
|
-
# :nocov:
|
59
44
|
class_eval <<~HEREDOC, __FILE__, __LINE__ + 1
|
60
|
-
|
61
|
-
#
|
62
|
-
# def initialize(...)
|
63
|
-
# MemoWise::InternalAPI.create_memo_wise_state!(self)
|
64
|
-
# super
|
65
|
-
# end
|
66
|
-
#
|
67
|
-
# On Ruby 2.6 or lower:
|
68
|
-
#
|
69
|
-
# def initialize(*)
|
70
|
-
# MemoWise::InternalAPI.create_memo_wise_state!(self)
|
71
|
-
# super
|
72
|
-
# end
|
73
|
-
|
74
|
-
def initialize(#{all_args})
|
45
|
+
def initialize(...)
|
75
46
|
MemoWise::InternalAPI.create_memo_wise_state!(self)
|
76
47
|
super
|
77
48
|
end
|
@@ -93,6 +64,13 @@ module MemoWise
|
|
93
64
|
end
|
94
65
|
private_constant(:CreateMemoWiseStateOnInherited)
|
95
66
|
|
67
|
+
module CreateMemoWiseStateOnIncluded
|
68
|
+
def included(base)
|
69
|
+
base.prepend(MemoWise)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
private_constant(:CreateMemoWiseStateOnIncluded)
|
73
|
+
|
96
74
|
# @private
|
97
75
|
#
|
98
76
|
# Private setup method, called automatically by `prepend MemoWise` in a class.
|
@@ -154,10 +132,7 @@ module MemoWise
|
|
154
132
|
klass.singleton_class.prepend(CreateMemoWiseStateOnExtended)
|
155
133
|
end
|
156
134
|
when Hash
|
157
|
-
unless method_name_or_hash.keys == [:self]
|
158
|
-
raise ArgumentError,
|
159
|
-
"`:self` is the only key allowed in memo_wise"
|
160
|
-
end
|
135
|
+
raise ArgumentError, "`:self` is the only key allowed in memo_wise" unless method_name_or_hash.keys == [:self]
|
161
136
|
|
162
137
|
method_name = method_name_or_hash[:self]
|
163
138
|
|
@@ -175,6 +150,8 @@ module MemoWise
|
|
175
150
|
if klass.is_a?(Class) && !klass.singleton_class?
|
176
151
|
klass.singleton_class.prepend(CreateMemoWiseStateOnInherited)
|
177
152
|
else
|
153
|
+
klass.singleton_class.prepend(CreateMemoWiseStateOnIncluded) if klass.is_a?(Module) && !klass.singleton_class?
|
154
|
+
|
178
155
|
klass.prepend(CreateMemoWiseStateOnInherited)
|
179
156
|
end
|
180
157
|
|
metadata
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memo_wise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Panorama Education
|
8
8
|
- Jacob Evelyn
|
9
9
|
- Jemma Issroff
|
10
10
|
- Marc Siegel
|
11
|
-
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
15
14
|
dependencies: []
|
16
|
-
description:
|
17
15
|
email:
|
18
16
|
- engineering@panoramaed.com
|
19
17
|
- jacobevelyn@gmail.com
|
@@ -36,7 +34,6 @@ metadata:
|
|
36
34
|
rubygems_mfa_required: 'true'
|
37
35
|
changelog_uri: https://github.com/panorama-ed/memo_wise/blob/main/CHANGELOG.md
|
38
36
|
source_code_uri: https://github.com/panorama-ed/memo_wise
|
39
|
-
post_install_message:
|
40
37
|
rdoc_options: []
|
41
38
|
require_paths:
|
42
39
|
- lib
|
@@ -44,15 +41,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
41
|
requirements:
|
45
42
|
- - ">="
|
46
43
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
44
|
+
version: 3.1.0
|
48
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
46
|
requirements:
|
50
47
|
- - ">="
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: '0'
|
53
50
|
requirements: []
|
54
|
-
rubygems_version: 3.
|
55
|
-
signing_key:
|
51
|
+
rubygems_version: 3.6.7
|
56
52
|
specification_version: 4
|
57
53
|
summary: The wise choice for Ruby memoization
|
58
54
|
test_files: []
|