thegamesdb 1.1.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +26 -0
- data/.github/workflows/rubocop.yml +20 -0
- data/.rubocop.yml +39 -0
- data/CHANGELOG.md +49 -0
- data/Gemfile +2 -0
- data/README.md +313 -52
- data/Rakefile +3 -0
- data/lib/thegamesdb/developers.rb +17 -0
- data/lib/thegamesdb/error.rb +12 -0
- data/lib/thegamesdb/games.rb +130 -0
- data/lib/thegamesdb/genres.rb +13 -0
- data/lib/thegamesdb/images.rb +7 -0
- data/lib/thegamesdb/platforms.rb +106 -0
- data/lib/thegamesdb/publishers.rb +15 -0
- data/lib/thegamesdb/utils.rb +66 -0
- data/lib/thegamesdb/version.rb +3 -1
- data/lib/thegamesdb.rb +78 -226
- data/test/client_test.rb +26 -0
- data/test/developers_test.rb +16 -0
- data/test/games_test.rb +92 -42
- data/test/genres_test.rb +16 -0
- data/test/platform_test.rb +85 -51
- data/test/publishers_test.rb +16 -0
- data/test/test_helper.rb +3 -2
- data/thegamesdb.gemspec +14 -9
- metadata +25 -8
- data/.travis.yml +0 -24
- data/lib/thegamesdb/config.rb +0 -9
data/test/platform_test.rb
CHANGED
@@ -1,113 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './test_helper'
|
2
4
|
|
3
5
|
describe 'GamesDB - platforms', :vcr do
|
6
|
+
let(:client) { Gamesdb::Client.new(ENV['GAMESDB_API_KEY']) }
|
7
|
+
|
4
8
|
describe 'platforms' do
|
5
9
|
before do
|
6
|
-
@platforms =
|
10
|
+
@platforms = client.platforms
|
7
11
|
end
|
8
12
|
|
9
13
|
it 'should get gaming platforms' do
|
10
|
-
@platforms.count.wont_be :<, 0
|
11
|
-
@platforms.count.must_equal
|
14
|
+
expect(@platforms.count).wont_be :<, 0
|
15
|
+
expect(@platforms.count).must_equal 147
|
12
16
|
end
|
13
17
|
|
14
18
|
it 'should have a valid name' do
|
15
|
-
@platforms[0][:name].must_be_kind_of String
|
19
|
+
expect(@platforms[0][:name]).must_be_kind_of String
|
16
20
|
end
|
17
21
|
|
18
22
|
it 'should have a valid id' do
|
19
|
-
@platforms[0][:id].must_be_kind_of Integer
|
23
|
+
expect(@platforms[0][:id]).must_be_kind_of Integer
|
20
24
|
end
|
21
25
|
|
22
26
|
it 'should have a valid alias' do
|
23
|
-
@platforms[0][:alias].must_be_kind_of String
|
27
|
+
expect(@platforms[0][:alias]).must_be_kind_of String
|
24
28
|
end
|
25
29
|
|
26
30
|
it 'should have valid fields for other stuff' do
|
27
31
|
nes = @platforms.select { |p| p[:id] == 7 }.first
|
28
|
-
nes[:icon].must_be_kind_of String
|
29
|
-
nes[:console].must_be_kind_of String
|
30
|
-
nes[:controller].must_be_kind_of String
|
31
|
-
nes[:developer].must_be_kind_of String
|
32
|
-
nes[:manufacturer].must_be_kind_of String
|
33
|
-
nes[:maxcontrollers].must_be_kind_of String
|
34
|
-
nes[:cpu].must_be_kind_of String
|
35
|
-
nes[:memory].must_be_kind_of String
|
36
|
-
nes[:sound].must_be_kind_of String
|
37
|
-
nes[:display].must_be_kind_of String
|
38
|
-
nes[:overview].must_be_kind_of String
|
32
|
+
expect(nes[:icon]).must_be_kind_of String
|
33
|
+
expect(nes[:console]).must_be_kind_of String
|
34
|
+
expect(nes[:controller]).must_be_kind_of String
|
35
|
+
expect(nes[:developer]).must_be_kind_of String
|
36
|
+
expect(nes[:manufacturer]).must_be_kind_of String
|
37
|
+
expect(nes[:maxcontrollers]).must_be_kind_of String
|
38
|
+
expect(nes[:cpu]).must_be_kind_of String
|
39
|
+
expect(nes[:memory]).must_be_kind_of String
|
40
|
+
expect(nes[:sound]).must_be_kind_of String
|
41
|
+
expect(nes[:display]).must_be_kind_of String
|
42
|
+
expect(nes[:overview]).must_be_kind_of String
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
46
|
describe 'games by platform' do
|
43
47
|
before do
|
44
|
-
platforms =
|
45
|
-
@first_page =
|
46
|
-
@second_page =
|
48
|
+
platforms = client.platforms
|
49
|
+
@first_page = client.games_by_platform_id(platforms[0][:id])
|
50
|
+
@second_page = client.games_by_platform_id(platforms[0][:id], 2)
|
47
51
|
end
|
48
52
|
|
49
53
|
it 'should return games in platform by id' do
|
50
|
-
@first_page.count.wont_be :<, 0
|
51
|
-
@first_page.count.must_equal 20
|
54
|
+
expect(@first_page.count).wont_be :<, 0
|
55
|
+
expect(@first_page.count).must_equal 20
|
52
56
|
end
|
53
57
|
|
54
58
|
it 'should return games in the platform for the second page' do
|
55
|
-
@second_page.count.wont_be :<, 0
|
56
|
-
@second_page.count.must_equal 20
|
57
|
-
(@first_page & @second_page).must_equal []
|
59
|
+
expect(@second_page.count).wont_be :<, 0
|
60
|
+
expect(@second_page.count).must_equal 20
|
61
|
+
expect(@first_page & @second_page).must_equal []
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
65
|
describe 'games by platform parameters' do
|
62
66
|
before do
|
63
|
-
@games1 =
|
64
|
-
@games2 =
|
65
|
-
@games3 =
|
67
|
+
@games1 = client.games_by_platform_id(4950)
|
68
|
+
@games2 = client.games_by_platform_id(4948)
|
69
|
+
@games3 = client.games_by_platform_id('4950,4948')
|
66
70
|
end
|
67
71
|
|
68
72
|
it 'supports comma separated list' do
|
69
|
-
@games1.count.must_equal 20
|
70
|
-
@games2.count.must_equal
|
71
|
-
@games3.count.must_equal 20
|
73
|
+
expect(@games1.count).must_equal 20
|
74
|
+
expect(@games2.count).must_equal 20
|
75
|
+
expect(@games3.count).must_equal 20
|
72
76
|
|
73
|
-
(@games3 - @games1).must_equal @games2
|
77
|
+
expect(@games3 - @games1).must_equal @games2
|
74
78
|
end
|
75
|
-
|
76
79
|
end
|
77
80
|
|
78
81
|
describe 'platform' do
|
79
82
|
describe 'assigning basic info' do
|
80
83
|
before do
|
81
|
-
@platform =
|
84
|
+
@platform = client.platforms_by_id(6)
|
82
85
|
end
|
83
86
|
|
84
87
|
it 'should return valid platform info' do
|
85
|
-
@platform[:name].must_equal 'Super Nintendo (SNES)'
|
86
|
-
@platform[:overview].must_be_kind_of String
|
87
|
-
@platform[:developer].must_be_kind_of String
|
88
|
-
@platform[:manufacturer].must_equal 'Nintendo'
|
89
|
-
@platform[:cpu].must_be_kind_of String
|
90
|
-
@platform[:memory].must_be_kind_of String
|
91
|
-
@platform[:sound].must_be_kind_of String
|
92
|
-
@platform[:display].must_be_kind_of String
|
88
|
+
expect(@platform[:name]).must_equal 'Super Nintendo (SNES)'
|
89
|
+
expect(@platform[:overview]).must_be_kind_of String
|
90
|
+
expect(@platform[:developer]).must_be_kind_of String
|
91
|
+
expect(@platform[:manufacturer]).must_equal 'Nintendo'
|
92
|
+
expect(@platform[:cpu]).must_be_kind_of String
|
93
|
+
expect(@platform[:memory]).must_be_kind_of String
|
94
|
+
expect(@platform[:sound]).must_be_kind_of String
|
95
|
+
expect(@platform[:display]).must_be_kind_of String
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
96
99
|
describe 'without hardware or images' do
|
97
100
|
before do
|
98
|
-
@platform =
|
101
|
+
@platform = client.platforms_by_id(4916)
|
99
102
|
end
|
100
103
|
|
101
104
|
it 'should return valid platform info' do
|
102
|
-
@platform[:name].must_equal 'Android'
|
103
|
-
@platform[:overview].must_be_kind_of String
|
104
|
-
@platform[:developer].must_be_kind_of String
|
105
|
-
@platform[:manufacturer].must_be_nil
|
106
|
-
@platform[:cpu].must_be_nil
|
107
|
-
@platform[:memory].must_be_nil
|
108
|
-
@platform[:sound].must_be_nil
|
109
|
-
@platform[:display].must_be_nil
|
105
|
+
expect(@platform[:name]).must_equal 'Android'
|
106
|
+
expect(@platform[:overview]).must_be_kind_of String
|
107
|
+
expect(@platform[:developer]).must_be_kind_of String
|
108
|
+
expect(@platform[:manufacturer]).must_be_nil
|
109
|
+
expect(@platform[:cpu]).must_be_nil
|
110
|
+
expect(@platform[:memory]).must_be_nil
|
111
|
+
expect(@platform[:sound]).must_be_nil
|
112
|
+
expect(@platform[:display]).must_be_nil
|
110
113
|
end
|
111
114
|
end
|
112
115
|
end
|
116
|
+
|
117
|
+
describe 'platforms by name' do
|
118
|
+
it 'should return platforms' do
|
119
|
+
@platforms = client.platforms_by_name('Nintendo')
|
120
|
+
|
121
|
+
expect(@platforms.count).must_equal 14
|
122
|
+
names = @platforms.sort_by { |p| p[:name] }.map { |p| p[:name] }
|
123
|
+
expect(names).must_equal [
|
124
|
+
'Nintendo 3DS', 'Nintendo 64', 'Nintendo DS', 'Nintendo Entertainment System (NES)',
|
125
|
+
'Nintendo Game Boy', 'Nintendo Game Boy Advance', 'Nintendo Game Boy Color', 'Nintendo GameCube',
|
126
|
+
'Nintendo Pokémon Mini', 'Nintendo Switch', 'Nintendo Virtual Boy', 'Nintendo Wii', 'Nintendo Wii U',
|
127
|
+
'Super Nintendo (SNES)'
|
128
|
+
]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'platform images' do
|
133
|
+
it 'should return all images for a platform' do
|
134
|
+
@images = client.platform_images(7)
|
135
|
+
|
136
|
+
expect(@images.count).must_equal(10)
|
137
|
+
expect(@images.first.keys).must_equal(['id', 'type', 'filename'])
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should filter image type for a platform' do
|
141
|
+
@images = client.platform_images(7, type: 'boxart')
|
142
|
+
|
143
|
+
expect(@images.count).must_equal(1)
|
144
|
+
expect(@images.first).must_equal({ 'id' => 222, 'type' => 'boxart', 'filename' => 'platform/boxart/7-2.jpg' })
|
145
|
+
end
|
146
|
+
end
|
113
147
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './test_helper'
|
4
|
+
|
5
|
+
describe 'GamesDB - Publishers', :vcr do
|
6
|
+
let(:client) { Gamesdb::Client.new(ENV['GAMESDB_API_KEY']) }
|
7
|
+
|
8
|
+
describe 'publishers' do
|
9
|
+
it 'should return publishers' do
|
10
|
+
publishers = client.publishers
|
11
|
+
|
12
|
+
expect(publishers.count.positive?)
|
13
|
+
expect(publishers.first.keys).must_equal(['id', 'name'])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'minitest/reporters'
|
5
5
|
require 'minitest/spec'
|
6
6
|
require 'vcr'
|
7
7
|
require 'minitest-vcr'
|
8
|
+
|
8
9
|
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
9
10
|
MinitestVcr::Spec.configure!
|
10
11
|
|
data/thegamesdb.gemspec
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require 'thegamesdb/version'
|
5
7
|
|
8
|
+
# rubocop:disable Metrics/BlockLength
|
6
9
|
Gem::Specification.new do |spec|
|
7
10
|
spec.name = 'thegamesdb'
|
8
11
|
spec.version = Gamesdb::VERSION
|
@@ -13,23 +16,25 @@ Gem::Specification.new do |spec|
|
|
13
16
|
spec.homepage = 'http://github.com/picandocodigo/gamesdb'
|
14
17
|
spec.license = 'MIT'
|
15
18
|
|
16
|
-
spec.files = `git ls-files`.split(
|
19
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
22
|
spec.require_paths = ['lib']
|
23
|
+
spec.required_ruby_version = '> 2.7.0'
|
20
24
|
spec.add_development_dependency 'bundler'
|
21
|
-
spec.add_development_dependency 'byebug'
|
25
|
+
spec.add_development_dependency 'byebug' unless defined?(JRUBY_VERSION)
|
22
26
|
spec.add_development_dependency 'minitest-reporters'
|
23
27
|
spec.add_development_dependency 'minitest-vcr'
|
24
28
|
spec.add_development_dependency 'rake'
|
25
|
-
spec.add_development_dependency '
|
29
|
+
spec.add_development_dependency 'rubocop'
|
26
30
|
spec.add_development_dependency 'vcr', '~> 4'
|
27
31
|
spec.add_development_dependency 'webmock'
|
28
|
-
spec.metadata
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
spec.metadata = {
|
33
|
+
'bug_tracker_uri' => 'https://github.com/picandocodigo/gamesdb/issues',
|
34
|
+
'changelog_uri' => 'https://github.com/picandocodigo/gamesdb/blob/master/CHANGELOG.md',
|
35
|
+
'documentation_uri' => 'https://github.com/picandocodigo/gamesdb/blob/master/README.md#gamesdb',
|
36
|
+
'homepage_uri' => 'https://github.com/picandocodigo/gamesdb',
|
37
|
+
'source_code_uri' => 'https://github.com/picandocodigo/gamesdb'
|
34
38
|
}
|
35
39
|
end
|
40
|
+
# rubocop:enable Metrics/BlockLength
|
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:
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Briano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -129,18 +129,31 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".github/workflows/main.yml"
|
133
|
+
- ".github/workflows/rubocop.yml"
|
132
134
|
- ".gitignore"
|
133
|
-
- ".
|
135
|
+
- ".rubocop.yml"
|
134
136
|
- CHANGELOG.md
|
135
137
|
- Gemfile
|
136
138
|
- LICENSE.txt
|
137
139
|
- README.md
|
138
140
|
- Rakefile
|
139
141
|
- lib/thegamesdb.rb
|
140
|
-
- lib/thegamesdb/
|
142
|
+
- lib/thegamesdb/developers.rb
|
143
|
+
- lib/thegamesdb/error.rb
|
144
|
+
- lib/thegamesdb/games.rb
|
145
|
+
- lib/thegamesdb/genres.rb
|
146
|
+
- lib/thegamesdb/images.rb
|
147
|
+
- lib/thegamesdb/platforms.rb
|
148
|
+
- lib/thegamesdb/publishers.rb
|
149
|
+
- lib/thegamesdb/utils.rb
|
141
150
|
- lib/thegamesdb/version.rb
|
151
|
+
- test/client_test.rb
|
152
|
+
- test/developers_test.rb
|
142
153
|
- test/games_test.rb
|
154
|
+
- test/genres_test.rb
|
143
155
|
- test/platform_test.rb
|
156
|
+
- test/publishers_test.rb
|
144
157
|
- test/test_helper.rb
|
145
158
|
- thegamesdb.gemspec
|
146
159
|
homepage: http://github.com/picandocodigo/gamesdb
|
@@ -158,20 +171,24 @@ require_paths:
|
|
158
171
|
- lib
|
159
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
173
|
requirements:
|
161
|
-
- - "
|
174
|
+
- - ">"
|
162
175
|
- !ruby/object:Gem::Version
|
163
|
-
version:
|
176
|
+
version: 2.7.0
|
164
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
178
|
requirements:
|
166
179
|
- - ">="
|
167
180
|
- !ruby/object:Gem::Version
|
168
181
|
version: '0'
|
169
182
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
183
|
+
rubygems_version: 3.3.7
|
171
184
|
signing_key:
|
172
185
|
specification_version: 4
|
173
186
|
summary: Client for TheGamesDB API (thegamesdb.net).
|
174
187
|
test_files:
|
188
|
+
- test/client_test.rb
|
189
|
+
- test/developers_test.rb
|
175
190
|
- test/games_test.rb
|
191
|
+
- test/genres_test.rb
|
176
192
|
- test/platform_test.rb
|
193
|
+
- test/publishers_test.rb
|
177
194
|
- test/test_helper.rb
|
data/.travis.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
env:
|
2
|
-
global:
|
3
|
-
- CC_TEST_REPORTER_ID=3ca09808c18a3fb0a12a7b113aeca064acf88831f8a36ee2e9fda89ca37b0650
|
4
|
-
language: ruby
|
5
|
-
rvm:
|
6
|
-
- 2.3.8
|
7
|
-
- 2.4.9
|
8
|
-
- 2.5.7
|
9
|
-
- 2.6.5
|
10
|
-
- 2.7.0
|
11
|
-
- truffleruby
|
12
|
-
- ruby-head
|
13
|
-
install: bundle install
|
14
|
-
before_script:
|
15
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
-
- chmod +x ./cc-test-reporter
|
17
|
-
- ./cc-test-reporter before-build
|
18
|
-
script:
|
19
|
-
- bundle exec rake test
|
20
|
-
after_script:
|
21
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
22
|
-
allow_failures:
|
23
|
-
- rvm: ruby-head
|
24
|
-
- rvm: truffleruby
|