nexus_mods 0.5.0 → 0.6.0
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 +12 -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
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/mod_spec.rb +26 -0
- 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: 81b66890f6e45e4f48b44fc3dbc2ce5f8ae7c3ee037960b95f4f269adb41ee77
|
4
|
+
data.tar.gz: 611d91825c05ba62fc6a6fcf16b62ba07cf284479e21e7bfb306b397ea910613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e53e797874ad30d2f6877202d0c926d21124b5208447e15d9af38d5ce6424b96d153d1c9c7ffafa8073d96ac9addcb5e0273438efb5899ef296d35355e2d889
|
7
|
+
data.tar.gz: cfa6d681a78c652108d70e605a951178b90e20a21a6477e7ef98c3822e00fdca50912973c675019dc69e5d69c7735025666252b82bbdc2761a038147c76c6fc0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# [v0.6.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.5.1...v0.6.0) (2023-04-10 17:30:40)
|
2
|
+
|
3
|
+
### Features
|
4
|
+
|
5
|
+
* [[Feature] Provide accessors for the default game domain name and mod id](https://github.com/Muriel-Salvan/nexus_mods/commit/ee2ba5c4d3eccf1adae2cc781c5988625537c341)
|
6
|
+
|
7
|
+
# [v0.5.1](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.5.0...v0.5.1) (2023-04-10 17:19:39)
|
8
|
+
|
9
|
+
### Patches
|
10
|
+
|
11
|
+
* [Use more efficient API cache keys](https://github.com/Muriel-Salvan/nexus_mods/commit/3f09a08b815c71a0b0ec6694359c02fd8503bc90)
|
12
|
+
|
1
13
|
# [v0.5.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.4.0...v0.5.0) (2023-04-10 17:05:11)
|
2
14
|
|
3
15
|
### 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
|
@@ -6,6 +6,14 @@ describe NexusMods::Api::Mod do
|
|
6
6
|
expect_validate_user
|
7
7
|
end
|
8
8
|
|
9
|
+
it 'returns the default game domain name' do
|
10
|
+
expect(nexus_mods(game_domain_name: 'skyrimspecialedition').game_domain_name).to eq 'skyrimspecialedition'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns the default game mod id' do
|
14
|
+
expect(nexus_mods(mod_id: 2014).mod_id).to eq 2014
|
15
|
+
end
|
16
|
+
|
9
17
|
it 'returns a mod complete information' do
|
10
18
|
expect_http_call_to(
|
11
19
|
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|
@@ -38,6 +46,15 @@ describe NexusMods::Api::Mod do
|
|
38
46
|
expect_mod_to_be_complete(nexus_mods(game_domain_name: 'skyrimspecialedition').mod(mod_id: 2014))
|
39
47
|
end
|
40
48
|
|
49
|
+
it 'returns mod information for the default game set using accessor' do
|
50
|
+
expect_http_call_to(
|
51
|
+
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|
52
|
+
json: json_complete_mod
|
53
|
+
)
|
54
|
+
nexus_mods.game_domain_name = 'skyrimspecialedition'
|
55
|
+
expect_mod_to_be_complete(nexus_mods.mod(mod_id: 2014))
|
56
|
+
end
|
57
|
+
|
41
58
|
it 'returns mod information for the default game and mod' do
|
42
59
|
expect_http_call_to(
|
43
60
|
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|
@@ -46,6 +63,15 @@ describe NexusMods::Api::Mod do
|
|
46
63
|
expect_mod_to_be_complete(nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod)
|
47
64
|
end
|
48
65
|
|
66
|
+
it 'returns mod information for the default game and mod set using accessor' do
|
67
|
+
expect_http_call_to(
|
68
|
+
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|
69
|
+
json: json_complete_mod
|
70
|
+
)
|
71
|
+
nexus_mods.mod_id = 2014
|
72
|
+
expect_mod_to_be_complete(nexus_mods.mod(game_domain_name: 'skyrimspecialedition'))
|
73
|
+
end
|
74
|
+
|
49
75
|
it 'compares objects for equality' do
|
50
76
|
expect_http_call_to(
|
51
77
|
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|