nexus_mods 0.1.1 → 0.2.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.
@@ -0,0 +1,73 @@
1
+ describe NexusMods::Api::ModFile do
2
+
3
+ context 'when testing mod files' do
4
+
5
+ before do
6
+ expect_validate_user
7
+ end
8
+
9
+ # Example of JSON object returned by the API for a mod files list
10
+ let(:json_example_mod_files) do
11
+ [
12
+ json_mod_file2472,
13
+ json_mod_file2487
14
+ ]
15
+ end
16
+
17
+ # Expect a mod's files to be the example ones
18
+ #
19
+ # Parameters::
20
+ # * *mod_files* (Array<NexusMods::Api::File>): List of files to validate
21
+ def expect_mod_files_to_be_example(mod_files)
22
+ expect(mod_files.size).to eq 2
23
+ sorted_mod_files = mod_files.sort_by(&:id)
24
+ expect_mod_file_to_be2472(sorted_mod_files.first)
25
+ expect_mod_file_to_be2487(sorted_mod_files[1])
26
+ end
27
+
28
+ it 'returns a mod files list' do
29
+ expect_http_call_to(
30
+ path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
31
+ json: { files: json_example_mod_files }
32
+ )
33
+ expect_mod_files_to_be_example(nexus_mods.mod_files(game_domain_name: 'skyrimspecialedition', mod_id: 2014))
34
+ end
35
+
36
+ it 'returns the default mod files list' do
37
+ expect_http_call_to(
38
+ path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
39
+ json: { files: json_example_mod_files }
40
+ )
41
+ expect_mod_files_to_be_example(nexus_mods(mod_id: 2014).mod_files(game_domain_name: 'skyrimspecialedition'))
42
+ end
43
+
44
+ it 'returns mod files list for the default game' do
45
+ expect_http_call_to(
46
+ path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
47
+ json: { files: json_example_mod_files }
48
+ )
49
+ expect_mod_files_to_be_example(nexus_mods(game_domain_name: 'skyrimspecialedition').mod_files(mod_id: 2014))
50
+ end
51
+
52
+ it 'returns mod files list for the default game and mod' do
53
+ expect_http_call_to(
54
+ path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
55
+ json: { files: json_example_mod_files }
56
+ )
57
+ expect_mod_files_to_be_example(nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod_files)
58
+ end
59
+
60
+ it 'compares objects for equality' do
61
+ expect_http_call_to(
62
+ path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
63
+ json: { files: [json_mod_file2472] }
64
+ )
65
+ mod_file1 = nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod_files.first
66
+ mod_file2 = nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod_files.first
67
+ expect(mod_file1.object_id).not_to eq mod_file2.object_id
68
+ expect(mod_file1).to eq mod_file2
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,62 @@
1
+ describe NexusMods::Api::Mod do
2
+
3
+ context 'when testing mods' do
4
+
5
+ before do
6
+ expect_validate_user
7
+ end
8
+
9
+ it 'returns a mod complete information' do
10
+ expect_http_call_to(
11
+ path: '/v1/games/skyrimspecialedition/mods/2014.json',
12
+ json: json_complete_mod
13
+ )
14
+ expect_mod_to_be_complete(nexus_mods.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014))
15
+ end
16
+
17
+ it 'returns a mod partial information' do
18
+ expect_http_call_to(
19
+ path: '/v1/games/skyrimspecialedition/mods/2014.json',
20
+ json: json_partial_mod
21
+ )
22
+ expect_mod_to_be_partial(nexus_mods.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014))
23
+ end
24
+
25
+ it 'returns the default mod information' do
26
+ expect_http_call_to(
27
+ path: '/v1/games/skyrimspecialedition/mods/2014.json',
28
+ json: json_complete_mod
29
+ )
30
+ expect_mod_to_be_complete(nexus_mods(mod_id: 2014).mod(game_domain_name: 'skyrimspecialedition'))
31
+ end
32
+
33
+ it 'returns mod information for the default game' do
34
+ expect_http_call_to(
35
+ path: '/v1/games/skyrimspecialedition/mods/2014.json',
36
+ json: json_complete_mod
37
+ )
38
+ expect_mod_to_be_complete(nexus_mods(game_domain_name: 'skyrimspecialedition').mod(mod_id: 2014))
39
+ end
40
+
41
+ it 'returns mod information for the default game and mod' do
42
+ expect_http_call_to(
43
+ path: '/v1/games/skyrimspecialedition/mods/2014.json',
44
+ json: json_complete_mod
45
+ )
46
+ expect_mod_to_be_complete(nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod)
47
+ end
48
+
49
+ it 'compares objects for equality' do
50
+ expect_http_call_to(
51
+ path: '/v1/games/skyrimspecialedition/mods/2014.json',
52
+ json: json_complete_mod
53
+ )
54
+ mod1 = nexus_mods.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014)
55
+ mod2 = nexus_mods.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014)
56
+ expect(mod1.object_id).not_to eq mod2.object_id
57
+ expect(mod1).to eq mod2
58
+ end
59
+
60
+ end
61
+
62
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-27 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -122,18 +122,21 @@ files:
122
122
  - LICENSE.md
123
123
  - README.md
124
124
  - lib/nexus_mods.rb
125
- - lib/nexus_mods/api_limits.rb
126
- - lib/nexus_mods/category.rb
127
- - lib/nexus_mods/game.rb
128
- - lib/nexus_mods/mod.rb
129
- - lib/nexus_mods/mod_file.rb
130
- - lib/nexus_mods/user.rb
125
+ - lib/nexus_mods/api/api_limits.rb
126
+ - lib/nexus_mods/api/category.rb
127
+ - lib/nexus_mods/api/game.rb
128
+ - lib/nexus_mods/api/mod.rb
129
+ - lib/nexus_mods/api/mod_file.rb
130
+ - lib/nexus_mods/api/user.rb
131
131
  - lib/nexus_mods/version.rb
132
+ - spec/nexus_mods_test/factories/games.rb
133
+ - spec/nexus_mods_test/factories/mod_files.rb
134
+ - spec/nexus_mods_test/factories/mods.rb
132
135
  - spec/nexus_mods_test/helpers.rb
133
- - spec/nexus_mods_test/scenarios/nexus_mods/api_limits_spec.rb
134
- - spec/nexus_mods_test/scenarios/nexus_mods/game_spec.rb
135
- - spec/nexus_mods_test/scenarios/nexus_mods/mod_file_spec.rb
136
- - spec/nexus_mods_test/scenarios/nexus_mods/mod_spec.rb
136
+ - spec/nexus_mods_test/scenarios/nexus_mods/api/api_limits_spec.rb
137
+ - spec/nexus_mods_test/scenarios/nexus_mods/api/game_spec.rb
138
+ - spec/nexus_mods_test/scenarios/nexus_mods/api/mod_file_spec.rb
139
+ - spec/nexus_mods_test/scenarios/nexus_mods/api/mod_spec.rb
137
140
  - spec/nexus_mods_test/scenarios/nexus_mods_access_spec.rb
138
141
  - spec/nexus_mods_test/scenarios/rubocop_spec.rb
139
142
  - spec/spec_helper.rb
@@ -158,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
161
  - !ruby/object:Gem::Version
159
162
  version: '0'
160
163
  requirements: []
161
- rubygems_version: 3.4.6
164
+ rubygems_version: 3.4.10
162
165
  signing_key:
163
166
  specification_version: 4
164
167
  summary: Access NexusMods REST API from Ruby
@@ -1,44 +0,0 @@
1
- class NexusMods
2
-
3
- # Object giving the NexusMods API limits
4
- class ApiLimits
5
-
6
- attr_reader(
7
- *%i[
8
- daily_limit
9
- daily_remaining
10
- daily_reset
11
- hourly_limit
12
- hourly_remaining
13
- hourly_reset
14
- ]
15
- )
16
-
17
- # Constructor
18
- #
19
- # Parameters::
20
- # * *daily_limit* (Integer): The daily limit
21
- # * *daily_remaining* (Integer): The daily remaining
22
- # * *daily_reset* (Integer): The daily reset time
23
- # * *hourly_limit* (Integer): The hourly limit
24
- # * *hourly_remaining* (Integer): The hourly remaining
25
- # * *hourly_reset* (Integer): The hourly reset time
26
- def initialize(
27
- daily_limit:,
28
- daily_remaining:,
29
- daily_reset:,
30
- hourly_limit:,
31
- hourly_remaining:,
32
- hourly_reset:
33
- )
34
- @daily_limit = daily_limit
35
- @daily_remaining = daily_remaining
36
- @daily_reset = daily_reset
37
- @hourly_limit = hourly_limit
38
- @hourly_remaining = hourly_remaining
39
- @hourly_reset = hourly_reset
40
- end
41
-
42
- end
43
-
44
- end
@@ -1,37 +0,0 @@
1
- class NexusMods
2
-
3
- # Categories defined for a game in NexusMods
4
- class Category
5
-
6
- attr_reader(
7
- *%i[
8
- id
9
- name
10
- ]
11
- )
12
-
13
- attr_accessor(
14
- *%i[
15
- parent_category
16
- ]
17
- )
18
-
19
- # Constructor
20
- #
21
- # Parameters::
22
- # *id* (Integer): The category id
23
- # *name* (String): The category id
24
- # *parent_category* (Category or nil): The parent category, or nil if none [default: nil]
25
- def initialize(
26
- id:,
27
- name:,
28
- parent_category: nil
29
- )
30
- @id = id
31
- @name = name
32
- @parent_category = parent_category
33
- end
34
-
35
- end
36
-
37
- end
@@ -1,78 +0,0 @@
1
- class NexusMods
2
-
3
- # A NexusMods game.
4
- # Attributes info can be taken from there:
5
- # * https://github.com/Nexus-Mods/node-nexus-api/blob/master/docs/interfaces/_types_.igameinfo.md
6
- class Game
7
-
8
- attr_reader(
9
- *%i[
10
- id
11
- name
12
- forum_url
13
- nexusmods_url
14
- genre
15
- domain_name
16
- approved_date
17
- files_count
18
- files_views
19
- files_endorsements
20
- downloads_count
21
- authors_count
22
- mods_count
23
- categories
24
- ]
25
- )
26
-
27
- # Constructor
28
- #
29
- # Parameters::
30
- # * *id* (Integer): The game's id
31
- # * *name* (String): The game's name
32
- # * *forum_url* (String): The game's forum's URL
33
- # * *nexusmods_url* (String): The game's NexusMods' URL
34
- # * *genre* (String): The game's genre
35
- # * *domain_name* (String): The game's domain's name
36
- # * *approved_date* (Time): The game's approved date (time when the game was added)
37
- # * *files_count* (Integer): The game's files' count [default: 0]
38
- # * *files_views* (Integer): The game's files' views [default: 0]
39
- # * *files_endorsements* (Integer): The game's files' endorsements [default: 0]
40
- # * *downloads_count* (Integer): The game's downloads' count [default: 0]
41
- # * *authors_count* (Integer): The game's authors's count [default: 0]
42
- # * *mods_count* (Integer): The game's mods' count [default: 0]
43
- # * *categories* (Array<Category>): The list of game's categories [default: []]
44
- def initialize(
45
- id:,
46
- name:,
47
- forum_url:,
48
- nexusmods_url:,
49
- genre:,
50
- domain_name:,
51
- approved_date:,
52
- files_count: 0,
53
- files_views: 0,
54
- files_endorsements: 0,
55
- downloads_count: 0,
56
- authors_count: 0,
57
- mods_count: 0,
58
- categories: []
59
- )
60
- @id = id
61
- @name = name
62
- @forum_url = forum_url
63
- @nexusmods_url = nexusmods_url
64
- @genre = genre
65
- @domain_name = domain_name
66
- @approved_date = approved_date
67
- @files_count = files_count
68
- @files_views = files_views
69
- @files_endorsements = files_endorsements
70
- @downloads_count = downloads_count
71
- @authors_count = authors_count
72
- @mods_count = mods_count
73
- @categories = categories
74
- end
75
-
76
- end
77
-
78
- end
@@ -1,106 +0,0 @@
1
- class NexusMods
2
-
3
- # A NexusMods mod.
4
- # Attributes info can be taken from there:
5
- # * https://github.com/Nexus-Mods/node-nexus-api/blob/master/docs/interfaces/_types_.imodinfo.md
6
- class Mod
7
-
8
- attr_reader(
9
- *%i[
10
- uid
11
- mod_id
12
- game_id
13
- allow_rating
14
- domain_name
15
- category_id
16
- version
17
- created_time
18
- updated_time
19
- author
20
- contains_adult_content
21
- status
22
- available
23
- uploader
24
- name
25
- summary
26
- description
27
- picture_url
28
- downloads_count
29
- unique_downloads_count
30
- endorsements_count
31
- ]
32
- )
33
-
34
- # Constructor
35
- #
36
- # Parameters::
37
- # * *uid* (Integer): The mod's uid
38
- # * *mod_id* (Integer): The mod's id
39
- # * *game_id* (Integer): The mod's game id
40
- # * *allow_rating* (Boolean): Does this mod allow endorsements?
41
- # * *domain_name* (String): The mod's domain name
42
- # * *category_id* (String): The mod's category id
43
- # * *version* (String): The mod's version
44
- # * *created_time* (Time): The mod's creation time
45
- # * *updated_time* (Time): The mod's update time
46
- # * *author* (String): The mod's author
47
- # * *contains_adult_content* (Boolean): Does this mod contain adult content?
48
- # * *status* (String): The mod's status
49
- # * *available* (Boolean): Is the mod publicly available?
50
- # * *uploader* (User): The mod's uploader information
51
- # * *name* (String or nil): The mod's name, or nil if under moderation [default: nil]
52
- # * *summary* (String or nil): The mod's summary, or nil if none [default: nil]
53
- # * *description* (String or nil): The mod's description, or nil if none [default: nil]
54
- # * *picture_url* (String): The mod's picture_url [default: nil]
55
- # * *downloads_count* (Integer): The mod's downloads' count [default: 0]
56
- # * *unique_downloads_count* (Integer): The mod's unique downloads' count [default: 0]
57
- # * *endorsements_count* (Integer): The mod's endorsements' count [default: 0]
58
- def initialize(
59
- uid:,
60
- mod_id:,
61
- game_id:,
62
- allow_rating:,
63
- domain_name:,
64
- category_id:,
65
- version:,
66
- created_time:,
67
- updated_time:,
68
- author:,
69
- contains_adult_content:,
70
- status:,
71
- available:,
72
- uploader:,
73
- name: nil,
74
- summary: nil,
75
- description: nil,
76
- picture_url: nil,
77
- downloads_count: 0,
78
- unique_downloads_count: 0,
79
- endorsements_count: 0
80
- )
81
- @uid = uid
82
- @mod_id = mod_id
83
- @game_id = game_id
84
- @allow_rating = allow_rating
85
- @domain_name = domain_name
86
- @category_id = category_id
87
- @version = version
88
- @created_time = created_time
89
- @updated_time = updated_time
90
- @author = author
91
- @contains_adult_content = contains_adult_content
92
- @status = status
93
- @available = available
94
- @uploader = uploader
95
- @name = name
96
- @summary = summary
97
- @description = description
98
- @picture_url = picture_url
99
- @downloads_count = downloads_count
100
- @unique_downloads_count = unique_downloads_count
101
- @endorsements_count = endorsements_count
102
- end
103
-
104
- end
105
-
106
- end
@@ -1,86 +0,0 @@
1
- class NexusMods
2
-
3
- # A NexusMods file.
4
- # Attributes info can be taken from there:
5
- # * https://github.com/Nexus-Mods/node-nexus-api/blob/master/docs/interfaces/_types_.ifileinfo.md
6
- class ModFile
7
-
8
- attr_reader(
9
- *%i[
10
- ids
11
- uid
12
- id
13
- name
14
- version
15
- category_id
16
- category_name
17
- is_primary
18
- size
19
- file_name
20
- uploaded_time
21
- mod_version
22
- external_virus_scan_url
23
- description
24
- changelog_html
25
- content_preview_url
26
- ]
27
- )
28
-
29
- # Constructor
30
- #
31
- # Parameters::
32
- # * *ids* (Array<Integer>): The file's list of IDs
33
- # * *uid* (Integer): The file's UID
34
- # * *id* (Integer): The file's main ID
35
- # * *name* (String): The file's name
36
- # * *version* (String): The file's version
37
- # * *category_id* (Symbol): The file's category's ID
38
- # * *category_name* (String): The file's category_name
39
- # * *is_primary* (String): Is this file the primary download one?
40
- # * *size* (Integer): The file's size (in bytes)
41
- # * *file_name* (String): The file's exact file name
42
- # * *uploaded_time* (Time): The file's uploaded time
43
- # * *mod_version* (String): The file's mod version
44
- # * *external_virus_scan_url* (String): The URL of virus scan for this file
45
- # * *description* (String): The file's description
46
- # * *changelog_html* (String): The file's change log in HTML
47
- # * *content_preview_url* (String): URL to a JSON that gives info on the file's content
48
- def initialize(
49
- ids:,
50
- uid:,
51
- id:,
52
- name:,
53
- version:,
54
- category_id:,
55
- category_name:,
56
- is_primary:,
57
- size:,
58
- file_name:,
59
- uploaded_time:,
60
- mod_version:,
61
- external_virus_scan_url:,
62
- description:,
63
- changelog_html:,
64
- content_preview_url:
65
- )
66
- @ids = ids
67
- @uid = uid
68
- @id = id
69
- @name = name
70
- @version = version
71
- @category_id = category_id
72
- @category_name = category_name
73
- @is_primary = is_primary
74
- @size = size
75
- @file_name = file_name
76
- @uploaded_time = uploaded_time
77
- @mod_version = mod_version
78
- @external_virus_scan_url = external_virus_scan_url
79
- @description = description
80
- @changelog_html = changelog_html
81
- @content_preview_url = content_preview_url
82
- end
83
-
84
- end
85
-
86
- end
@@ -1,37 +0,0 @@
1
- class NexusMods
2
-
3
- # A user on NExusMods.
4
- # Mainly used for uploaders information.
5
- class User
6
-
7
- attr_reader(
8
- *%i[
9
- member_id
10
- member_group_id
11
- name
12
- profile_url
13
- ]
14
- )
15
-
16
- # Constructor
17
- #
18
- # Parameters::
19
- # * *member_id* (Integer): The user's member id
20
- # * *member_group_id* (Integer): The user's member group id
21
- # * *name* (String): The user's name
22
- # * *profile_url* (String): The user's profile URL
23
- def initialize(
24
- member_id:,
25
- member_group_id:,
26
- name:,
27
- profile_url:
28
- )
29
- @member_id = member_id
30
- @member_group_id = member_group_id
31
- @name = name
32
- @profile_url = profile_url
33
- end
34
-
35
- end
36
-
37
- end