memo_wise 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07ea8ff9f5bbe537cceded02e2379f22145b2ca0023ee745cca77d503875884c
4
- data.tar.gz: 43a1683798319eccc7fb0781519b84575c1096d938f7076b6dc5747370e5849e
3
+ metadata.gz: bcbf16d5dbb7dcebd8181d89b17e550f493afb08e8c3f46c2e56d1c6d224a71d
4
+ data.tar.gz: bff1adee597c5a29fea1223604733a23b5b10e800e217d7b7e73d715b0c221cf
5
5
  SHA512:
6
- metadata.gz: 0d40f55683a9dd45e81ffc16ac0c4678294cf0d0668c18e676717b9146709b538a7ed9c58b6b3d75f78e262e71f27267228ee2271e47994674d32967f7ff167f
7
- data.tar.gz: 92ad0acb0712b0cb122c77a0a8901003b79d73253adc1db8d27fedb42ec07ba49d4706ccf4be8b44a79d18856be909235ec4b4673bf576db69d7dc4643e23770
6
+ metadata.gz: 477aac5ab8f66cf7287ff976a484d8ba06447587f997e612fccee952d003b688c79d9d934f28d730443d7c23fdeca4d90ec0adb79f6dea9f5bdc11b0b9d3820e
7
+ data.tar.gz: 99175b330fd6235bab7967545177298d2ccaa3fbab2c2d860aaa7f686f48e581ec7d5ef2e036a760759e48bec8618b24b1784227e9eb762052dac4649f102813
@@ -17,7 +17,7 @@
17
17
  - name: 'Checkout Repository'
18
18
  uses: actions/checkout@v4
19
19
  - name: 'Dependency Review'
20
- uses: actions/dependency-review-action@v3
20
+ uses: actions/dependency-review-action@v4
21
21
  with:
22
22
  # Possible values: "critical", "high", "moderate", "low"
23
23
  fail-on-severity: high
@@ -14,7 +14,7 @@ jobs:
14
14
  matrix:
15
15
  # Due to https://github.com/actions/runner/issues/849, we have to use
16
16
  # quotes for '3.0' -- without quotes, CI sees '3' and runs the latest.
17
- ruby: [2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby, truffleruby-head]
17
+ ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby, truffleruby-head]
18
18
  runs-on: ubuntu-latest
19
19
  steps:
20
20
  - uses: actions/checkout@v4
@@ -23,8 +23,8 @@ jobs:
23
23
  # * https://github.com/ruby/setup-ruby#bundle-config
24
24
  - name: Set bundler environment variables
25
25
  run: |
26
- echo "BUNDLE_WITHOUT=checks:docs" >> $GITHUB_ENV
27
- if: matrix.ruby != 3.2
26
+ echo "BUNDLE_WITH=checks:docs" >> $GITHUB_ENV
27
+ if: matrix.ruby == 3.2
28
28
 
29
29
  # Use 'bundler-cache: true' instead of actions/cache as advised:
30
30
  # * https://github.com/actions/cache/blob/main/examples.md#ruby---bundler
@@ -35,10 +35,11 @@ jobs:
35
35
 
36
36
  - run: bundle exec rspec
37
37
 
38
- - uses: codecov/codecov-action@v3
38
+ - uses: codecov/codecov-action@v4
39
39
  with:
40
40
  files: ./coverage/coverage.xml
41
41
  fail_ci_if_error: true # optional (default = false)
42
+ token: ${{ secrets.CODECOV_TOKEN }}
42
43
  verbose: true # optional (default = false)
43
44
  if: matrix.ruby == 3.2
44
45
 
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -5,13 +5,28 @@ 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.0...HEAD)
8
+ ## [Unreleased](https://github.com/panorama-ed/memo_wise/compare/v1.9.0...HEAD)
9
9
 
10
- **Gem enhancements:** none
10
+ **Gem enhancements:**
11
11
 
12
12
  _No breaking changes!_
13
13
 
14
- **Project enhancements:** none
14
+ **Project enhancements:**
15
+
16
+ ## [v1.9.0](https://github.com/panorama-ed/memo_wise/compare/v1.8.0...v1.9.0)
17
+
18
+ **Gem enhancements:**
19
+
20
+ - Fixed a bug that overwrote existing self.extended method definitions. [[#324]](https://github.com/panorama-ed/memo_wise/pull/314)
21
+ - Fixed a bug that overwrote existing self.inherited method definitions. [[#325]](https://github.com/panorama-ed/memo_wise/pull/315)
22
+
23
+ _Breaking changes:_
24
+ - 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)
25
+
26
+ **Project enhancements:**
27
+
28
+ - Fixed `bundle exec yard server --reload` and related documentation [[#333]](https://github.com/panorama-ed/memo_wise/pull/333)
29
+ - 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)
15
30
 
16
31
  ## [v1.8.0](https://github.com/panorama-ed/memo_wise/compare/v1.7.0...v1.8.0) - 2023-10-25
17
32
 
data/Gemfile CHANGED
@@ -7,12 +7,12 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
7
7
  gemspec
8
8
 
9
9
  group :test do
10
- gem "rspec", "~> 3.12"
10
+ gem "rspec", "~> 3.13"
11
11
  gem "values", "~> 1"
12
12
  end
13
13
 
14
14
  # Excluded from CI except on latest MRI Ruby, to reduce compatibility burden
15
- group :checks do
15
+ group :checks, optional: true do
16
16
  gem "panolint-ruby", github: "panorama-ed/panolint-ruby", branch: "main"
17
17
 
18
18
  # Simplecov to generate coverage info
@@ -23,9 +23,10 @@ group :checks do
23
23
  end
24
24
 
25
25
  # Excluded from CI except on latest MRI Ruby, to reduce compatibility burden
26
- group :docs do
26
+ group :docs, optional: true do
27
27
  gem "dokaz", "~> 0.0.5"
28
28
  gem "redcarpet", "~> 3.6"
29
+ gem "webrick", "~> 1.8"
29
30
  gem "yard", "~> 0.9"
30
31
  gem "yard-doctest", "~> 0.1"
31
32
  end
data/Gemfile.lock CHANGED
@@ -11,14 +11,14 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- memo_wise (1.8.0)
14
+ memo_wise (1.9.0)
15
15
 
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
19
  ansi (1.5.0)
20
20
  ast (2.4.2)
21
- diff-lcs (1.5.0)
21
+ diff-lcs (1.5.1)
22
22
  docile (1.4.0)
23
23
  dokaz (0.0.5)
24
24
  ansi
@@ -30,24 +30,25 @@ GEM
30
30
  parser (3.2.2.1)
31
31
  ast (~> 2.4.1)
32
32
  rainbow (3.1.1)
33
- rake (13.0.6)
33
+ rake (13.1.0)
34
34
  redcarpet (3.6.0)
35
35
  regexp_parser (2.8.0)
36
- rexml (3.2.5)
36
+ rexml (3.2.8)
37
+ strscan (>= 3.0.9)
37
38
  rouge (4.1.0)
38
- rspec (3.12.0)
39
- rspec-core (~> 3.12.0)
40
- rspec-expectations (~> 3.12.0)
41
- rspec-mocks (~> 3.12.0)
42
- rspec-core (3.12.1)
43
- rspec-support (~> 3.12.0)
44
- rspec-expectations (3.12.2)
39
+ rspec (3.13.0)
40
+ rspec-core (~> 3.13.0)
41
+ rspec-expectations (~> 3.13.0)
42
+ rspec-mocks (~> 3.13.0)
43
+ rspec-core (3.13.0)
44
+ rspec-support (~> 3.13.0)
45
+ rspec-expectations (3.13.0)
45
46
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.12.0)
47
- rspec-mocks (3.12.3)
47
+ rspec-support (~> 3.13.0)
48
+ rspec-mocks (3.13.0)
48
49
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.12.0)
50
- rspec-support (3.12.0)
50
+ rspec-support (~> 3.13.0)
51
+ rspec-support (3.13.1)
51
52
  rubocop (1.51.0)
52
53
  json (~> 2.3)
53
54
  parallel (~> 1.10)
@@ -82,9 +83,11 @@ GEM
82
83
  simplecov-html (0.12.3)
83
84
  simplecov_json_formatter (0.1.4)
84
85
  slop (3.6.0)
86
+ strscan (3.1.0)
85
87
  unicode-display_width (2.4.2)
86
88
  values (1.8.0)
87
- yard (0.9.34)
89
+ webrick (1.8.1)
90
+ yard (0.9.36)
88
91
  yard-doctest (0.1.17)
89
92
  minitest
90
93
  yard
@@ -98,10 +101,11 @@ DEPENDENCIES
98
101
  panolint-ruby!
99
102
  rake
100
103
  redcarpet (~> 3.6)
101
- rspec (~> 3.12)
104
+ rspec (~> 3.13)
102
105
  simplecov
103
106
  simplecov-cobertura
104
107
  values (~> 1)
108
+ webrick (~> 1.8)
105
109
  yard (~> 0.9)
106
110
  yard-doctest (~> 0.1)
107
111
 
data/README.md CHANGED
@@ -118,15 +118,15 @@ Results using Ruby 3.2.2:
118
118
 
119
119
  |Method arguments|`Dry::Core`\* (1.0.1)|`Memery` (1.5.0)|
120
120
  |--|--|--|
121
- |`()` (none)|0.54x|3.62x|
122
- |`(a)`|1.54x|7.74x|
123
- |`(a, b)`|1.29x|5.58x|
124
- |`(a:)`|1.55x|12.37x|
125
- |`(a:, b:)`|1.15x|8.76x|
126
- |`(a, b:)`|1.15x|8.75x|
127
- |`(a, *args)`|0.84x|1.54x|
128
- |`(a:, **kwargs)`|0.79x|2.13x|
129
- |`(a, *args, b:, **kwargs)`|0.69x|1.38x|
121
+ |`()` (none)|0.66x|3.54x|
122
+ |`(a)`|1.48x|8.49x|
123
+ |`(a, b)`|1.18x|6.52x|
124
+ |`(a:)`|1.53x|13.57x|
125
+ |`(a:, b:)`|1.27x|10.56x|
126
+ |`(a, b:)`|1.26x|10.44x|
127
+ |`(a, *args)`|0.78x|1.60x|
128
+ |`(a:, **kwargs)`|0.77x|2.12x|
129
+ |`(a, *args, b:, **kwargs)`|0.69x|1.40x|
130
130
 
131
131
  \* `Dry::Core`
132
132
  [may cause incorrect behavior caused by hash collisions](https://github.com/dry-rb/dry-core/issues/63).
@@ -135,15 +135,15 @@ Results using Ruby 2.7.8 (because these gems raise errors in Ruby 3.x):
135
135
 
136
136
  |Method arguments|`DDMemoize` (1.0.0)|`Memoist` (0.16.2)|`Memoized` (1.1.1)|`Memoizer` (1.0.3)|
137
137
  |--|--|--|--|--|
138
- |`()` (none)|24.22x|2.42x|26.43x|2.70x|
139
- |`(a)`|22.08x|15.19x|22.03x|13.67x|
140
- |`(a, b)`|19.12x|14.01x|18.60x|12.80x|
141
- |`(a:)`|30.21x|24.29x|26.43x|23.11x|
142
- |`(a:, b:)`|27.73x|22.97x|25.11x|21.89x|
143
- |`(a, b:)`|26.87x|22.76x|23.71x|21.26x|
144
- |`(a, *args)`|3.15x|2.30x|3.18x|2.11x|
145
- |`(a:, **kwargs)`|2.89x|2.40x|2.69x|2.28x|
146
- |`(a, *args, b:, **kwargs)`|2.12x|1.82x|1.96x|1.74x|
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
147
 
148
148
  You can run benchmarks yourself with:
149
149
 
@@ -176,18 +176,42 @@ versions:
176
176
 
177
177
  ## Documentation
178
178
 
179
- ### Documentation is Automatically Generated
179
+ ### Automatically Generated Docs
180
180
 
181
181
  We maintain API documentation using [YARD](https://yardoc.org/), which is
182
182
  published automatically at
183
- [RubyDoc.info](https://rubydoc.info/gems/memo_wise). To
184
- edit documentation locally and see it rendered in your browser, run:
183
+ [RubyDoc.info](https://rubydoc.info/gems/memo_wise).
184
+
185
+ To generate documentation locally or run documentation tests,
186
+ first install the `docs` dependencies (e.g. `yard`) as follows:
185
187
 
186
188
  ```bash
187
- bundle exec yard server
189
+ BUNDLE_WITH=docs bundle install
188
190
  ```
189
191
 
190
- ### Documentation Examples are Automatically Tested
192
+ ### Hot Reloading Docs Locally
193
+
194
+ To edit documentation locally and see it rendered in your browser
195
+ using hot reloading, run:
196
+
197
+ ```bash
198
+ bundle exec yard server --reload
199
+ ```
200
+
201
+ You can then open your web browser to `http://127.0.0.1:8808/`. As you
202
+ edit documentation locally, reload your browser to see it generated.
203
+
204
+ ### Static Generate Docs Locally
205
+
206
+ To statically generate documentation locally, run:
207
+
208
+ ```bash
209
+ bundle exec yard
210
+ ```
211
+
212
+ You can then open the generated documentation at `docs/index.html`.
213
+
214
+ ### Test all Docs Examples
191
215
 
192
216
  We use [yard-doctest](https://github.com/p0deje/yard-doctest) to test all
193
217
  code examples in our YARD documentation. To run `doctest` locally:
@@ -204,7 +228,7 @@ locally:
204
228
  bundle exec dokaz
205
229
  ```
206
230
 
207
- ### A Note on Testing
231
+ ## A Note on Testing
208
232
 
209
233
  When testing memoized *module* methods, note that some testing setups will
210
234
  reuse the same instance (which `include`s/`extend`s/`prepend`s the module)
@@ -254,12 +278,11 @@ the [code of conduct](https://github.com/panorama-ed/memo_wise/blob/main/CODE_OF
254
278
  ## Releasing
255
279
 
256
280
  To make a new release of `MemoWise` to
257
- [RubyGems](https://rubygems.org/gems/memo_wise), first install the release
281
+ [RubyGems](https://rubygems.org/gems/memo_wise), first install the `release`
258
282
  dependencies (e.g. `rake`) as follows:
259
283
 
260
284
  ```shell
261
- bundle config --local with 'release'
262
- bundle install
285
+ BUNDLE_WITH=release bundle install
263
286
  ```
264
287
 
265
288
  Then carry out these steps:
data/benchmarks/Gemfile CHANGED
@@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
6
6
 
7
7
  ruby ">= 2.7.7"
8
8
 
9
- gem "benchmark-ips", "2.12.0"
9
+ gem "benchmark-ips", "2.13.0"
10
10
 
11
11
  if RUBY_VERSION > "3"
12
12
  gem "dry-core", "1.0.1"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MemoWise
4
- VERSION = "1.8.0"
4
+ VERSION = "1.9.0"
5
5
  end
data/lib/memo_wise.rb CHANGED
@@ -31,12 +31,12 @@ module MemoWise
31
31
  # [calling the original](https://medium.com/@jeremy_96642/ruby-method-auditing-using-module-prepend-4f4e69aacd95)
32
32
  # constructor.
33
33
  #
34
- # - **Q:** Why is [Module#prepend](https://ruby-doc.org/3.2.1/Module.html#method-i-prepend)
34
+ # - **Q:** Why is [Module#prepend](https://ruby-doc.org/3.2.2/Module.html#method-i-prepend)
35
35
  # important here
36
36
  # ([more info](https://medium.com/@leo_hetsch/ruby-modules-include-vs-prepend-vs-extend-f09837a5b073))?
37
37
  # - **A:** To set up *mutable state* inside the instance, even if the original
38
38
  # constructor will then call
39
- # [Object#freeze](https://ruby-doc.org/3.2.1/Object.html#method-i-freeze).
39
+ # [Object#freeze](https://ruby-doc.org/3.2.2/Object.html#method-i-freeze).
40
40
  #
41
41
  # This approach supports memoization on frozen (immutable) objects -- for
42
42
  # example, classes created by the
@@ -78,6 +78,22 @@ module MemoWise
78
78
  end
79
79
  HEREDOC
80
80
 
81
+ module CreateMemoWiseStateOnExtended
82
+ def extended(base)
83
+ MemoWise::InternalAPI.create_memo_wise_state!(base)
84
+ super
85
+ end
86
+ end
87
+ private_constant(:CreateMemoWiseStateOnExtended)
88
+
89
+ module CreateMemoWiseStateOnInherited
90
+ def inherited(subclass)
91
+ MemoWise::InternalAPI.create_memo_wise_state!(subclass)
92
+ super
93
+ end
94
+ end
95
+ private_constant(:CreateMemoWiseStateOnInherited)
96
+
81
97
  # @private
82
98
  #
83
99
  # Private setup method, called automatically by `prepend MemoWise` in a class.
@@ -85,7 +101,7 @@ module MemoWise
85
101
  # @param target [Class]
86
102
  # The `Class` into to prepend the MemoWise methods e.g. `memo_wise`
87
103
  #
88
- # @see https://ruby-doc.org/3.2.1/Module.html#method-i-prepend
104
+ # @see https://ruby-doc.org/3.2.2/Module.html#method-i-prepend
89
105
  #
90
106
  # @example
91
107
  # class Example
@@ -100,7 +116,7 @@ module MemoWise
100
116
  #
101
117
  # This is necessary in addition to the `#initialize` method definition
102
118
  # above because
103
- # [`Class#allocate`](https://ruby-doc.org/3.2.1/Class.html#method-i-allocate)
119
+ # [`Class#allocate`](https://ruby-doc.org/3.2.2/Class.html#method-i-allocate)
104
120
  # bypasses `#initialize`, and when it's used (e.g.,
105
121
  # [in ActiveRecord](https://github.com/rails/rails/blob/a395c3a6af1e079740e7a28994d77c8baadd2a9d/activerecord/lib/active_record/persistence.rb#L411))
106
122
  # we still need to be able to access MemoWise's instance variable. Despite
@@ -136,9 +152,7 @@ module MemoWise
136
152
  #
137
153
  # On method call `@_memo_wise` would still be `nil`
138
154
  # causing error when fetching cache from `@_memo_wise`
139
- def klass.extended(base)
140
- MemoWise::InternalAPI.create_memo_wise_state!(base)
141
- end
155
+ klass.singleton_class.prepend(CreateMemoWiseStateOnExtended)
142
156
  end
143
157
  when Hash
144
158
  unless method_name_or_hash.keys == [:self]
@@ -159,12 +173,11 @@ module MemoWise
159
173
 
160
174
  # This ensures that a memoized method defined on a parent class can
161
175
  # still be used in a child class.
162
- klass.module_eval <<~HEREDOC, __FILE__, __LINE__ + 1
163
- def inherited(subclass)
164
- super
165
- MemoWise::InternalAPI.create_memo_wise_state!(subclass)
166
- end
167
- HEREDOC
176
+ if klass.is_a?(Class) && !klass.singleton_class?
177
+ klass.singleton_class.prepend(CreateMemoWiseStateOnInherited)
178
+ else
179
+ klass.prepend(CreateMemoWiseStateOnInherited)
180
+ end
168
181
 
169
182
  raise ArgumentError, "#{method_name.inspect} must be a Symbol" unless method_name.is_a?(Symbol)
170
183
 
@@ -255,7 +268,7 @@ module MemoWise
255
268
  )
256
269
  end
257
270
 
258
- # Override [Module#instance_method](https://ruby-doc.org/3.2.1/Module.html#method-i-instance_method)
271
+ # Override [Module#instance_method](https://ruby-doc.org/3.2.2/Module.html#method-i-instance_method)
259
272
  # to proxy the original `UnboundMethod#parameters` results. We want the
260
273
  # parameters to reflect the original method in order to support callers
261
274
  # who want to use Ruby reflection to process the method parameters,
data/memo_wise.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  "marc@usainnov.com",
24
24
  ]
25
25
 
26
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
26
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
27
27
 
28
28
  # Specify which files should be added to the gem when it is released.
29
29
  # The `git ls-files -z` loads the files in the RubyGem that have been added
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.8.0
4
+ version: 1.9.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: 2023-10-30 00:00:00.000000000 Z
14
+ date: 2024-06-04 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description:
17
17
  email:
@@ -64,14 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 2.4.0
67
+ version: 2.5.0
68
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.4.6
74
+ rubygems_version: 3.4.10
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: The wise choice for Ruby memoization