alt_memery 2.0.0 → 2.1.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: 34a090f8bb82efcf602abd829780cf4ad2999a5a4ef2832c739438e05ffde120
4
- data.tar.gz: 205faeba1520ae7fc16877b00260450db78dbf425904e2140bdc8733dac8e1db
3
+ metadata.gz: 858f46520931a8e2991134fa17882da328cc3ccc5c386e1c304e0edcb9fc3c90
4
+ data.tar.gz: 8613844f42351da6d38d0222307857ebc2b5ccd47458b371fc08ceb48707c1f2
5
5
  SHA512:
6
- metadata.gz: 2d5d4380c23de08c5501e2875debfc1eb64db87e2df49c07dca6a1f71a1fd702a205284971a2266a176bcea6de65be0897bfd35f0a13e43ada5996d6cd2e48d3
7
- data.tar.gz: 6f0f56fc4abb3277d49235a086933228e86ad30917978c6ac994732cb511bfb9537dab641a7b9baf9085f250decd803cc51e234aa089a4d76ceb719d070466f1
6
+ metadata.gz: 8935dc68e268a35e23e7eab016f28fe6e97c6e84bcaba5db7f0195e425b58bc6320d75204f886d5137bfbfc83355476b576c67eddd4d2ce8cb0abd6c8ed84bf2
7
+ data.tar.gz: 147cdaf45147816c6dd708e0fe843a4b952a7dcc3b0a8bcc96627a5defc3361c0bb200a3e1f0afb8634d5ca20dff8f78080fc56f47945929179d311762b8f55d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 2.1.0 (2021-02-10)
6
+
7
+ * Support Ruby 3.
8
+ * Fix error of `#clear_memery_cache!` with specific methods and without existing cache.
9
+ * Improve specs.
10
+ * Update development dependencies.
11
+ * Update documentation.
12
+
5
13
  ## 2.0.0 (2020-07-09)
6
14
 
7
15
  * Rename gem.
data/README.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Alt Memery
2
2
 
3
+ [![Cirrus CI - Base Branch Build Status](https://img.shields.io/cirrus/github/AlexWayfer/alt_memery?style=flat-square)](https://cirrus-ci.com/github/AlexWayfer/alt_memery)
4
+ [![Codecov branch](https://img.shields.io/codecov/c/github/AlexWayfer/alt_memery/master.svg?style=flat-square)](https://codecov.io/gh/AlexWayfer/alt_memery)
5
+ [![Code Climate](https://img.shields.io/codeclimate/maintainability/AlexWayfer/alt_memery.svg?style=flat-square)](https://codeclimate.com/github/AlexWayfer/alt_memery)
6
+ [![Depfu](https://img.shields.io/depfu/AlexWayfer/benchmark_toys?style=flat-square)](https://depfu.com/repos/github/AlexWayfer/alt_memery)
7
+ [![Inline docs](https://inch-ci.org/github/AlexWayfer/alt_memery.svg?branch=master)](https://inch-ci.org/github/AlexWayfer/alt_memery)
8
+ [![license](https://img.shields.io/github/license/AlexWayfer/alt_memery.svg?style=flat-square)](https://github.com/AlexWayfer/alt_memery/blob/master/LICENSE.txt)
9
+ [![Gem](https://img.shields.io/gem/v/alt_memery.svg?style=flat-square)](https://rubygems.org/gems/alt_memery)
10
+
3
11
  Alt Memery allows to memoize methods return values.
4
12
 
5
13
  The native simplest memoization in Ruby looks like this:
@@ -291,6 +299,17 @@ puts C.instance_method(:foo).super_method.owner.memoized_methods[:foo].source
291
299
  # end
292
300
  ```
293
301
 
302
+ ## Development
303
+
304
+ After checking out the repo, run `bundle install` to install dependencies.
305
+
306
+ Then, run `toys rspec` to run the tests.
307
+
308
+ To install this gem onto your local machine, run `toys gem install`.
309
+
310
+ To release a new version, run `toys gem release %version%`.
311
+ See how it works [here](https://github.com/AlexWayfer/gem_toys#release).
312
+
294
313
  ## Contributing
295
314
 
296
315
  Bug reports and pull requests are welcome on GitHub at <https://github.com/AlexWayfer/alt_memery>.
data/lib/memery.rb CHANGED
@@ -37,6 +37,7 @@ module Memery
37
37
  # rubocop:disable Metrics/MethodLength
38
38
  # rubocop:disable Metrics/AbcSize
39
39
  # rubocop:disable Metrics/CyclomaticComplexity
40
+ # rubocop:disable Metrics/PerceivedComplexity
40
41
  def memoize(method_name, condition: nil, ttl: nil)
41
42
  original_visibility = Memery.method_visibility(self, method_name)
42
43
 
@@ -73,6 +74,7 @@ module Memery
73
74
  # rubocop:enable Metrics/MethodLength
74
75
  # rubocop:enable Metrics/AbcSize
75
76
  # rubocop:enable Metrics/CyclomaticComplexity
77
+ # rubocop:enable Metrics/PerceivedComplexity
76
78
 
77
79
  def memoized?(method_name)
78
80
  memoized_methods.key?(method_name)
@@ -80,9 +82,11 @@ module Memery
80
82
  end
81
83
 
82
84
  def clear_memery_cache!(*method_names)
85
+ return unless defined? @_memery_memoized_values
86
+
83
87
  if method_names.any?
84
88
  method_names.each { |method_name| @_memery_memoized_values[method_name]&.clear }
85
- elsif defined? @_memery_memoized_values
89
+ else
86
90
  @_memery_memoized_values.clear
87
91
  end
88
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Memery
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alt_memery
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-08 00:00:00.000000000 Z
12
+ date: 2021-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: module_methods
@@ -101,20 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.1.0
105
- - - "<"
106
- - !ruby/object:Gem::Version
107
- version: 0.1.18
104
+ version: 0.2.0
108
105
  type: :development
109
106
  prerelease: false
110
107
  version_requirements: !ruby/object:Gem::Requirement
111
108
  requirements:
112
109
  - - "~>"
113
110
  - !ruby/object:Gem::Version
114
- version: 0.1.0
115
- - - "<"
116
- - !ruby/object:Gem::Version
117
- version: 0.1.18
111
+ version: 0.2.0
118
112
  - !ruby/object:Gem::Dependency
119
113
  name: rspec
120
114
  requirement: !ruby/object:Gem::Requirement
@@ -135,28 +129,28 @@ dependencies:
135
129
  requirements:
136
130
  - - "~>"
137
131
  - !ruby/object:Gem::Version
138
- version: 0.18.0
132
+ version: 0.20.0
139
133
  type: :development
140
134
  prerelease: false
141
135
  version_requirements: !ruby/object:Gem::Requirement
142
136
  requirements:
143
137
  - - "~>"
144
138
  - !ruby/object:Gem::Version
145
- version: 0.18.0
139
+ version: 0.20.0
146
140
  - !ruby/object:Gem::Dependency
147
141
  name: rubocop
148
142
  requirement: !ruby/object:Gem::Requirement
149
143
  requirements:
150
144
  - - "~>"
151
145
  - !ruby/object:Gem::Version
152
- version: 0.87.0
146
+ version: '1.0'
153
147
  type: :development
154
148
  prerelease: false
155
149
  version_requirements: !ruby/object:Gem::Requirement
156
150
  requirements:
157
151
  - - "~>"
158
152
  - !ruby/object:Gem::Version
159
- version: 0.87.0
153
+ version: '1.0'
160
154
  - !ruby/object:Gem::Dependency
161
155
  name: rubocop-performance
162
156
  requirement: !ruby/object:Gem::Requirement
@@ -177,42 +171,42 @@ dependencies:
177
171
  requirements:
178
172
  - - "~>"
179
173
  - !ruby/object:Gem::Version
180
- version: '1.38'
174
+ version: '2.0'
181
175
  type: :development
182
176
  prerelease: false
183
177
  version_requirements: !ruby/object:Gem::Requirement
184
178
  requirements:
185
179
  - - "~>"
186
180
  - !ruby/object:Gem::Version
187
- version: '1.38'
181
+ version: '2.0'
188
182
  - !ruby/object:Gem::Dependency
189
183
  name: gem_toys
190
184
  requirement: !ruby/object:Gem::Requirement
191
185
  requirements:
192
186
  - - "~>"
193
187
  - !ruby/object:Gem::Version
194
- version: 0.2.0
188
+ version: 0.5.0
195
189
  type: :development
196
190
  prerelease: false
197
191
  version_requirements: !ruby/object:Gem::Requirement
198
192
  requirements:
199
193
  - - "~>"
200
194
  - !ruby/object:Gem::Version
201
- version: 0.2.0
195
+ version: 0.5.0
202
196
  - !ruby/object:Gem::Dependency
203
197
  name: toys
204
198
  requirement: !ruby/object:Gem::Requirement
205
199
  requirements:
206
200
  - - "~>"
207
201
  - !ruby/object:Gem::Version
208
- version: 0.10.0
202
+ version: 0.11.0
209
203
  type: :development
210
204
  prerelease: false
211
205
  version_requirements: !ruby/object:Gem::Requirement
212
206
  requirements:
213
207
  - - "~>"
214
208
  - !ruby/object:Gem::Version
215
- version: 0.10.0
209
+ version: 0.11.0
216
210
  description: |
217
211
  Alt Memery is a gem for memoization.
218
212
  It's a fork of Memery with implementation via `UnboundMethod` instead of `prepend Module`.
@@ -239,14 +233,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
233
  requirements:
240
234
  - - ">="
241
235
  - !ruby/object:Gem::Version
242
- version: '0'
236
+ version: '2.5'
237
+ - - "<"
238
+ - !ruby/object:Gem::Version
239
+ version: '4'
243
240
  required_rubygems_version: !ruby/object:Gem::Requirement
244
241
  requirements:
245
242
  - - ">="
246
243
  - !ruby/object:Gem::Version
247
244
  version: '0'
248
245
  requirements: []
249
- rubygems_version: 3.1.2
246
+ rubygems_version: 3.2.3
250
247
  signing_key:
251
248
  specification_version: 4
252
249
  summary: A gem for memoization.