thegamesdb 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/thegamesdb.rb +39 -14
- data/lib/thegamesdb/version.rb +1 -1
- data/test/games_test.rb +34 -1
- data/test/platform_test.rb +1 -2
- data/thegamesdb.gemspec +7 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 477e3d9d2b073a86b77e82e6032a49f7c196e9eb9493ddbe233d5d1a569a4a95
|
4
|
+
data.tar.gz: 968a97e6b32aa648e40c443aca798c80eae9bec40275a350a2e762215a78fbcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6a757afd1711766e6de821fd4f7470751ba757e2b001db9ed013619ea106d7ac02ffd29f151324469cb474f58e019e585a983c448fc4165bffbb7fcf1768835
|
7
|
+
data.tar.gz: 90a01c2548018e0c3f6366bf13494fe67d9425e3230ec893684fb9ec09ad2ccb32fef56e578dc74a783fe942dc59669670e23f92cbedf9b633e5a783c127a140
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.1.1
|
4
|
+
* Adds `platform_id` parameter to `games_by_name`
|
5
|
+
* Adds `page` parameter to `games_by_name`
|
6
|
+
* Adds extra fields and boxart to `games_by_name` response
|
7
|
+
* Refactors `process_platform_games`
|
8
|
+
|
3
9
|
## 1.1.0
|
4
10
|
* Adds `page` parameter to `games_by_platform_id` and includes `boxart`.
|
5
11
|
* Adds all available fields from Platforms in `platforms`, updates tests. Changes `:slug` to `:alias` in platforms response, to map to same response from API.
|
6
12
|
* Refactored `json_response` to use `includes` and extra data from the API response.
|
7
13
|
|
8
|
-
|
9
14
|
## 1.0.0
|
10
15
|
|
11
16
|
* Updated to new API endpoint, API key is now required to use the gem. Request an API Key here: https://forums.thegamesdb.net/viewforum.php?f=10
|
data/lib/thegamesdb.rb
CHANGED
@@ -9,6 +9,7 @@ module Gamesdb
|
|
9
9
|
IMAGES_BASE_URL = 'https://legacy.thegamesdb.net/banners/'.freeze
|
10
10
|
|
11
11
|
# Method for listing platform's games
|
12
|
+
# TODO: check (and test) that we support ',' delimited list
|
12
13
|
# https://api.thegamesdb.net/#/operations/Games/GamesByPlatformID
|
13
14
|
#
|
14
15
|
# Parameters: platform id (int), page (int)
|
@@ -64,7 +65,7 @@ module Gamesdb
|
|
64
65
|
end
|
65
66
|
|
66
67
|
# Method for getting game info
|
67
|
-
# TODO:
|
68
|
+
# TODO: check (and test) that we support ',' delimited list
|
68
69
|
# https://api.thegamesdb.net/#/operations/Games/GamesByGameID
|
69
70
|
#
|
70
71
|
# Parameters:
|
@@ -91,15 +92,27 @@ module Gamesdb
|
|
91
92
|
#
|
92
93
|
# Parameters:
|
93
94
|
# - name (required)
|
95
|
+
# - platform (optional - platform id)
|
96
|
+
# - page (optional)
|
94
97
|
#
|
95
98
|
# == Returns:
|
96
99
|
# Hash with game info: id, name (not-unique), release_date,
|
97
|
-
# platform
|
100
|
+
# platform, etc.
|
98
101
|
#
|
99
|
-
def self.games_by_name(name)
|
102
|
+
def self.games_by_name(name, platform: nil, page: 1)
|
100
103
|
url = 'Games/ByGameName'
|
101
|
-
|
102
|
-
|
104
|
+
params = {
|
105
|
+
fields: 'players,publishers,genres,overview,last_updated,rating,platform,coop,youtube,os,processor,ram,hdd,video,sound,alternates',
|
106
|
+
include: 'boxart',
|
107
|
+
name: name,
|
108
|
+
page: page
|
109
|
+
}
|
110
|
+
unless platform.nil?
|
111
|
+
params.merge!("filter[platform]" => platform)
|
112
|
+
end
|
113
|
+
|
114
|
+
data = json_response(url, params)
|
115
|
+
process_platform_games(data)
|
103
116
|
end
|
104
117
|
|
105
118
|
# This API feature returns a list of available artwork types and
|
@@ -119,7 +132,7 @@ module Gamesdb
|
|
119
132
|
def self.game_images(id)
|
120
133
|
url = 'Games/Images'
|
121
134
|
data = json_response(url, games_id: id)
|
122
|
-
return [] if data
|
135
|
+
return [] if data.dig('data', 'count') == (0 || nil)
|
123
136
|
|
124
137
|
response = {}
|
125
138
|
response[:base_url] = data['data']['base_url']['original']
|
@@ -199,15 +212,27 @@ module Gamesdb
|
|
199
212
|
games = []
|
200
213
|
|
201
214
|
data['data']['games'].each do |elem|
|
202
|
-
name = elem['game_title']
|
203
215
|
id = elem['id']
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
216
|
+
games << {
|
217
|
+
name: elem['game_title'],
|
218
|
+
id: id,
|
219
|
+
release_date: elem['release_date'],
|
220
|
+
platform: elem['platform'],
|
221
|
+
developers: elem['developers'],
|
222
|
+
players: elem['players'],
|
223
|
+
publishers: elem['publishers'],
|
224
|
+
genres: elem['genres'],
|
225
|
+
overview: elem['overview'],
|
226
|
+
last_updated: elem['last_updated'],
|
227
|
+
rating: elem['rating'],
|
228
|
+
coop: elem['coop'],
|
229
|
+
youtube: elem['youtube'],
|
230
|
+
alternates: elem['alternates'],
|
231
|
+
image: if boxart = data.dig('include', 'boxart', 'data', id.to_s)
|
232
|
+
data['include']['boxart']['base_url']['original'] +
|
233
|
+
boxart.select { |a| a['side'] == 'front' }.first['filename'] || ''
|
234
|
+
end
|
235
|
+
}
|
211
236
|
end
|
212
237
|
games
|
213
238
|
end
|
data/lib/thegamesdb/version.rb
CHANGED
data/test/games_test.rb
CHANGED
@@ -35,12 +35,45 @@ describe 'Gamesdb - games', :vcr do
|
|
35
35
|
it 'should return a list' do
|
36
36
|
game = @games_list.first
|
37
37
|
game[:id].must_be_kind_of Integer
|
38
|
-
game[:
|
38
|
+
game[:name].must_be_kind_of String
|
39
39
|
game[:platform].must_be_kind_of Integer
|
40
40
|
game[:release_date].must_be_kind_of String
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
describe 'games by name pages' do
|
45
|
+
before do
|
46
|
+
@first_page = Gamesdb.games_by_name('mario', page: 1)
|
47
|
+
@second_page = Gamesdb.games_by_name('mario', page: 2)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should return games in platform by id' do
|
51
|
+
@first_page.count.wont_be :<, 0
|
52
|
+
@first_page.count.must_equal 20
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should return games in the platform for the second page' do
|
56
|
+
@second_page.count.wont_be :<, 0
|
57
|
+
@second_page.count.must_equal 20
|
58
|
+
(@first_page & @second_page).must_equal []
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'games by name and platform' do
|
63
|
+
before do
|
64
|
+
@games_list = Gamesdb.games_by_name('mario', platform: 7)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should return a list' do
|
68
|
+
@games_list.each do |game|
|
69
|
+
game[:id].must_be_kind_of Integer
|
70
|
+
game[:id].must_be_kind_of Integer
|
71
|
+
game[:name].must_be_kind_of String
|
72
|
+
game[:platform].must_equal 7
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
44
77
|
describe 'games art', :vcr do
|
45
78
|
describe 'when most of the art is available' do
|
46
79
|
before do
|
data/test/platform_test.rb
CHANGED
@@ -39,7 +39,7 @@ describe 'GamesDB - platforms', :vcr do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe 'platform_games' do
|
42
|
+
describe 'platform_games pages' do
|
43
43
|
before do
|
44
44
|
platforms = Gamesdb.platforms
|
45
45
|
@first_page = Gamesdb.games_by_platform_id(platforms[0][:id])
|
@@ -56,7 +56,6 @@ describe 'GamesDB - platforms', :vcr do
|
|
56
56
|
@second_page.count.must_equal 20
|
57
57
|
(@first_page & @second_page).must_equal []
|
58
58
|
end
|
59
|
-
|
60
59
|
end
|
61
60
|
|
62
61
|
describe 'platform' do
|
data/thegamesdb.gemspec
CHANGED
@@ -25,4 +25,11 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'simplecov'
|
26
26
|
spec.add_development_dependency 'vcr', '~> 4'
|
27
27
|
spec.add_development_dependency 'webmock'
|
28
|
+
spec.metadata = {
|
29
|
+
"bug_tracker_uri" => "https://github.com/picandocodigo/gamesdb/issues",
|
30
|
+
"changelog_uri" => "https://github.com/picandocodigo/gamesdb/blob/master/CHANGELOG.md",
|
31
|
+
"documentation_uri" => "https://github.com/picandocodigo/gamesdb/blob/master/README.md#gamesdb",
|
32
|
+
"homepage_uri" => "https://github.com/picandocodigo/gamesdb",
|
33
|
+
"source_code_uri" => "https://github.com/picandocodigo/gamesdb",
|
34
|
+
}
|
28
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thegamesdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Briano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,7 +146,12 @@ files:
|
|
146
146
|
homepage: http://github.com/picandocodigo/gamesdb
|
147
147
|
licenses:
|
148
148
|
- MIT
|
149
|
-
metadata:
|
149
|
+
metadata:
|
150
|
+
bug_tracker_uri: https://github.com/picandocodigo/gamesdb/issues
|
151
|
+
changelog_uri: https://github.com/picandocodigo/gamesdb/blob/master/CHANGELOG.md
|
152
|
+
documentation_uri: https://github.com/picandocodigo/gamesdb/blob/master/README.md#gamesdb
|
153
|
+
homepage_uri: https://github.com/picandocodigo/gamesdb
|
154
|
+
source_code_uri: https://github.com/picandocodigo/gamesdb
|
150
155
|
post_install_message:
|
151
156
|
rdoc_options: []
|
152
157
|
require_paths:
|