nexus_mods 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/nexus_mods/api_client.rb +8 -5
- data/lib/nexus_mods/cacheable_api.rb +11 -2
- data/lib/nexus_mods/version.rb +1 -1
- data/lib/nexus_mods.rb +0 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30a5d88705ee7a8d0198ee6bd944bcc8735468e162e8bf17877ecffa3a356d27
|
4
|
+
data.tar.gz: c622e319de62f51ee8dd8a8615187105dc8d246efe926933037315798e003ac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43800296d117d5e07862753eb2325d86549550237ab66c7a8b50d22b16676821cedbb69deea59dbca947266f74c9ba513683cb5846a807fdb338c4468154c81
|
7
|
+
data.tar.gz: d172bd4112bfec791136a5f6b4e608871c92da6f6b3d025337dc767f64b712743173666458e767c57b308d328dbb91409eb7fc4261e92d42c048d9ed1b645eb3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# [v0.5.1](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.5.0...v0.5.1) (2023-04-10 17:19:39)
|
2
|
+
|
3
|
+
### Patches
|
4
|
+
|
5
|
+
* [Use more efficient API cache keys](https://github.com/Muriel-Salvan/nexus_mods/commit/3f09a08b815c71a0b0ec6694359c02fd8503bc90)
|
6
|
+
|
1
7
|
# [v0.5.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.4.0...v0.5.0) (2023-04-10 17:05:11)
|
2
8
|
|
3
9
|
### Features
|
@@ -150,13 +150,16 @@ class NexusMods
|
|
150
150
|
end
|
151
151
|
cacheable_api(
|
152
152
|
:cached_api,
|
153
|
+
key_format: proc do |_target, _method_name, method_args, method_kwargs|
|
154
|
+
"#{method_kwargs[:verb]}/#{method_args.first}"
|
155
|
+
end,
|
153
156
|
expiry_from_key: proc do |key|
|
154
157
|
# Example of keys:
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
key_components = key.split('/')[
|
158
|
+
# get/games
|
159
|
+
# get/games/skyrimspecialedition/mods/2014
|
160
|
+
# get/games/skyrimspecialedition/mods/2014/files
|
161
|
+
# get/users/validate
|
162
|
+
key_components = key.split('/')[1..]
|
160
163
|
case key_components[0]
|
161
164
|
when 'games'
|
162
165
|
if key_components[1].nil?
|
@@ -29,10 +29,19 @@ class NexusMods
|
|
29
29
|
# * Result::
|
30
30
|
# * Integer: Corresponding expiry time
|
31
31
|
# * *on_cache_update* (Proc): Proc called when the cache has been updated
|
32
|
-
|
32
|
+
# * *key_format* (Proc or nil): Optional proc giving the key format from the target of cacheable [default: nil].
|
33
|
+
# If nil then a default proc concatenating the target's class, method name and all arguments will be used.
|
34
|
+
# * Parameters::
|
35
|
+
# * *target* (Object): Object on which the method is cached
|
36
|
+
# * *method_name* (Symbol): Method being cached
|
37
|
+
# * *method_args* (Array<Object>): Method's arguments
|
38
|
+
# * *method_kwargs* (Hash<Symbol,Object>): Method's kwargs
|
39
|
+
# * Result::
|
40
|
+
# * String: The corresponding key to be used for caching
|
41
|
+
def cacheable_api(*original_method_names, expiry_from_key:, on_cache_update:, key_format: nil)
|
33
42
|
cacheable_with_expiry(
|
34
43
|
*original_method_names,
|
35
|
-
key_format:
|
44
|
+
key_format: key_format || proc do |target, method_name, method_args, method_kwargs|
|
36
45
|
(
|
37
46
|
[
|
38
47
|
target.class,
|
data/lib/nexus_mods/version.rb
CHANGED
data/lib/nexus_mods.rb
CHANGED
@@ -225,9 +225,4 @@ class NexusMods
|
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
228
|
-
# TODO: Check http cache usefulness and either test it or remove it
|
229
|
-
# TODO: Check if attr_reader of mod_id and game_id is needed and remove it if not
|
230
|
-
# TODO: Find better cache keys
|
231
|
-
# TODO: Documentation and examples
|
232
|
-
|
233
228
|
end
|