memoize_until 1.2.0 → 1.2.1
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 +3 -0
- data/LICENSE.txt +1 -1
- data/README.md +12 -0
- data/VERSION +1 -1
- data/lib/memoize_until/base.rb +15 -0
- data/lib/memoize_until/store.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 572f76ed252765bca587e9d9d68fb28327c02783ac1066d061147315c542a996
|
4
|
+
data.tar.gz: 36ef39ba60fba0f2ca3b0c26a9f082442f72ed4a1780952a79a78c1eb89305bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae171d5e3b67e3c0cb79116c4436206031c7924088f4fdb446dc89d937a4144427905c42b64c77d92a5d15acb3a413b30ebe0f85ff03f333c22185c12f7de171
|
7
|
+
data.tar.gz: a6f78d6a8097ae44332acd264b2a9e3df00ce0bca795e4f59c85bb1ce24ca08e348d6f357f0c6043c24365144c84fb8d42208a07620b8be6c3dea6f9befef61e
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
## 1.2.1 - 08 May, 2020
|
2
|
+
|
3
|
+
* 🚀 [ENHANCEMENT] Public method `clear_now_for` added to `MemoizeUntil`, delegating the method to the underlying store object. This is done to support writing unit test cases without touching getting dirty with the private `Store` API. [#8](https://github.com/freshdesk/memoize_until/pull/8). Thanks to [@ritikesh](https://github.com/ritikesh).
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,18 @@ gem 'memoize_until'
|
|
36
36
|
For most use cases, the list of purposes that come will not suffice. You can define your custom list of config purposes that you wish to memoize for, by including a `config/memoize_until.yml` in the root directory of your application. Here is an [example](/examples/memoize_until.yml) to help you with the file structure.
|
37
37
|
|
38
38
|
## Testing
|
39
|
+
|
40
|
+
To clear the currently memoized value for a purpose, you can use the `clear_now` API.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
irb:> MemoizeUntil.day(:default) { 1 } # 1
|
44
|
+
irb:> MemoizeUntil.clear_now_for(:day, :default)
|
45
|
+
irb:> MemoizeUntil.day(:default) { 2 } # 2
|
46
|
+
```
|
47
|
+
|
48
|
+
#### Note: This API only clears the currently memoized value in the current running process and will not mitigate to other processes in a multiprocess world. This is recommended to be used only for testing setup.
|
49
|
+
|
50
|
+
## Contributing
|
39
51
|
To run test cases,
|
40
52
|
```shell
|
41
53
|
bundle install
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/lib/memoize_until/base.rb
CHANGED
@@ -47,4 +47,19 @@ class MemoizeUntil
|
|
47
47
|
def self.add_to(kind, key)
|
48
48
|
TYPE_FACTORY[kind].add(key)
|
49
49
|
end
|
50
|
+
|
51
|
+
# clears previously memoized value for "now" for the given key
|
52
|
+
# only clears memory in the process that this code runs on.
|
53
|
+
# added for supporting custom scripts / test cases
|
54
|
+
#
|
55
|
+
# @param kind [Symbol] one of the default or customised kind supported
|
56
|
+
# @param key [Symbol] the purpose defined in memoize_until.yml or :default.
|
57
|
+
#
|
58
|
+
# @example Clearing currently memoised value for today for :default.
|
59
|
+
# MemoizeUntil.clear_for(:day, :default)
|
60
|
+
#
|
61
|
+
# @return nil
|
62
|
+
def self.clear_now_for(kind, key)
|
63
|
+
TYPE_FACTORY[kind].clear_now(key)
|
64
|
+
end
|
50
65
|
end
|
data/lib/memoize_until/store.rb
CHANGED
@@ -27,14 +27,14 @@ class MemoizeUntil
|
|
27
27
|
|
28
28
|
# clears all previously memoized values for the given key
|
29
29
|
# only clears memory in the process that this code runs.
|
30
|
-
# added for fetch and custom scripts
|
30
|
+
# added for supporting fetch and custom scripts
|
31
31
|
def clear_all(key)
|
32
32
|
_store[key] = {}
|
33
33
|
end
|
34
34
|
|
35
35
|
# clears previously memoized value for "now" for the given key
|
36
|
-
# only clears memory in the process that this code runs.
|
37
|
-
# added for custom scripts
|
36
|
+
# only clears memory in the process that this code runs on.
|
37
|
+
# added for supporting custom scripts / test cases
|
38
38
|
def clear_now(key)
|
39
39
|
now = Time.now.public_send(_kind)
|
40
40
|
_store[key][now] = nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memoize_until
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ritikesh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -47,6 +47,7 @@ extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
49
|
- ".gitignore"
|
50
|
+
- CHANGELOG.md
|
50
51
|
- CODE_OF_CONDUCT.md
|
51
52
|
- Gemfile
|
52
53
|
- LICENSE.txt
|