memo_wise 1.5.0 → 1.6.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/main.yml +6 -6
- data/.ruby-version +1 -1
- data/CHANGELOG.md +20 -4
- data/Gemfile.lock +9 -7
- data/LICENSE.txt +1 -1
- data/README.md +11 -11
- data/benchmarks/benchmarks.rb +1 -1
- data/lib/memo_wise/version.rb +1 -1
- data/lib/memo_wise.rb +13 -15
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aee2439aaa86140659e102e2269e4d773e34a933e73ff604b449918948b9cd29
|
|
4
|
+
data.tar.gz: bff512646d578b936d45267408be8681479c7316fa7ae16c683fc3b47261577a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a820daf7cbc735f0bc586cc7e2b73c507f01592f8666ed3837b83584537466b4d06aee3202aa7c31b4545558f3e24a45ccc4063e315479fbbc4f3ece1606f7d8
|
|
7
|
+
data.tar.gz: 6349b73c2cec18df74259b79dceef15f7f9303001deffb94146c00abcc5e9f0d6be9ab82c0aa0adab0dc528dd75de4e5c8450df389f64c88c24bea50dead15ce
|
data/.github/workflows/main.yml
CHANGED
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
strategy:
|
|
13
13
|
fail-fast: false
|
|
14
14
|
matrix:
|
|
15
|
-
ruby: [jruby, 2.4, 2.5, 2.6, 2.7, 3.0, truffleruby-head]
|
|
15
|
+
ruby: [jruby, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, truffleruby-head]
|
|
16
16
|
runs-on: ubuntu-latest
|
|
17
17
|
steps:
|
|
18
18
|
- uses: actions/checkout@v2
|
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
- name: Set bundler environment variables
|
|
23
23
|
run: |
|
|
24
24
|
echo "BUNDLE_WITHOUT=checks:docs" >> $GITHUB_ENV
|
|
25
|
-
if: matrix.ruby != 3.
|
|
25
|
+
if: matrix.ruby != 3.1
|
|
26
26
|
|
|
27
27
|
# Use 'bundler-cache: true' instead of actions/cache as advised:
|
|
28
28
|
# * https://github.com/actions/cache/blob/main/examples.md#ruby---bundler
|
|
@@ -34,15 +34,15 @@ jobs:
|
|
|
34
34
|
- run: bundle exec rspec
|
|
35
35
|
|
|
36
36
|
- run: bundle exec rubocop
|
|
37
|
-
if: matrix.ruby == 3.
|
|
37
|
+
if: matrix.ruby == 3.1
|
|
38
38
|
|
|
39
39
|
- run: |
|
|
40
40
|
bundle exec yard doctest
|
|
41
41
|
bundle exec dokaz
|
|
42
|
-
if: matrix.ruby == 3.
|
|
42
|
+
if: matrix.ruby == 3.1
|
|
43
43
|
|
|
44
|
-
- name: Run benchmarks on Ruby 2.7 or 3.
|
|
44
|
+
- name: Run benchmarks on Ruby 2.7 or 3.1
|
|
45
45
|
run: |
|
|
46
46
|
BUNDLE_GEMFILE=benchmarks/Gemfile bundle install --jobs 4 --retry 3
|
|
47
47
|
BUNDLE_GEMFILE=benchmarks/Gemfile bundle exec ruby benchmarks/benchmarks.rb
|
|
48
|
-
if: matrix.ruby == '2.7' || matrix.ruby == '3.
|
|
48
|
+
if: matrix.ruby == '2.7' || matrix.ruby == '3.1'
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.1.0
|
data/CHANGELOG.md
CHANGED
|
@@ -7,13 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Nothing yet!
|
|
11
|
+
|
|
12
|
+
## [1.6.0] - 2022-01-24
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Fixed a bug relating to inheritance of classes which include module which
|
|
17
|
+
prepends MemoWise ([#265](https://github.com/panorama-ed/memo_wise/pull/265))
|
|
18
|
+
|
|
19
|
+
### Updated
|
|
20
|
+
|
|
21
|
+
- Update official test coverage to support Ruby 3.1
|
|
11
22
|
|
|
12
23
|
## [1.5.0] - 2021-12-17
|
|
13
24
|
|
|
14
|
-
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- Remove optimization for truthy results to fix thread safety race condition
|
|
28
|
+
bugs
|
|
15
29
|
- Switch to a simpler internal data structure to fix several classes of bugs
|
|
16
|
-
that the previous few versions were unable to
|
|
30
|
+
related to inheritance that the previous few versions were unable to
|
|
31
|
+
sufficiently address
|
|
17
32
|
|
|
18
33
|
## [1.4.0] - 2021-12-10
|
|
19
34
|
|
|
@@ -116,7 +131,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
116
131
|
- Panolint
|
|
117
132
|
- Dependabot setup
|
|
118
133
|
|
|
119
|
-
[Unreleased]: https://github.com/panorama-ed/memo_wise/compare/v1.
|
|
134
|
+
[Unreleased]: https://github.com/panorama-ed/memo_wise/compare/v1.6.0...HEAD
|
|
135
|
+
[1.6.0]: https://github.com/panorama-ed/memo_wise/compare/v1.5.0...v1.6.0
|
|
120
136
|
[1.5.0]: https://github.com/panorama-ed/memo_wise/compare/v1.4.0...v1.5.0
|
|
121
137
|
[1.4.0]: https://github.com/panorama-ed/memo_wise/compare/v1.3.0...v1.4.0
|
|
122
138
|
[1.3.0]: https://github.com/panorama-ed/memo_wise/compare/v1.2.0...v1.3.0
|
data/Gemfile.lock
CHANGED
|
@@ -14,7 +14,7 @@ GIT
|
|
|
14
14
|
PATH
|
|
15
15
|
remote: .
|
|
16
16
|
specs:
|
|
17
|
-
memo_wise (1.
|
|
17
|
+
memo_wise (1.6.0)
|
|
18
18
|
|
|
19
19
|
GEM
|
|
20
20
|
remote: https://rubygems.org/
|
|
@@ -41,13 +41,13 @@ GEM
|
|
|
41
41
|
concurrent-ruby (~> 1.0)
|
|
42
42
|
minitest (5.14.4)
|
|
43
43
|
parallel (1.21.0)
|
|
44
|
-
parser (3.0.
|
|
44
|
+
parser (3.1.0.0)
|
|
45
45
|
ast (~> 2.4.1)
|
|
46
46
|
rack (2.2.3)
|
|
47
47
|
rainbow (3.0.0)
|
|
48
48
|
rake (13.0.6)
|
|
49
49
|
redcarpet (3.5.1)
|
|
50
|
-
regexp_parser (2.
|
|
50
|
+
regexp_parser (2.2.0)
|
|
51
51
|
rexml (3.2.5)
|
|
52
52
|
rouge (3.26.0)
|
|
53
53
|
rspec (3.10.0)
|
|
@@ -63,16 +63,16 @@ GEM
|
|
|
63
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
64
64
|
rspec-support (~> 3.10.0)
|
|
65
65
|
rspec-support (3.10.0)
|
|
66
|
-
rubocop (1.
|
|
66
|
+
rubocop (1.24.1)
|
|
67
67
|
parallel (~> 1.10)
|
|
68
68
|
parser (>= 3.0.0.0)
|
|
69
69
|
rainbow (>= 2.2.2, < 4.0)
|
|
70
70
|
regexp_parser (>= 1.8, < 3.0)
|
|
71
71
|
rexml
|
|
72
|
-
rubocop-ast (>= 1.
|
|
72
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
|
73
73
|
ruby-progressbar (~> 1.7)
|
|
74
74
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
75
|
-
rubocop-ast (1.
|
|
75
|
+
rubocop-ast (1.15.1)
|
|
76
76
|
parser (>= 3.0.1.1)
|
|
77
77
|
rubocop-performance (1.12.0)
|
|
78
78
|
rubocop (>= 1.7.0, < 2.0)
|
|
@@ -95,7 +95,9 @@ GEM
|
|
|
95
95
|
concurrent-ruby (~> 1.0)
|
|
96
96
|
unicode-display_width (2.1.0)
|
|
97
97
|
values (1.8.0)
|
|
98
|
-
|
|
98
|
+
webrick (1.7.0)
|
|
99
|
+
yard (0.9.27)
|
|
100
|
+
webrick (~> 1.7.0)
|
|
99
101
|
yard-doctest (0.1.17)
|
|
100
102
|
minitest
|
|
101
103
|
yard
|
data/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2020-
|
|
3
|
+
Copyright (c) 2020-2022 Panorama Education
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
|
@@ -115,19 +115,19 @@ For more usage details, see our detailed [documentation](#documentation).
|
|
|
115
115
|
|
|
116
116
|
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.9.2).
|
|
117
117
|
|
|
118
|
-
Results using Ruby 3.0
|
|
118
|
+
Results using Ruby 3.1.0:
|
|
119
119
|
|
|
120
|
-
|Method arguments|`Dry::Core
|
|
120
|
+
|Method arguments|`Dry::Core` (0.7.1)|`Memery` (1.4.0)|
|
|
121
121
|
|--|--|--|
|
|
122
|
-
|`()` (none)|1.
|
|
123
|
-
|`(a)`|1.
|
|
124
|
-
|`(a, b)`|0.
|
|
125
|
-
|`(a:)`|1.
|
|
126
|
-
|`(a:, b:)`|0.
|
|
127
|
-
|`(a, b:)`|0.
|
|
128
|
-
|`(a, *args)`|0.83x|1.
|
|
129
|
-
|`(a:, **kwargs)`|0.
|
|
130
|
-
|`(a, *args, b:, **kwargs)`|0.
|
|
122
|
+
|`()` (none)|1.09x|11.80x|
|
|
123
|
+
|`(a)`|1.64x|9.74x|
|
|
124
|
+
|`(a, b)`|0.34x|2.00x|
|
|
125
|
+
|`(a:)`|1.49x|18.84x|
|
|
126
|
+
|`(a:, b:)`|0.35x|4.26x|
|
|
127
|
+
|`(a, b:)`|0.35x|4.18x|
|
|
128
|
+
|`(a, *args)`|0.83x|1.89x|
|
|
129
|
+
|`(a:, **kwargs)`|0.84x|3.30x|
|
|
130
|
+
|`(a, *args, b:, **kwargs)`|0.54x|1.47x|
|
|
131
131
|
|
|
132
132
|
\* `Dry::Core`
|
|
133
133
|
[may cause incorrect behavior caused by hash collisions](https://github.com/dry-rb/dry-core/issues/63).
|
data/benchmarks/benchmarks.rb
CHANGED
|
@@ -191,7 +191,7 @@ benchmark_lambdas.map do |benchmark|
|
|
|
191
191
|
json_file = Tempfile.new
|
|
192
192
|
|
|
193
193
|
Benchmark.ips do |x|
|
|
194
|
-
x.config(suite: suite)
|
|
194
|
+
x.config(suite: suite) # rubocop:disable Style/HashSyntax
|
|
195
195
|
BENCHMARK_GEMS.each do |benchmark_gem|
|
|
196
196
|
instance = Object.const_get("#{benchmark_gem.klass}Example").new
|
|
197
197
|
|
data/lib/memo_wise/version.rb
CHANGED
data/lib/memo_wise.rb
CHANGED
|
@@ -30,12 +30,12 @@ module MemoWise
|
|
|
30
30
|
# [calling the original](https://medium.com/@jeremy_96642/ruby-method-auditing-using-module-prepend-4f4e69aacd95)
|
|
31
31
|
# constructor.
|
|
32
32
|
#
|
|
33
|
-
# - **Q:** Why is [Module#prepend](https://ruby-doc.org/core-3.
|
|
33
|
+
# - **Q:** Why is [Module#prepend](https://ruby-doc.org/core-3.1.0/Module.html#method-i-prepend)
|
|
34
34
|
# important here
|
|
35
35
|
# ([more info](https://medium.com/@leo_hetsch/ruby-modules-include-vs-prepend-vs-extend-f09837a5b073))?
|
|
36
36
|
# - **A:** To set up *mutable state* inside the instance, even if the original
|
|
37
37
|
# constructor will then call
|
|
38
|
-
# [Object#freeze](https://ruby-doc.org/core-3.
|
|
38
|
+
# [Object#freeze](https://ruby-doc.org/core-3.1.0/Object.html#method-i-freeze).
|
|
39
39
|
#
|
|
40
40
|
# This approach supports memoization on frozen (immutable) objects -- for
|
|
41
41
|
# example, classes created by the
|
|
@@ -84,7 +84,7 @@ module MemoWise
|
|
|
84
84
|
# @param target [Class]
|
|
85
85
|
# The `Class` into to prepend the MemoWise methods e.g. `memo_wise`
|
|
86
86
|
#
|
|
87
|
-
# @see https://ruby-doc.org/core-3.
|
|
87
|
+
# @see https://ruby-doc.org/core-3.1.0/Module.html#method-i-prepended
|
|
88
88
|
#
|
|
89
89
|
# @example
|
|
90
90
|
# class Example
|
|
@@ -99,7 +99,7 @@ module MemoWise
|
|
|
99
99
|
#
|
|
100
100
|
# This is necessary in addition to the `#initialize` method definition
|
|
101
101
|
# above because
|
|
102
|
-
# [`Class#allocate`](https://ruby-doc.org/core-3.
|
|
102
|
+
# [`Class#allocate`](https://ruby-doc.org/core-3.1.0/Class.html#method-i-allocate)
|
|
103
103
|
# bypasses `#initialize`, and when it's used (e.g.,
|
|
104
104
|
# [in ActiveRecord](https://github.com/rails/rails/blob/a395c3a6af1e079740e7a28994d77c8baadd2a9d/activerecord/lib/active_record/persistence.rb#L411))
|
|
105
105
|
# we still need to be able to access MemoWise's instance variable. Despite
|
|
@@ -156,16 +156,14 @@ module MemoWise
|
|
|
156
156
|
klass = klass.singleton_class
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
HEREDOC
|
|
168
|
-
end
|
|
159
|
+
# This ensures that a memoized method defined on a parent class can
|
|
160
|
+
# still be used in a child class.
|
|
161
|
+
klass.module_eval <<~HEREDOC, __FILE__, __LINE__ + 1
|
|
162
|
+
def inherited(subclass)
|
|
163
|
+
super
|
|
164
|
+
MemoWise::InternalAPI.create_memo_wise_state!(subclass)
|
|
165
|
+
end
|
|
166
|
+
HEREDOC
|
|
169
167
|
|
|
170
168
|
raise ArgumentError, "#{method_name.inspect} must be a Symbol" unless method_name.is_a?(Symbol)
|
|
171
169
|
|
|
@@ -225,7 +223,7 @@ module MemoWise
|
|
|
225
223
|
)
|
|
226
224
|
end
|
|
227
225
|
|
|
228
|
-
# Override [Module#instance_method](https://ruby-doc.org/core-3.
|
|
226
|
+
# Override [Module#instance_method](https://ruby-doc.org/core-3.1.0/Module.html#method-i-instance_method)
|
|
229
227
|
# to proxy the original `UnboundMethod#parameters` results. We want the
|
|
230
228
|
# parameters to reflect the original method in order to support callers
|
|
231
229
|
# who want to use Ruby reflection to process the method parameters,
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: memo_wise
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Panorama Education
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date:
|
|
14
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
|
15
15
|
dependencies: []
|
|
16
16
|
description:
|
|
17
17
|
email:
|
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
70
70
|
- !ruby/object:Gem::Version
|
|
71
71
|
version: '0'
|
|
72
72
|
requirements: []
|
|
73
|
-
rubygems_version: 3.
|
|
73
|
+
rubygems_version: 3.3.3
|
|
74
74
|
signing_key:
|
|
75
75
|
specification_version: 4
|
|
76
76
|
summary: The wise choice for Ruby memoization
|