nexus_mods 0.1.1 → 0.3.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/api_limits.rb +64 -0
- data/lib/nexus_mods/api/category.rb +54 -0
- data/lib/nexus_mods/api/game.rb +106 -0
- data/lib/nexus_mods/api/mod.rb +141 -0
- data/lib/nexus_mods/api/mod_file.rb +116 -0
- data/lib/nexus_mods/api/user.rb +55 -0
- data/lib/nexus_mods/api_client.rb +182 -0
- data/lib/nexus_mods/cacheable_api.rb +52 -0
- data/lib/nexus_mods/cacheable_with_expiry.rb +70 -0
- data/lib/nexus_mods/core_extensions/cacheable/cache_adapters/persistent_json_adapter.rb +62 -0
- data/lib/nexus_mods/core_extensions/cacheable/method_generator.rb +62 -0
- data/lib/nexus_mods/file_cache.rb +71 -0
- data/lib/nexus_mods/version.rb +1 -1
- data/lib/nexus_mods.rb +32 -86
- data/spec/nexus_mods_test/factories/games.rb +135 -0
- data/spec/nexus_mods_test/factories/mod_files.rb +113 -0
- data/spec/nexus_mods_test/factories/mods.rb +144 -0
- data/spec/nexus_mods_test/helpers.rb +39 -14
- data/spec/nexus_mods_test/scenarios/nexus_mods/{api_limits_spec.rb → api/api_limits_spec.rb} +10 -3
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/game_spec.rb +93 -0
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/mod_file_spec.rb +73 -0
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/mod_spec.rb +62 -0
- data/spec/nexus_mods_test/scenarios/nexus_mods_caching_spec.rb +88 -0
- metadata +37 -13
- data/lib/nexus_mods/api_limits.rb +0 -44
- data/lib/nexus_mods/category.rb +0 -37
- data/lib/nexus_mods/game.rb +0 -78
- data/lib/nexus_mods/mod.rb +0 -106
- data/lib/nexus_mods/mod_file.rb +0 -86
- data/lib/nexus_mods/user.rb +0 -37
- data/spec/nexus_mods_test/scenarios/nexus_mods/game_spec.rb +0 -180
- data/spec/nexus_mods_test/scenarios/nexus_mods/mod_file_spec.rb +0 -140
- data/spec/nexus_mods_test/scenarios/nexus_mods/mod_spec.rb +0 -185
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'digest'
|
2
2
|
require 'webmock/rspec'
|
3
3
|
require 'rspec/support/object_formatter'
|
4
|
+
require 'nexus_mods_test/factories/games'
|
5
|
+
require 'nexus_mods_test/factories/mods'
|
6
|
+
require 'nexus_mods_test/factories/mod_files'
|
4
7
|
require 'nexus_mods'
|
5
8
|
|
6
|
-
module
|
9
|
+
module NexusModsTest
|
7
10
|
|
8
11
|
module Helpers
|
9
12
|
|
@@ -72,6 +75,7 @@ module NexusModsTests
|
|
72
75
|
# * *message* (String): Mocked returned message [default: 'OK']
|
73
76
|
# * *json* (Object): Mocked JSON body [default: {}]
|
74
77
|
# * *headers* (Hash<String,String>): Mocked additional HTTP headers [default: {}]
|
78
|
+
# * *times* (Integer): Number of times the call is expected [default: 1]
|
75
79
|
def expect_http_call_to(
|
76
80
|
host: 'api.nexusmods.com',
|
77
81
|
http_method: :get,
|
@@ -80,7 +84,8 @@ module NexusModsTests
|
|
80
84
|
code: 200,
|
81
85
|
message: 'OK',
|
82
86
|
json: {},
|
83
|
-
headers: {}
|
87
|
+
headers: {},
|
88
|
+
times: 1
|
84
89
|
)
|
85
90
|
json_as_str = json.to_json
|
86
91
|
mocked_etag = "W/\"#{Digest::MD5.hexdigest("#{path}|#{json_as_str}")}\""
|
@@ -93,19 +98,25 @@ module NexusModsTests
|
|
93
98
|
else
|
94
99
|
@expected_returned_etags << mocked_etag
|
95
100
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
@expected_stubs << [
|
102
|
+
stub_request(http_method, "https://#{host}#{path}").with(headers: expected_request_headers).to_return(
|
103
|
+
status: [code, message],
|
104
|
+
body: json_as_str,
|
105
|
+
headers: DEFAULT_API_HEADERS.
|
106
|
+
merge(
|
107
|
+
'etag' => mocked_etag
|
108
|
+
).
|
109
|
+
merge(headers)
|
110
|
+
),
|
111
|
+
times
|
112
|
+
]
|
105
113
|
end
|
106
114
|
|
107
115
|
# Expect a successfull call made to validate the user
|
108
|
-
|
116
|
+
#
|
117
|
+
# Parameters::
|
118
|
+
# * *times* (Integer): Number of times the call is expected [default: 1]
|
119
|
+
def expect_validate_user(times: 1)
|
109
120
|
expect_http_call_to(
|
110
121
|
path: '/v1/users/validate.json',
|
111
122
|
json: {
|
@@ -118,7 +129,8 @@ module NexusModsTests
|
|
118
129
|
profile_url: 'https://www.nexusmods.com/Contents/Images/noavatar.gif',
|
119
130
|
is_supporter: false,
|
120
131
|
is_premium: false
|
121
|
-
}
|
132
|
+
},
|
133
|
+
times:
|
122
134
|
)
|
123
135
|
end
|
124
136
|
|
@@ -127,12 +139,25 @@ module NexusModsTests
|
|
127
139
|
end
|
128
140
|
|
129
141
|
RSpec.configure do |config|
|
130
|
-
config.include
|
142
|
+
config.include NexusModsTest::Helpers
|
143
|
+
config.include NexusModsTest::Factories::Games
|
144
|
+
config.include NexusModsTest::Factories::Mods
|
145
|
+
config.include NexusModsTest::Factories::ModFiles
|
131
146
|
config.before do
|
132
147
|
@nexus_mods = nil
|
148
|
+
# Reload the ApiClient as it stores caches at class level
|
149
|
+
NexusMods::ApiClient.clear_cacheable_expiry_caches
|
133
150
|
# Keep a list of the etags we should have returned, so that we know when queries should contain them
|
134
151
|
# Array<String>
|
135
152
|
@expected_returned_etags = []
|
153
|
+
# List of expected stubs and the number of times they were supposed to mock
|
154
|
+
# Array< [ WebMock::RequestStub, Integer ] >
|
155
|
+
@expected_stubs = []
|
156
|
+
end
|
157
|
+
config.after do
|
158
|
+
@expected_stubs.each do |(stub, times)|
|
159
|
+
expect(stub).to have_been_made.times(times)
|
160
|
+
end
|
136
161
|
end
|
137
162
|
end
|
138
163
|
|
data/spec/nexus_mods_test/scenarios/nexus_mods/{api_limits_spec.rb → api/api_limits_spec.rb}
RENAMED
@@ -1,10 +1,9 @@
|
|
1
|
-
describe NexusMods::ApiLimits do
|
1
|
+
describe NexusMods::Api::ApiLimits do
|
2
2
|
|
3
3
|
context 'when testing API limits' do
|
4
4
|
|
5
5
|
it 'gets api limits' do
|
6
|
-
expect_validate_user
|
7
|
-
expect_validate_user
|
6
|
+
expect_validate_user(times: 2)
|
8
7
|
api_limits = nexus_mods.api_limits
|
9
8
|
expect(api_limits.daily_limit).to eq 2500
|
10
9
|
expect(api_limits.daily_remaining).to eq 2500
|
@@ -14,6 +13,14 @@ describe NexusMods::ApiLimits do
|
|
14
13
|
expect(api_limits.hourly_reset).to eq Time.parse('2019-10-02T16:00:00+00:00')
|
15
14
|
end
|
16
15
|
|
16
|
+
it 'compares objects for equality' do
|
17
|
+
expect_validate_user(times: 3)
|
18
|
+
api_limits1 = nexus_mods.api_limits
|
19
|
+
api_limits2 = nexus_mods.api_limits
|
20
|
+
expect(api_limits1.object_id).not_to eq api_limits2.object_id
|
21
|
+
expect(api_limits1).to eq api_limits2
|
22
|
+
end
|
23
|
+
|
17
24
|
end
|
18
25
|
|
19
26
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
describe NexusMods::Api::Game do
|
2
|
+
|
3
|
+
context 'when testing games' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
expect_validate_user
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns the games list' do
|
10
|
+
expect_http_call_to(
|
11
|
+
path: '/v1/games.json',
|
12
|
+
json: [
|
13
|
+
json_game100,
|
14
|
+
json_game101
|
15
|
+
]
|
16
|
+
)
|
17
|
+
games = nexus_mods.games.sort_by(&:id)
|
18
|
+
expect(games.size).to eq 2
|
19
|
+
expect_game_to_be_game100(games.first)
|
20
|
+
expect_game_to_be_game101(games[1])
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns a game having missing parent category' do
|
24
|
+
expect_http_call_to(
|
25
|
+
path: '/v1/games.json',
|
26
|
+
json: [
|
27
|
+
{
|
28
|
+
'id' => 100,
|
29
|
+
'name' => 'Morrowind',
|
30
|
+
'forum_url' => 'https://forums.nexusmods.com/index.php?/forum/111-morrowind/',
|
31
|
+
'nexusmods_url' => 'http://www.nexusmods.com/morrowind',
|
32
|
+
'genre' => 'RPG',
|
33
|
+
'file_count' => 14_143,
|
34
|
+
'downloads' => 20_414_985,
|
35
|
+
'domain_name' => 'morrowind',
|
36
|
+
'approved_date' => 1,
|
37
|
+
'file_views' => 100_014_750,
|
38
|
+
'authors' => 2062,
|
39
|
+
'file_endorsements' => 719_262,
|
40
|
+
'mods' => 6080,
|
41
|
+
'categories' => [
|
42
|
+
{
|
43
|
+
'category_id' => 1,
|
44
|
+
'name' => 'Morrowind',
|
45
|
+
'parent_category' => false
|
46
|
+
},
|
47
|
+
{
|
48
|
+
'category_id' => 2,
|
49
|
+
'name' => 'Buildings',
|
50
|
+
'parent_category' => 3
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
]
|
55
|
+
)
|
56
|
+
game = nexus_mods.games.first
|
57
|
+
expect(game.id).to eq 100
|
58
|
+
expect(game.name).to eq 'Morrowind'
|
59
|
+
expect(game.forum_url).to eq 'https://forums.nexusmods.com/index.php?/forum/111-morrowind/'
|
60
|
+
expect(game.nexusmods_url).to eq 'http://www.nexusmods.com/morrowind'
|
61
|
+
expect(game.genre).to eq 'RPG'
|
62
|
+
expect(game.files_count).to eq 14_143
|
63
|
+
expect(game.downloads_count).to eq 20_414_985
|
64
|
+
expect(game.domain_name).to eq 'morrowind'
|
65
|
+
expect(game.approved_date).to eq Time.parse('1970-01-01 00:00:01 +0000')
|
66
|
+
expect(game.files_views).to eq 100_014_750
|
67
|
+
expect(game.authors_count).to eq 2062
|
68
|
+
expect(game.files_endorsements).to eq 719_262
|
69
|
+
expect(game.mods_count).to eq 6080
|
70
|
+
game_categories = game.categories
|
71
|
+
expect(game_categories.size).to eq 2
|
72
|
+
expect(game_categories.first.id).to eq 1
|
73
|
+
expect(game_categories.first.name).to eq 'Morrowind'
|
74
|
+
expect(game_categories.first.parent_category).to be_nil
|
75
|
+
expect(game_categories[1].id).to eq 2
|
76
|
+
expect(game_categories[1].name).to eq 'Buildings'
|
77
|
+
expect(game_categories[1].parent_category).to be_nil
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'compares objects for equality' do
|
81
|
+
expect_http_call_to(
|
82
|
+
path: '/v1/games.json',
|
83
|
+
json: [json_game100]
|
84
|
+
)
|
85
|
+
game1 = nexus_mods.games.first
|
86
|
+
game2 = nexus_mods.games.first
|
87
|
+
expect(game1.object_id).not_to eq game2.object_id
|
88
|
+
expect(game1).to eq game2
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -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
|
@@ -0,0 +1,88 @@
|
|
1
|
+
describe NexusMods do
|
2
|
+
|
3
|
+
context 'when testing caching' do
|
4
|
+
|
5
|
+
it 'does not cache user queries' do
|
6
|
+
expect_validate_user(times: 3)
|
7
|
+
nexus_mods.api_limits
|
8
|
+
nexus_mods.api_limits
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'caches games queries' do
|
12
|
+
expect_validate_user
|
13
|
+
expect_http_call_to(
|
14
|
+
path: '/v1/games.json',
|
15
|
+
json: [
|
16
|
+
json_game100,
|
17
|
+
json_game101
|
18
|
+
]
|
19
|
+
)
|
20
|
+
games = nexus_mods.games
|
21
|
+
expect(nexus_mods.games).to eq(games)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'caches mod queries' do
|
25
|
+
expect_validate_user
|
26
|
+
expect_http_call_to(
|
27
|
+
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|
28
|
+
json: json_complete_mod
|
29
|
+
)
|
30
|
+
mod = nexus_mods.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014)
|
31
|
+
expect(nexus_mods.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014)).to eq(mod)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'caches mod files queries' do
|
35
|
+
expect_validate_user
|
36
|
+
expect_http_call_to(
|
37
|
+
path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
|
38
|
+
json: { files: [json_mod_file2472, json_mod_file2487] }
|
39
|
+
)
|
40
|
+
mod_files = nexus_mods.mod_files(game_domain_name: 'skyrimspecialedition', mod_id: 2014)
|
41
|
+
expect(nexus_mods.mod_files(game_domain_name: 'skyrimspecialedition', mod_id: 2014)).to eq(mod_files)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'expires games queries cache' do
|
45
|
+
expect_validate_user
|
46
|
+
expect_http_call_to(
|
47
|
+
path: '/v1/games.json',
|
48
|
+
json: [
|
49
|
+
json_game100,
|
50
|
+
json_game101
|
51
|
+
],
|
52
|
+
times: 2
|
53
|
+
)
|
54
|
+
nexus_mods_instance = nexus_mods(api_cache_expiry: { games: 1 })
|
55
|
+
games = nexus_mods_instance.games
|
56
|
+
sleep 2
|
57
|
+
expect(nexus_mods_instance.games).to eq(games)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'expires mod queries cache' do
|
61
|
+
expect_validate_user
|
62
|
+
expect_http_call_to(
|
63
|
+
path: '/v1/games/skyrimspecialedition/mods/2014.json',
|
64
|
+
json: json_complete_mod,
|
65
|
+
times: 2
|
66
|
+
)
|
67
|
+
nexus_mods_instance = nexus_mods(api_cache_expiry: { mod: 1 })
|
68
|
+
mod = nexus_mods_instance.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014)
|
69
|
+
sleep 2
|
70
|
+
expect(nexus_mods_instance.mod(game_domain_name: 'skyrimspecialedition', mod_id: 2014)).to eq(mod)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'expires mod files queries cache' do
|
74
|
+
expect_validate_user
|
75
|
+
expect_http_call_to(
|
76
|
+
path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
|
77
|
+
json: { files: [json_mod_file2472, json_mod_file2487] },
|
78
|
+
times: 2
|
79
|
+
)
|
80
|
+
nexus_mods_instance = nexus_mods(api_cache_expiry: { mod_files: 1 })
|
81
|
+
mod_files = nexus_mods_instance.mod_files(game_domain_name: 'skyrimspecialedition', mod_id: 2014)
|
82
|
+
sleep 2
|
83
|
+
expect(nexus_mods_instance.mod_files(game_domain_name: 'skyrimspecialedition', mod_id: 2014)).to eq(mod_files)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cacheable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,19 +136,29 @@ files:
|
|
122
136
|
- LICENSE.md
|
123
137
|
- README.md
|
124
138
|
- 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
|
139
|
+
- lib/nexus_mods/api/api_limits.rb
|
140
|
+
- lib/nexus_mods/api/category.rb
|
141
|
+
- lib/nexus_mods/api/game.rb
|
142
|
+
- lib/nexus_mods/api/mod.rb
|
143
|
+
- lib/nexus_mods/api/mod_file.rb
|
144
|
+
- lib/nexus_mods/api/user.rb
|
145
|
+
- lib/nexus_mods/api_client.rb
|
146
|
+
- lib/nexus_mods/cacheable_api.rb
|
147
|
+
- lib/nexus_mods/cacheable_with_expiry.rb
|
148
|
+
- lib/nexus_mods/core_extensions/cacheable/cache_adapters/persistent_json_adapter.rb
|
149
|
+
- lib/nexus_mods/core_extensions/cacheable/method_generator.rb
|
150
|
+
- lib/nexus_mods/file_cache.rb
|
131
151
|
- lib/nexus_mods/version.rb
|
152
|
+
- spec/nexus_mods_test/factories/games.rb
|
153
|
+
- spec/nexus_mods_test/factories/mod_files.rb
|
154
|
+
- spec/nexus_mods_test/factories/mods.rb
|
132
155
|
- 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
|
156
|
+
- spec/nexus_mods_test/scenarios/nexus_mods/api/api_limits_spec.rb
|
157
|
+
- spec/nexus_mods_test/scenarios/nexus_mods/api/game_spec.rb
|
158
|
+
- spec/nexus_mods_test/scenarios/nexus_mods/api/mod_file_spec.rb
|
159
|
+
- spec/nexus_mods_test/scenarios/nexus_mods/api/mod_spec.rb
|
137
160
|
- spec/nexus_mods_test/scenarios/nexus_mods_access_spec.rb
|
161
|
+
- spec/nexus_mods_test/scenarios/nexus_mods_caching_spec.rb
|
138
162
|
- spec/nexus_mods_test/scenarios/rubocop_spec.rb
|
139
163
|
- spec/spec_helper.rb
|
140
164
|
homepage: https://github.com/Muriel-Salvan/nexus_mods
|
@@ -158,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
182
|
- !ruby/object:Gem::Version
|
159
183
|
version: '0'
|
160
184
|
requirements: []
|
161
|
-
rubygems_version: 3.4.
|
185
|
+
rubygems_version: 3.4.10
|
162
186
|
signing_key:
|
163
187
|
specification_version: 4
|
164
188
|
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
|
data/lib/nexus_mods/category.rb
DELETED
@@ -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
|