memoize_until 1.2.0 → 1.2.1

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: 9f66521ac063cd6908fb61b5e05754a72a16beb3ba9862409f28b3b0beda85d1
4
- data.tar.gz: 4749947d376dcb95804afffe1621da5a31c5a604904254b2c478800e47ea8602
3
+ metadata.gz: 572f76ed252765bca587e9d9d68fb28327c02783ac1066d061147315c542a996
4
+ data.tar.gz: 36ef39ba60fba0f2ca3b0c26a9f082442f72ed4a1780952a79a78c1eb89305bf
5
5
  SHA512:
6
- metadata.gz: 3ceebecdc00e71e8618ad3404a1d85acc1e15cf3e9d5177aed0a8fd2258d8f9e8f3a7527c1bfaac5494a6f968febaaa7008c7e1a34a0dcf310f18abc0e43c029
7
- data.tar.gz: 264f732011f7209d9254c6d0dd78f29b6f666467be328fd6d93ee5db03c4b123fa1f312a49882d58461e2d7fc462425e363ce271a56efb23d78d00531a751a10
6
+ metadata.gz: ae171d5e3b67e3c0cb79116c4436206031c7924088f4fdb446dc89d937a4144427905c42b64c77d92a5d15acb3a413b30ebe0f85ff03f333c22185c12f7de171
7
+ data.tar.gz: a6f78d6a8097ae44332acd264b2a9e3df00ce0bca795e4f59c85bb1ce24ca08e348d6f357f0c6043c24365144c84fb8d42208a07620b8be6c3dea6f9befef61e
@@ -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).
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Ritikesh
3
+ Copyright (c) 2018 FRESHWORKS, INC.
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
@@ -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.0
1
+ 1.2.1
@@ -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
@@ -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.0
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-06 00:00:00.000000000 Z
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