nexus_mods 0.6.0 → 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: 81b66890f6e45e4f48b44fc3dbc2ce5f8ae7c3ee037960b95f4f269adb41ee77
4
- data.tar.gz: 611d91825c05ba62fc6a6fcf16b62ba07cf284479e21e7bfb306b397ea910613
3
+ metadata.gz: b99b3c80e3d45a5bde54394040517dc6e7c3cb803dfa4b3be263a0283bdf5606
4
+ data.tar.gz: cae008f32c14745db775d1791c631f15cab5071e3dcd0ac0d4d0c0ce5ba1a1c8
5
5
  SHA512:
6
- metadata.gz: 6e53e797874ad30d2f6877202d0c926d21124b5208447e15d9af38d5ce6424b96d153d1c9c7ffafa8073d96ac9addcb5e0273438efb5899ef296d35355e2d889
7
- data.tar.gz: cfa6d681a78c652108d70e605a951178b90e20a21a6477e7ef98c3822e00fdca50912973c675019dc69e5d69c7735025666252b82bbdc2761a038147c76c6fc0
6
+ metadata.gz: 8c0bf7800a21880cf748a0733d14483e3326d939671a5aa41b3e0076d3ef9ea46ff2e4d498078c95990a729542dd23ca15d229726e70b63eba139abd53ed828e
7
+ data.tar.gz: 754f2778855552657f7977d03fd8b84e58fc291b85b21f12dd6ee0d6a9baa6ade16670acc97244a043320f09d8b93e638b0ac4f680725b558b748c10bfcf99ba
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
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
+
1
7
  # [v0.6.0](https://github.com/Muriel-Salvan/nexus_mods/compare/v0.5.1...v0.6.0) (2023-04-10 17:30:40)
2
8
 
3
9
  ### 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
@@ -1,5 +1,5 @@
1
1
  class NexusMods
2
2
 
3
- VERSION = '0.6.0'
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
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.6.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan