nexus_mods 0.6.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/nexus_mods/api/mod_file.rb +14 -0
- data/lib/nexus_mods/version.rb +1 -1
- data/lib/nexus_mods.rb +5 -14
- data/spec/nexus_mods_test/factories/mod_files.rb +4 -2
- data/spec/nexus_mods_test/helpers.rb +9 -1
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/mod_file_spec.rb +66 -0
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/mod_spec.rb +0 -8
- data/spec/nexus_mods_test/scenarios/nexus_mods/nexus_mods_common_spec.rb +32 -0
- metadata +4 -3
- /data/spec/nexus_mods_test/scenarios/{nexus_mods_access_spec.rb → nexus_mods/nexus_mods_access_spec.rb} +0 -0
- /data/spec/nexus_mods_test/scenarios/{nexus_mods_caching_spec.rb → nexus_mods/nexus_mods_caching_spec.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6490bd894c40f7806bb126cb70ade888ab5121499b86ff2cc959ee663dd223d
|
4
|
+
data.tar.gz: d9fdeb53c88c27ce9503e328a261ddb31a0facbbe0b6c35c304628c6e9580790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c8f9576edd38dab0076f24ad1d396973c9d1ab8542ff4eef548d9b49758f85b6da465465b10b1e53dbb2db6d8312f31e9b88649916f654e7b8c1a12092aaadb
|
7
|
+
data.tar.gz: 1b2d1e915594af39c9bd793a8f216fc2796024e2729a2b5596c35b546e04c8e2bb96dce77aa35e11f5d7a98fba1652c79f77f01648a363cfdf9b93ec40ee7602
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# [v1.1.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v1.0.0...v1.1.0) (2023-04-10 19:19:16)
|
2
|
+
|
3
|
+
### Features
|
4
|
+
|
5
|
+
* [[Feature] Add log_level parameter while creating nexus_mods instance](https://github.com/Muriel-Salvan/nexus_mods/commit/1b6215be2d9b3a97076bb6b7bf665f8ec8e900ca)
|
6
|
+
|
7
|
+
# [v1.0.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.6.0...v1.0.0) (2023-04-10 19:03:51)
|
8
|
+
|
9
|
+
### Breaking changes
|
10
|
+
|
11
|
+
* [[Breaking] Keep category_id in mod files and use category for interpretation, including unknowns categories](https://github.com/Muriel-Salvan/nexus_mods/commit/a6b01df6d03d27ee880260e46884f09e6a497f1d)
|
12
|
+
|
1
13
|
# [v0.6.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.5.1...v0.6.0) (2023-04-10 17:30:40)
|
2
14
|
|
3
15
|
### Features
|
@@ -14,6 +14,7 @@ class NexusMods
|
|
14
14
|
id
|
15
15
|
name
|
16
16
|
version
|
17
|
+
category
|
17
18
|
category_id
|
18
19
|
category_name
|
19
20
|
is_primary
|
@@ -28,6 +29,17 @@ class NexusMods
|
|
28
29
|
]
|
29
30
|
)
|
30
31
|
|
32
|
+
# Enum of file categories from the API
|
33
|
+
FILE_CATEGORIES = {
|
34
|
+
1 => :main,
|
35
|
+
2 => :patch,
|
36
|
+
3 => :optional,
|
37
|
+
4 => :old,
|
38
|
+
5 => :miscellaneous,
|
39
|
+
6 => :deleted,
|
40
|
+
7 => :archived
|
41
|
+
}
|
42
|
+
|
31
43
|
# Constructor
|
32
44
|
#
|
33
45
|
# Parameters::
|
@@ -81,6 +93,8 @@ class NexusMods
|
|
81
93
|
@description = description
|
82
94
|
@changelog_html = changelog_html
|
83
95
|
@content_preview_url = content_preview_url
|
96
|
+
# Extra fields for sugar
|
97
|
+
@category = FILE_CATEGORIES[category_id] || :unknown
|
84
98
|
end
|
85
99
|
|
86
100
|
# Equality operator
|
data/lib/nexus_mods/version.rb
CHANGED
data/lib/nexus_mods.rb
CHANGED
@@ -46,6 +46,7 @@ class NexusMods
|
|
46
46
|
# * *mod_files*: Expiry associated to queries on mod files [default: 1 day]
|
47
47
|
# * *api_cache_file* (String): File used to store the NexusMods API cache, or nil for no cache [default: "#{Dir.tmpdir}/nexus_mods_api_cache.json"]
|
48
48
|
# * *logger* (Logger): The logger to be used for log messages [default: Logger.new(STDOUT)]
|
49
|
+
# * *log_level* (Symbol): The logger level to be set [default: :info]
|
49
50
|
def initialize(
|
50
51
|
api_key: nil,
|
51
52
|
game_domain_name: 'skyrimspecialedition',
|
@@ -54,12 +55,14 @@ class NexusMods
|
|
54
55
|
http_cache_file: "#{Dir.tmpdir}/nexus_mods_http_cache.json",
|
55
56
|
api_cache_expiry: {},
|
56
57
|
api_cache_file: "#{Dir.tmpdir}/nexus_mods_api_cache.json",
|
57
|
-
logger: Logger.new($stdout)
|
58
|
+
logger: Logger.new($stdout),
|
59
|
+
log_level: :info
|
58
60
|
)
|
59
61
|
@game_domain_name = game_domain_name
|
60
62
|
@mod_id = mod_id
|
61
63
|
@file_id = file_id
|
62
64
|
@logger = logger
|
65
|
+
@logger.level = log_level
|
63
66
|
@premium = false
|
64
67
|
@api_client = ApiClient.new(
|
65
68
|
api_key:,
|
@@ -182,15 +185,6 @@ class NexusMods
|
|
182
185
|
)
|
183
186
|
end
|
184
187
|
|
185
|
-
# Enum of file categories from the API
|
186
|
-
FILE_CATEGORIES = {
|
187
|
-
1 => :main,
|
188
|
-
2 => :patch,
|
189
|
-
3 => :optional,
|
190
|
-
4 => :old,
|
191
|
-
6 => :deleted
|
192
|
-
}
|
193
|
-
|
194
188
|
# Get files belonging to a mod
|
195
189
|
#
|
196
190
|
# Parameters::
|
@@ -201,16 +195,13 @@ class NexusMods
|
|
201
195
|
# * Array<ModFile>: List of mod's files
|
202
196
|
def mod_files(game_domain_name: @game_domain_name, mod_id: @mod_id, clear_cache: false)
|
203
197
|
@api_client.api("games/#{game_domain_name}/mods/#{mod_id}/files", clear_cache:)['files'].map do |file_json|
|
204
|
-
category_id = FILE_CATEGORIES[file_json['category_id']]
|
205
|
-
raise "Unknown file category: #{file_json['category_id']}" if category_id.nil?
|
206
|
-
|
207
198
|
Api::ModFile.new(
|
208
199
|
ids: file_json['id'],
|
209
200
|
uid: file_json['uid'],
|
210
201
|
id: file_json['file_id'],
|
211
202
|
name: file_json['name'],
|
212
203
|
version: file_json['version'],
|
213
|
-
category_id
|
204
|
+
category_id: file_json['category_id'],
|
214
205
|
category_name: file_json['category_name'],
|
215
206
|
is_primary: file_json['is_primary'],
|
216
207
|
size: file_json['size_in_bytes'],
|
@@ -70,7 +70,8 @@ module NexusModsTest
|
|
70
70
|
expect(mod_file.id).to eq 2472
|
71
71
|
expect(mod_file.name).to eq 'ApachiiSkyHair_v_1_6_Full'
|
72
72
|
expect(mod_file.version).to eq '1.6.Full'
|
73
|
-
expect(mod_file.
|
73
|
+
expect(mod_file.category).to eq :old
|
74
|
+
expect(mod_file.category_id).to eq 4
|
74
75
|
expect(mod_file.category_name).to eq 'OLD_VERSION'
|
75
76
|
expect(mod_file.is_primary).to be false
|
76
77
|
expect(mod_file.size).to eq 309_251_227
|
@@ -93,7 +94,8 @@ module NexusModsTest
|
|
93
94
|
expect(mod_file.id).to eq 2487
|
94
95
|
expect(mod_file.name).to eq 'ApachiiSkyHairMale_v_1_2'
|
95
96
|
expect(mod_file.version).to eq '1.2'
|
96
|
-
expect(mod_file.
|
97
|
+
expect(mod_file.category).to eq :old
|
98
|
+
expect(mod_file.category_id).to eq 4
|
97
99
|
expect(mod_file.category_name).to eq 'OLD_VERSION'
|
98
100
|
expect(mod_file.is_primary).to be false
|
99
101
|
expect(mod_file.size).to eq 209_251_227
|
@@ -66,12 +66,20 @@ module NexusModsTest
|
|
66
66
|
@nexus_mods
|
67
67
|
end
|
68
68
|
|
69
|
+
# Get NexusMods logs
|
70
|
+
#
|
71
|
+
# Result::
|
72
|
+
# * String: The NexusMods logs
|
73
|
+
def nexus_mods_logs
|
74
|
+
@nexus_mods_logger.string
|
75
|
+
end
|
76
|
+
|
69
77
|
# Reset the NexusMods instance.
|
70
78
|
# Dump the output if needed for debugging purposes.
|
71
79
|
def reset_nexus_mods
|
72
80
|
if @nexus_mods && test_debug?
|
73
81
|
puts '===== NexusMods output BEGIN ====='
|
74
|
-
puts
|
82
|
+
puts nexus_mods_logs
|
75
83
|
puts '===== NexusMods output END ====='
|
76
84
|
end
|
77
85
|
@nexus_mods = nil
|
@@ -49,6 +49,15 @@ describe NexusMods::Api::ModFile do
|
|
49
49
|
expect_mod_files_to_be_example(nexus_mods(game_domain_name: 'skyrimspecialedition').mod_files(mod_id: 2014))
|
50
50
|
end
|
51
51
|
|
52
|
+
it 'returns mod files list for the default game set using accessor' do
|
53
|
+
expect_http_call_to(
|
54
|
+
path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
|
55
|
+
json: { files: json_example_mod_files }
|
56
|
+
)
|
57
|
+
nexus_mods.game_domain_name = 'skyrimspecialedition'
|
58
|
+
expect_mod_files_to_be_example(nexus_mods.mod_files(mod_id: 2014))
|
59
|
+
end
|
60
|
+
|
52
61
|
it 'returns mod files list for the default game and mod' do
|
53
62
|
expect_http_call_to(
|
54
63
|
path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
|
@@ -57,6 +66,15 @@ describe NexusMods::Api::ModFile do
|
|
57
66
|
expect_mod_files_to_be_example(nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod_files)
|
58
67
|
end
|
59
68
|
|
69
|
+
it 'returns mod files list for the default game and mod using accessor' do
|
70
|
+
expect_http_call_to(
|
71
|
+
path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
|
72
|
+
json: { files: json_example_mod_files }
|
73
|
+
)
|
74
|
+
nexus_mods.mod_id = 2014
|
75
|
+
expect_mod_files_to_be_example(nexus_mods.mod_files(game_domain_name: 'skyrimspecialedition'))
|
76
|
+
end
|
77
|
+
|
60
78
|
it 'compares objects for equality' do
|
61
79
|
expect_http_call_to(
|
62
80
|
path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
|
@@ -68,6 +86,54 @@ describe NexusMods::Api::ModFile do
|
|
68
86
|
expect(mod_file1).to eq mod_file2
|
69
87
|
end
|
70
88
|
|
89
|
+
{
|
90
|
+
main: 1,
|
91
|
+
patch: 2,
|
92
|
+
optional: 3,
|
93
|
+
old: 4,
|
94
|
+
miscellaneous: 5,
|
95
|
+
deleted: 6,
|
96
|
+
archived: 7,
|
97
|
+
unknown: 100
|
98
|
+
}.each do |category, category_id|
|
99
|
+
it "accepts mod files having category #{category}" do
|
100
|
+
expect_http_call_to(
|
101
|
+
path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
|
102
|
+
json: {
|
103
|
+
files: [
|
104
|
+
{
|
105
|
+
'id' => [
|
106
|
+
2472,
|
107
|
+
1704
|
108
|
+
],
|
109
|
+
'uid' => 7_318_624_274_856,
|
110
|
+
'file_id' => 2472,
|
111
|
+
'name' => 'ApachiiSkyHair_v_1_6_Full',
|
112
|
+
'version' => '1.6.Full',
|
113
|
+
'category_id' => category_id,
|
114
|
+
'category_name' => 'OLD_VERSION',
|
115
|
+
'is_primary' => false,
|
116
|
+
'file_name' => 'ApachiiSkyHair_v_1_6_Full-2014-1-6-Full.7z',
|
117
|
+
'uploaded_timestamp' => 1_477_967_645,
|
118
|
+
'uploaded_time' => '2016-11-01T02:34:05.000+00:00',
|
119
|
+
'mod_version' => '1.6.Full',
|
120
|
+
'external_virus_scan_url' => 'https://www.virustotal.com/file/3dcc96dce0b846ea643d626c48bd6ad08752da8232f3d29be644d36e1fd627cf/analysis/1477978674/',
|
121
|
+
'description' => '[b][color=orange] NOT optimized meshes. Standalone. Adds 42 new hairstyles for females, 21 hair for males and 5 hairs for Female Khajiit- 2 hairs for Male Khajiit[/color][/b] ',
|
122
|
+
'size' => 304_347,
|
123
|
+
'size_kb' => 304_347,
|
124
|
+
'size_in_bytes' => 309_251_227,
|
125
|
+
'changelog_html' => nil,
|
126
|
+
'content_preview_link' => 'https://file-metadata.nexusmods.com/file/nexus-files-meta/1704/2014/ApachiiSkyHair_v_1_6_Full-2014-1-6-Full.7z.json'
|
127
|
+
}
|
128
|
+
]
|
129
|
+
}
|
130
|
+
)
|
131
|
+
mod_file = nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod_files.first
|
132
|
+
expect(mod_file.category).to eq category
|
133
|
+
expect(mod_file.category_id).to eq category_id
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
71
137
|
end
|
72
138
|
|
73
139
|
end
|
@@ -6,14 +6,6 @@ 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
|
-
|
17
9
|
it 'returns a mod complete information' do
|
18
10
|
expect_http_call_to(
|
19
11
|
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|
@@ -0,0 +1,32 @@
|
|
1
|
+
describe NexusMods do
|
2
|
+
|
3
|
+
context 'when testing authentication and access' do
|
4
|
+
|
5
|
+
it 'returns the default game domain name' do
|
6
|
+
expect_validate_user
|
7
|
+
expect(nexus_mods(game_domain_name: 'skyrimspecialedition').game_domain_name).to eq 'skyrimspecialedition'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the default game mod id' do
|
11
|
+
expect_validate_user
|
12
|
+
expect(nexus_mods(mod_id: 2014).mod_id).to eq 2014
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'accepts the log level' do
|
16
|
+
expect_validate_user(times: 2)
|
17
|
+
expect_http_call_to(
|
18
|
+
path: '/v1/games.json',
|
19
|
+
json: [],
|
20
|
+
times: 2
|
21
|
+
)
|
22
|
+
nexus_mods(log_level: :debug).games
|
23
|
+
log_debug = nexus_mods_logs
|
24
|
+
reset_nexus_mods
|
25
|
+
nexus_mods(log_level: :info).games
|
26
|
+
log_info = nexus_mods_logs
|
27
|
+
expect(log_debug.size).to be > log_info.size
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_mods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muriel Salvan
|
@@ -157,8 +157,9 @@ files:
|
|
157
157
|
- spec/nexus_mods_test/scenarios/nexus_mods/api/game_spec.rb
|
158
158
|
- spec/nexus_mods_test/scenarios/nexus_mods/api/mod_file_spec.rb
|
159
159
|
- spec/nexus_mods_test/scenarios/nexus_mods/api/mod_spec.rb
|
160
|
-
- spec/nexus_mods_test/scenarios/nexus_mods_access_spec.rb
|
161
|
-
- spec/nexus_mods_test/scenarios/nexus_mods_caching_spec.rb
|
160
|
+
- spec/nexus_mods_test/scenarios/nexus_mods/nexus_mods_access_spec.rb
|
161
|
+
- spec/nexus_mods_test/scenarios/nexus_mods/nexus_mods_caching_spec.rb
|
162
|
+
- spec/nexus_mods_test/scenarios/nexus_mods/nexus_mods_common_spec.rb
|
162
163
|
- spec/nexus_mods_test/scenarios/rubocop_spec.rb
|
163
164
|
- spec/spec_helper.rb
|
164
165
|
homepage: https://github.com/Muriel-Salvan/nexus_mods
|
File without changes
|
File without changes
|