nexus_mods 0.5.1 → 1.0.0

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: 30a5d88705ee7a8d0198ee6bd944bcc8735468e162e8bf17877ecffa3a356d27
4
- data.tar.gz: c622e319de62f51ee8dd8a8615187105dc8d246efe926933037315798e003ac0
3
+ metadata.gz: b99b3c80e3d45a5bde54394040517dc6e7c3cb803dfa4b3be263a0283bdf5606
4
+ data.tar.gz: cae008f32c14745db775d1791c631f15cab5071e3dcd0ac0d4d0c0ce5ba1a1c8
5
5
  SHA512:
6
- metadata.gz: c43800296d117d5e07862753eb2325d86549550237ab66c7a8b50d22b16676821cedbb69deea59dbca947266f74c9ba513683cb5846a807fdb338c4468154c81
7
- data.tar.gz: d172bd4112bfec791136a5f6b4e608871c92da6f6b3d025337dc767f64b712743173666458e767c57b308d328dbb91409eb7fc4261e92d42c048d9ed1b645eb3
6
+ metadata.gz: 8c0bf7800a21880cf748a0733d14483e3326d939671a5aa41b3e0076d3ef9ea46ff2e4d498078c95990a729542dd23ca15d229726e70b63eba139abd53ed828e
7
+ data.tar.gz: 754f2778855552657f7977d03fd8b84e58fc291b85b21f12dd6ee0d6a9baa6ade16670acc97244a043320f09d8b93e638b0ac4f680725b558b748c10bfcf99ba
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [v1.0.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.6.0...v1.0.0) (2023-04-10 19:03:51)
2
+
3
+ ### Breaking changes
4
+
5
+ * [[Breaking] Keep category_id in mod files and use category for interpretation, including unknowns categories](https://github.com/Muriel-Salvan/nexus_mods/commit/a6b01df6d03d27ee880260e46884f09e6a497f1d)
6
+
7
+ # [v0.6.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.5.1...v0.6.0) (2023-04-10 17:30:40)
8
+
9
+ ### Features
10
+
11
+ * [[Feature] Provide accessors for the default game domain name and mod id](https://github.com/Muriel-Salvan/nexus_mods/commit/ee2ba5c4d3eccf1adae2cc781c5988625537c341)
12
+
1
13
  # [v0.5.1](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.5.0...v0.5.1) (2023-04-10 17:19:39)
2
14
 
3
15
  ### Patches
@@ -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
@@ -1,5 +1,5 @@
1
1
  class NexusMods
2
2
 
3
- VERSION = '0.5.1'
3
+ VERSION = '1.0.0'
4
4
 
5
5
  end
data/lib/nexus_mods.rb CHANGED
@@ -182,15 +182,6 @@ class NexusMods
182
182
  )
183
183
  end
184
184
 
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
185
  # Get files belonging to a mod
195
186
  #
196
187
  # Parameters::
@@ -201,16 +192,13 @@ class NexusMods
201
192
  # * Array<ModFile>: List of mod's files
202
193
  def mod_files(game_domain_name: @game_domain_name, mod_id: @mod_id, clear_cache: false)
203
194
  @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
195
  Api::ModFile.new(
208
196
  ids: file_json['id'],
209
197
  uid: file_json['uid'],
210
198
  id: file_json['file_id'],
211
199
  name: file_json['name'],
212
200
  version: file_json['version'],
213
- category_id:,
201
+ category_id: file_json['category_id'],
214
202
  category_name: file_json['category_name'],
215
203
  is_primary: file_json['is_primary'],
216
204
  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.category_id).to eq :old
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.category_id).to eq :old
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
@@ -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,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',
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: 0.5.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan