thegamesdb 0.2.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: d98f6062fe9aeb46eaa145ae984dddde93598e658527ca7fb97cc407fed5c5f5
4
- data.tar.gz: ea3afe6ed630d5cdda83f8d5e62eafe08ef0c4bf08cd2f74f2f3c9ea1a599963
3
+ metadata.gz: 91d3d0b45cd2e27b775840b9e21ca69ac31eff3425da1c20087cd92ff7185037
4
+ data.tar.gz: d53c14fa8fdfca34ea4f0284712ad330a56cc3daa3b1a2657aec46a5387bd47c
5
5
  SHA512:
6
- metadata.gz: e6b20ed995691fe0ef6f4b50994a2b78c521400d8ba04366a03e7675adda0bebc290aa12f7d8f9ae68ec6c38f29ed7465fdc45b2341cb5c082c96bae620b98dd
7
- data.tar.gz: f7d4a9a807f20549656f6546289892721418d4142709eec2adb67ce8edf7e8a59cdf395da13d8d82def77d2a7c06f393d8d008671f74e0ec75437571f7b026f1
6
+ metadata.gz: 8ae9f566ec2099c108e58b2aac390f20146990db555d8b5d1ffbb9ebd41336fef77102e8ea3124a870d092fbd431a5e788fc28890fc7437bc8c785f7c919e168
7
+ data.tar.gz: 9d4ef8f0d6d96df24d61f7a1395689aa20d6c15aa986bf99395611c4796b1fa261571669e50b3e0d2725f370a2a717b33f0de45e25e42393ad87153edf12e74a
data/.gitignore CHANGED
@@ -17,4 +17,5 @@ test/version_tmp
17
17
  tmp
18
18
  test/fixtures/vcr_cassettes/*
19
19
  .byebug_history
20
- test/reports
20
+ test/reports
21
+ .env
data/.travis.yml CHANGED
@@ -1,9 +1,20 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=3ca09808c18a3fb0a12a7b113aeca064acf88831f8a36ee2e9fda89ca37b0650
1
4
  language: ruby
2
5
  rvm:
3
- - 2.3.7
4
- - 2.4.4
5
- - 2.5.1
6
- cache: bundler
6
+ - 2.3.8
7
+ - 2.4.7
8
+ - 2.5.6
9
+ - 2.6.4
10
+ - truffleruby
11
+ - ruby-head
7
12
  install: bundle install
13
+ before_script:
14
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
+ - chmod +x ./cc-test-reporter
16
+ - ./cc-test-reporter before-build
8
17
  script:
9
18
  - bundle exec rake test
19
+ after_script:
20
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ * 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
6
+ * Legacy API no longer supported since it's been shutdown.
7
+ * Since the API has changed, some endpoints are no longer supported and some new ones are supported.
8
+ * Removed ox dependency, the new returns JSON instead of XML.
9
+
10
+ ## 0.2.0
11
+
12
+ * The API endpoint has been updated, so this release updates the API endpoint to the legacy.
13
+ * Updates the way the incoming XML is parsed, so more fields are available from the raw API response. It's also easier to parse using a different method from `ox` than before.
14
+ * No longer supports Ruby 2.2, it's out of support life.
15
+
16
+ ## Previous versions
17
+
18
+ Implements GetGamesList, GetGame, GetArt, GetPlatformsList, GetPlatform, GetPlatformGames, PlatformGames from the original API.
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Gamesdb
2
2
  A Ruby gem to interact with [TheGamesDB](http://thegamesdb.net) API.
3
3
 
4
- It's currently using [the legacy API](http://wiki.thegamesdb.net/index.php/API_Introduction) which is available in read only mode [More info](https://forums.thegamesdb.net/viewtopic.php?f=11&t=86). But it'll be updated to use [the new API endpoints](https://api.thegamesdb.net/), for which you'll need to request an API key. I'll keep a way to use the legacy API with a Legacy module anyways.
4
+ The Legacy API has been shutdown. The gem is now using the new API and you need to [request an API key](https://forums.thegamesdb.net/viewforum.php?f=10) to use it.
5
5
 
6
6
  [![Build Status](https://api.travis-ci.com/picandocodigo/gamesdb.svg?branch=master)](https://travis-ci.com/picandocodigo/gamesdb)
7
+ [![Gem Version](https://badge.fury.io/rb/thegamesdb.svg)](https://badge.fury.io/rb/thegamesdb)
8
+ [![Maintainability](https://api.codeclimate.com/v1/badges/2dcf3cdcbe37adcea569/maintainability)](https://codeclimate.com/github/picandocodigo/gamesdb/maintainability)
9
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/2dcf3cdcbe37adcea569/test_coverage)](https://codeclimate.com/github/picandocodigo/gamesdb/test_coverage)
7
10
 
8
11
  ## Installation
9
12
 
@@ -21,239 +24,116 @@ Or install it in your system with:
21
24
 
22
25
  $ gem install thegamesdb
23
26
 
24
- ## Usage
27
+ Request an API Key [here](https://forums.thegamesdb.net/viewforum.php?f=10). Set the API key in your env variables:
25
28
 
26
- For now you can use most of the API:
27
-
28
- | API call | gem call |
29
- |------------------| ----|
30
- | [GetGamesList](http://wiki.thegamesdb.net/index.php/GetGamesList) | [Get Games List](#get-games-list) |
31
- | [GetGame](http://wiki.thegamesdb.net/index.php/GetGame) | [Get Game](#get-game) |
32
- | [GetArt](http://wiki.thegamesdb.net/index.php/GetArt) | [Get Art](#get-art) |
33
- | [GetPlatformsList](http://wiki.thegamesdb.net/index.php/GetPlatformsList) | [Get Platforms](#get-platforms) |
34
- | [GetPlatform](http://wiki.thegamesdb.net/index.php/GetPlatform) | [Get Platform](#get-platform) |
35
- | [GetPlatformGames](http://wiki.thegamesdb.net/index.php/GetPlatformGames) | [Get Platform Games](#get-platform-games-or-platform-games) |
36
- | [PlatformGames](http://wiki.thegamesdb.net/index.php/PlatformGames) | [Platform Games](#get-platform-games-or-platform-games) |
37
- | [Updates](http://wiki.thegamesdb.net/index.php/Updates) | _Not implemented yet_ |
38
- | [UserRating](http://wiki.thegamesdb.net/index.php/UserRating) | _Not implemented yet_ |
39
- | [UserFavorites](http://wiki.thegamesdb.net/index.php/UserFavorites) | _Not implemented yet_ |
29
+ ```
30
+ GAMESDB_API_KEY='your_api_key'
31
+ ```
40
32
 
41
- ### Get Platforms
42
- http://wiki.thegamesdb.net/index.php?title=GetPlatformsList
43
- >The GetGamesList API search returns a listing of a listing of all platforms available on the site, sorted by alphabetical order of name.
33
+ ## Development
44
34
 
45
- **Usage**
35
+ Run all tests:
46
36
 
47
- * Parameters: none
48
- * Returns: Array with platforms info in Hashes with `:id`, `:name` and `:slug`.
37
+ ```
38
+ GAMESDB_API_KEY='your_api_key' rake test
39
+ ```
49
40
 
50
- ```ruby
51
- $ rake console
52
- irb(main):001:0> Gamesdb.platforms
53
- => [{:name=>"3DO", :id=>25, :slug=>"3do"},
54
- {:name=>"Acorn Archimedes", :id=>4944, :slug=>"acorn-archimedes"},
55
- {:name=>"Acorn Electron", :id=>4954, :slug=>"acorn-electron"},
56
- {:name=>"Action Max", :id=>4976, :slug=>"action-max"},
57
- {:name=>"Amiga", :id=>4911, :slug=>"amiga"},
58
- {:name=>"Amiga CD32", :id=>4947, :slug=>"amiga-cd32"},
59
- {:name=>"Amstrad CPC", :id=>4914, :slug=>"amstrad-cpc"},
60
- {:name=>"Android", :id=>4916, :slug=>"android"},
61
- {:name=>"APF MP-1000", :id=>4969, :slug=>"apf-mp-1000"},
62
- {:name=>"Apple II", :id=>4942, :slug=>"apple2"},
63
- {:name=>"Arcade", :id=>23, :slug=>"arcade"},
64
- {:name=>"Atari 2600", :id=>22, :slug=>"atari-2600"},
65
- {:name=>"Atari 5200", :id=>26, :slug=>"atari-5200"},
66
- {:name=>"Atari 7800", :id=>27, :slug=>"atari-7800"},
67
- {:name=>"Atari 800", :id=>4943, :slug=>"atari800"},
68
- {:name=>"Atari Jaguar", :id=>28, :slug=>"atari-jaguar"},
41
+ Run a single test:
42
+ ```
43
+ GAMESDB_API_KEY='your_api_key' rake test TEST=test/platform_test.rb
69
44
  ```
70
45
 
71
- ### Get Platform Games OR Platform Games
72
- The same method implements `GetPlatformGames` and `PlatformGames`. The first receives the platform id as a parameter, the second one receives the slug. You can find the slug with the GetPlatform method. The return is the same for both methods.
46
+ **Usage**
73
47
 
74
- http://wiki.thegamesdb.net/index.php?title=GetPlatformGames
75
- >The GetPlatformGames API method returns a listing of all games available on the site for the given platform.
48
+ ## Endpoints available
76
49
 
77
- http://wiki.thegamesdb.net/index.php/PlatformGames
78
- >The PlatformGames API call lists all games under a certain platform.
50
+ API Documentation: https://api.thegamesdb.net/
79
51
 
80
- * Parameters:
81
- * id - the integer id of the required platform, as retrived from GetPlatformsList
82
- * platform (string) : the platform slug to list games for (for more information on how to attain a valid platform slug see GetPlatformsList)
52
+ ### Games
83
53
 
84
- * Returns: Array with games info in Hashes with `:id`, `:name` and `:release_date`.
54
+ - [x] **[/Games/ByGameID](https://api.thegamesdb.net/#/operations/Games/GamesByGameID)**
85
55
 
86
- With id:
56
+ Usage:
87
57
 
88
58
  ```ruby
89
- irb(main):002:0> Gamesdb.platform_games(6)
90
- => [{:name=>"Super Mario Kart", :id=>41, :release_date=>"09/01/1992"},
91
- {:name=>"Final Fantasy III", :id=>83, :release_date=>"04/02/1994"},
92
- {:name=>"Contra III: The Alien Wars", :id=>122, :release_date=>"04/06/1992"},
93
- {:name=>"Donkey Kong Country", :id=>131, :release_date=>"11/21/1994"},
94
- {:name=>"Super Mario World", :id=>136, :release_date=>"08/13/1991"},
95
- {:name=>"Super Mario World 2: Yoshi's Island", :id=>137, :release_date=>"10/04/1995"},
96
- {:name=>"Mega Man X", :id=>143, :release_date=>"01/21/1994"},
97
- {:name=>"Teenage Mutant Ninja Turtles IV: Turtles In Time", :id=>188, :release_date=>"08/01/1992"},
98
- ...
59
+ > Gamesdb.game_by_id(6177)
60
+ => {:id=>6177, :game_title=>"Super Turrican", :release_date=>"1993-05-01", :platform=>6, :players=>1, :overview=>"Super Turrican is the next generation installment of the famous Turrican Series. Once again it is up to the U.S.S. Freedom Forces to get into their Turrican Assault Suits and drive back the forces of \"The Machine\".\r\n\r\nSimilar to it's predecessors, Super Turican features large levels that are crammed with secrets and can be explored freely and in any direction. To get rid of the numerous enemies, Turrican can use three upgradeable shots: A spreadshot, a powerful laser and a rebound that bounces off of walls. Additionally, there is a Freeze-Beam that can be used to temporarily freeze enemies. It is fully rotatable, and therefor also a great help in discovering secret capsules. These capsules contain powerups and can often be used to reach secret areas. Last but not least, Turrican has the ability to transform into an energy wheel (as long as he has enough special energy), which enables him to lay mines and even makes him invincible.", :last_updated=>"2018-07-11 21:05:25", :rating=>"T - Teen", :coop=>"No", :youtube=>nil, :os=>nil, :processor=>nil, :ram=>nil, :hdd=>nil, :video=>nil, :sound=>nil, :developers=>[2976], :genres=>[8], :publishers=>[454], :alternates=>nil}
99
61
  ```
100
62
 
101
- With slug:
63
+ - [x] **[/Games/ByGameName](https://api.thegamesdb.net/#/operations/Games/GamesByGameName)**
64
+
65
+ Usage:
102
66
 
103
67
  ```ruby
104
- irb(main):003:0> Gamesdb.platform_games("3do")
105
- => [
106
- {:name=>"Mad Dog McCree", :id=>6429, :release_date=>"01/01/1994"},
107
- {:name=>"AD&D: Slayer", :id=>3143, :release_date=>"01/01/1994"},
108
- {:name=>"Blade Force", :id=>4826, :release_date=>"04/05/1995"},
109
- {:name=>"Battle Chess", :id=>4829, :release_date=>"01/01/1993"},
110
- {:name=>"Brain Dead 13", :id=>4830, :release_date=>"01/01/1996"},
111
- {:name=>"Burning Soldier", :id=>4831, :release_date=>"11/01/1994"},
112
- {:name=>"Corpse Killer", :id=>4833, :release_date=>"01/01/1994"},
68
+ > Gamesdb.games_by_name("Mario Kart")
69
+ => [{:id=>266, :game_title=>"Mario Kart 64", :release_date=>"1997-02-10", :platform=>3, :developers=>[6037]}, {:id=>47050, :game_title=>"Mario Kart 64", :release_date=>"2016-12-29", :platform=>38, :developers=>[6037]}, {:id=>55187, :game_title=>"Mario Kart 64 (VC)", :release_date=>"2007-01-29", :platform=>9, :developers=>[6041]}, {:id=>64547, :game_title=>"Mario Kart 64 [Not for Resale]", :release_date=>"1997-02-10", :platform=>3, :developers=>nil}, {:id=>12733, :game_title=>"Mario Kart 7", :release_date=>"2011-12-04", :platform=>4912, :developers=>[7160]}, {:id=>17444, :game_title=>"Mario Kart 8", :release_date=>"2014-05-30", :platform=>38, :developers=>[6037]}, {:id=>42294, :game_title=>"Mario Kart 8 Deluxe", :release_date=>"2017-04-28", :platform=>4971, :developers=>[6037]}, {:id=>10750, :game_title=>"Mario Kart Arcade GP", :release_date=>"2005-10-12", :platform=>23, :developers=>[5804]}, ...
70
+ ]
113
71
  ```
72
+ - [x] **[/Games/ByPlatformID](https://api.thegamesdb.net/#/operations/Games/GamesByPlatformID)**
114
73
 
115
- ### Get Platform
116
- http://wiki.thegamesdb.net/index.php/GetPlatform
117
- >This API feature returns a set of metadata and artwork data for a specified Platform ID.
74
+ Usage:
118
75
 
119
- **Usage**
76
+ ```ruby
77
+ Gamesdb.games_by_platform_id(7)
78
+ => [{:name=>"Donkey Kong", :id=>5, :release_date=>"1982-01-01", :developers=>[6037]}, {:name=>"Bionic Commando", :id=>76, :release_date=>"1988-12-06", :developers=>[1436]}, {:name=>"Super Mario Bros. 3", :id=>112, :release_date=>"1990-02-12", :developers=>[6055]}, {:name=>"The Legend of Zelda", :id=>113, :release_date=>"1987-07-01", :developers=>[6055]}, {:name=>"Kirby's Adventure", :id=>121, :release_date=>"1993-03-26", :developers=>[3694]}, {:name=>"Metroid", :id=>123, :release_date=>"1987-08-15", :developers=>[6051]}, {:name=>"Mega Man 5", :id=>125, :release_date=>"1992-12-04", :developers=>[1436]}, {:name=>"Kid Icarus", :id=>130, :release_date=>"1986-12-18", :developers=>[6037]}, {:name=>"Lemmings", :id=>133, :release_date=>"1991-02-14", :developers=>[2404]}, {:name=>"Castlevania", :id=>135, :release_date=>"1987-05-01", :developers=>[4765]}, {:name=>"Super Mario Bros.", :id=>140, :release_date=>"1985-09-13", :developers=>[6042]}, ...
79
+ ]
80
+ ```
81
+ - [x] /Games/Images
120
82
 
121
- * Parameters: id - The numeric ID of the platform in the GamesDB database
122
- * Returns: Hash with platform info
83
+ Usage:
123
84
 
124
85
  ```ruby
125
- irb(main):004:0> Gamesdb.platform(6)
126
- => {
127
- :id=>"6",
128
- :console=>"http://www.youtube.com/watch?v=6.png",
129
- :controller=>"http://www.youtube.com/watch?v=6.png",
130
- :overview=>"The Super Nintendo Entertainment System (also known as the Super NES, SNES or Super Nintendo) is a 16-bit video game console that was released by Nintendo in North America, Europe, Australasia (Oceania), and South America between 1990 and 1993. In Japan and Southeast Asia, the system is called the Super Famicom (officially adopting the abbreviated name of its predecessor, the Family Computer), or SFC for short. In South Korea, it is known as the Super Comboy and was distributed by Hyundai Electronics. Although each version is essentially the same, several forms of regional lockout prevent the different versions from being compatible with one another. The Super Nintendo Entertainment System was Nintendo's second home console, following the Nintendo Entertainment System (NES). The console introduced advanced graphics and sound capabilities compared with other consoles at the time. Additionally, development of a variety of enhancement chips (which were integrated on game circuit boards) helped to keep it competitive in the marketplace. The SNES was a global success, becoming the best-selling console of the 16-bit era despite its relatively late start and the fierce competition it faced in North America and Europe from Sega's Genesis console. The SNES remained popular well into the 32-bit era, and although Nintendo no longer offers factory repairs/replacement or accessories for the console, it continues to be popular among fans, collectors, retro gamers, and emulation enthusiasts, some of whom are still making homebrew ROM images.",
131
- :developer=>"Nintendo",
132
- :manufacturer=>"Nintendo",
133
- :cpu=>"16-bit 65c816 Ricoh 5A22 3.58 MHz",
134
- :memory=>"128kb",
135
- :sound=>"8-bit Sony SPC700",
136
- :display=>"512 \xC3\x97 239",
137
- :media=>"Cartridge",
138
- :maxcontrollers=>"2",
139
- :Youtube=>"http://www.youtube.com/watch?v=9fSAnVpJ42w",
140
- :Rating=>"7.8",
141
- :Images=>{
142
- :fanart=>[
143
- {:original=>[{:width=>"1920", :height=>"1080"}, "platform/fanart/6-1.jpg"], :thumb=>"platform/fanart/thumb/6-1.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "platform/fanart/6-2.jpg"], :thumb=>"platform/fanart/thumb/6-2.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "platform/fanart/6-3.jpg"], :thumb=>"platform/fanart/thumb/6-3.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "platform/fanart/6-4.jpg"], :thumb=>"platform/fanart/thumb/6-4.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "platform/fanart/6-5.jpg"], :thumb=>"platform/fanart/thumb/6-5.jpg"}
144
- ],
145
- :boxart=>[
146
- {:side=>"back", :width=>"500", :height=>"750"}, "platform/boxart/6-2.jpg"
147
- ],
148
- :banner=>[
149
- [{:width=>"760", :height=>"140"}, "platform/banners/6-1.png"],
150
- [{:width=>"760", :height=>"140"}, "platform/banners/6-2.jpg"]
151
- ],
152
- :consoleart=>"platform/consoleart/6.png",
153
- :controllerart=>"platform/controllerart/6.png"},
154
- :name=>"Super Nintendo (SNES)"
155
- }
86
+ > Gamesdb.game_images(121)
87
+ => {:base_url=>"https://cdn.thegamesdb.net/images/original/", :logo=>"clearlogo/121.png", :boxart=>{:front=>{:url=>"boxart/front/121-1.jpg", :resolution=>"1536x2100", :width=>"1536", :height=>"2100"}, :back=>{:url=>"boxart/back/121-1.jpg", :resolution=>"1539x2100", :width=>"1539", :height=>"2100"}}, :screenshot=>[{:id=>104578, :type=>"screenshot", :side=>nil, :filename=>"screenshots/121-1.jpg", :resolution=>nil}, {:id=>104580, :type=>"screenshot", :side=>nil, :filename=>"screenshots/121-2.jpg", :resolution=>nil}], :fanart=>[{:url=>"fanart/121-1.jpg", :resolution=>"1920x1080", :width=>"1920", :height=>"1080"}, {:url=>"fanart/121-2.jpg", :resolution=>"1920x1080", :width=>"1920", :height=>"1080"}]}
156
88
  ```
89
+ - [ ] /Games/Updates
157
90
 
158
- ### Get Game
159
- http://wiki.thegamesdb.net/index.php?title=GetGame
160
- >The GetGameApi title search returns game data in an XML document or if an id is given it just returns the data for that specific game.
161
-
162
- **Usage**
91
+ ### Platforms
163
92
 
164
- * Parameters: id (int): ID representing a specific game
165
- * Returns: Array with games info in Hashes `:id`, `:title`, `:release_date`, `:platform`, `:overview`, `:publisher`, `:developer`, `:genres` (comma separated string), `:images {:front, :back}`
93
+ - [x] **[/Platforms](https://api.thegamesdb.net/#/operations/Platforms/Platforms)**
166
94
 
95
+ Usage:
167
96
  ```ruby
168
- irb(main):005:0> Gamesdb.game(109)
169
- => {
170
- :id=>109,
171
- :PlatformId=>"9",
172
- :ReleaseDate=>"11/19/2006",
173
- :Overview=>"Join Link for an legendary adventure on the Wii console. When an evil darkness enshrouds the land of Hyrule, a young farm boy named Link must awaken the hero \xE2\x80\x93 and the animal \xE2\x80\x93 within. When Link travels to the Twilight Realm, he transforms into a wolf and must scour the land with the help of a mysterious girl named Midna. Besides his trusty sword and shield, Link will use his bow and arrows by aiming with the Wii Remote controller, fight while on horseback and use a wealth of other items, both new and old. Features * Arm Link: The Wii Remote and Nunchuk controllers are used for a variety of game activities from fishing to projectile-weapon aiming. The game features incredibly precise aiming control using the Wii Remote controller. Use the controllers for sword swings, spin attacks and shield shoves. * Thrilling Adventure: Players ride into battle against troops of foul creatures and wield a sword and shield with the Wii Remote and Nunchuk controllers, then take on massive bosses that must be seen to be believed. * Mind & Muscle: Many puzzles stand between Link and the fulfillment of his quest, so players must sharpen their wits as they hunt for weapons and items.",
174
- :ESRB=>"T - Teen",
175
- :Genres=>{
176
- :genre=>["Action", "Adventure", "Platform", "Puzzle", "Role-Playing"]
177
- },
178
- :Players=>"1",
179
- :"Co-op"=>"No",
180
- :Youtube=>"http://www.youtube.com/watch?v=ceCktUEG4jA",
181
- :Publisher=>"Nintendo",
182
- :Developer=>"Nintendo",
183
- :Rating=>"6.85",
184
- :Similar=>{
185
- :SimilarCount=>"1",
186
- :Game=>{:id=>"5434", :PlatformId=>"2"}
187
- },
188
- :Images=>{
189
- :fanart=>[{:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-1.jpg"], :thumb=>"fanart/thumb/109-1.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-2.jpg"], :thumb=>"fanart/thumb/109-2.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-3.jpg"], :thumb=>"fanart/thumb/109-3.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-4.jpg"], :thumb=>"fanart/thumb/109-4.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-5.jpg"], :thumb=>"fanart/thumb/109-5.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-6.jpg"], :thumb=>"fanart/thumb/109-6.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-7.jpg"], :thumb=>"fanart/thumb/109-7.jpg"}, {:original=>[{:width=>"1920", :height=>"1080"}, "fanart/original/109-8.jpg"], :thumb=>"fanart/thumb/109-8.jpg"}],
190
- :boxart=>[
191
- [{:side=>"back", :width=>"1528", :height=>"2156", :thumb=>"boxart/thumb/original/back/109-1.jpg"},"boxart/original/back/109-1.jpg"],
192
- [{:side=>"front", :width=>"1529", :height=>"2156", :thumb=>"boxart/thumb/original/front/109-1.jpg"}, "boxart/original/front/109-1.jpg"]],
193
- :banner=>[[{:width=>"760", :height=>"140"}, "graphical/109-g.jpg"], [{:width=>"760", :height=>"140"}, "graphical/109-g2.png"]],
194
- :screenshot=>{:original=>[{:width=>"603", :height=>"310"}, "screenshots/109-1.jpg"], :thumb=>"screenshots/thumb/109-1.jpg"},
195
- :clearlogo=>[{:width=>"400", :height=>"277"}, "clearlogo/109.png"]
196
- },
197
- :name=>"The Legend of Zelda: Twilight Princess",
198
- :title=>"The Legend of Zelda: Twilight Princess",
199
- :platform=>"Nintendo Wii"}
97
+ Gamesdb.platforms
98
+ => [
99
+ {:name=>"3DO", :id=>25, :slug=>"3do"},
100
+ {:name=>"Acorn Archimedes", :id=>4944, :slug=>"acorn-archimedes"},
101
+ {:name=>"Acorn Electron", :id=>4954, :slug=>"acorn-electron"},
102
+ {:name=>"Action Max", :id=>4976, :slug=>"action-max"},
103
+ {:name=>"Amiga", :id=>4911, :slug=>"amiga"},
104
+ {:name=>"Amiga CD32", :id=>4947, :slug=>"amiga-cd32"},
105
+ {:name=>"Amstrad CPC", :id=>4914, :slug=>"amstrad-cpc"},
106
+ {:name=>"Android", :id=>4916, :slug=>"android"},
107
+ ...
108
+ ```
109
+ - [x] **[/Platforms/ByPlatformID](https://api.thegamesdb.net/#/operations/Platforms/PlatformsByPlatformID)**
200
110
 
111
+ Usage:
112
+ ```ruby
113
+ > Gamesdb.platform_by_id(7)
114
+ => {:id=>7, :name=>"Nintendo Entertainment System (NES)", :alias=>"nintendo-entertainment-system-nes", :icon=>"nintendo-entertainment-system-nes-1336524652.png", :console=>"7.png", :controller=>"7.png", :developer=>"Nintendo", :manufacturer=>"Nintendo", :media=>"Cartridge", :cpu=>"Ricoh 2A03", :memory=>"2KB RAM", :graphics=>"RP2C02", :sound=>"Pulse Code Modulation", :maxcontrollers=>"2", :display=>"RGB", :overview=>"The Nintendo Entertainment System (also abbreviated as NES or simply called Nintendo) is an 8-bit video game console that was released by Nintendo in North America during 1985, in Europe during 1986 and Australia in 1987. In most of Asia, including Japan (where it was first launched in 1983), China, Vietnam, Singapore, the Middle East and Hong Kong, it was released as the Family Computer, commonly shortened as either the romanized contraction Famicom, or abbreviated to FC. In South Korea, it was known as the Hyundai Comboy, and was distributed by Hynix which then was known as Hyundai Electronics.\r\n\r\nAs the best-selling gaming console of its time, the NES helped revitalize the US video game industry following the video game crash of 1983, and set the standard for subsequent consoles of its generation. With the NES, Nintendo introduced a now-standard business model of licensing third-party developers, authorizing them to produce and distribute software for Nintendo's platform.", :youtube=>nil}
201
115
  ```
202
116
 
203
- ### Get Games List
204
- http://wiki.thegamesdb.net/index.php/GetGamesList
205
- >The GetGamesList API search returns a listing of games matched up with loose search terms. *Note: We have implemented special character stripping and loose word order searching in an attempt to provide better matching and a return a greater number of relevant hits.*
117
+ - [ ] /Platforms/ByPlatformName
118
+ - [ ] /Platforms/Images
206
119
 
207
- **Usage**
120
+ ### Genres
208
121
 
209
- * Parameters: name (String): search string.
210
- * Returns: Hash with game info: `:id`, `:name` (not-unique), `:release_date`, `platform`
122
+ - [ ] /Genres
211
123
 
212
- ```ruby
213
- irb(main):006:0> Gamesdb.games_list "Asterix"
214
- => [
215
- {:id=>330,:ReleaseDate=>"01/01/1993", :name=>"Asterix", :title=>"Asterix", :platform=>"Nintendo Entertainment System (NES)"},
216
- {:id=>2981, :ReleaseDate=>"01/01/1991", :name=>"Asterix", :title=>"Asterix", :platform=>"Sega Master System"},
217
- {:id=>3160, :ReleaseDate=>"01/01/1993", :name=>"Asterix", :title=>"Asterix", :platform=>"Super Nintendo (SNES)"},
218
- {:id=>9243, :ReleaseDate=>"01/01/1983", :name=>"Asterix", :title=>"Asterix", :platform=>"Atari 2600"},
219
- {:id=>21170, :ReleaseDate=>"06/11/1993", :name=>"Asterix", :title=>"Asterix", :platform=>"Nintendo Game Boy"},
220
- {:id=>21565, :ReleaseDate=>"07/01/1992", :name=>"Asterix", :title=>"Asterix", :platform=>"Arcade"},
221
- {:id=>498, :ReleaseDate=>"09/01/2000", :name=>"Asterix: The Gallic War", :title=>"Asterix: The Gallic War", :platform=>"Sony Playstation"},
222
- {:id=>1572, :ReleaseDate=>"09/28/1995", :name=>"Asterix & Obelix", :title=>"Asterix & Obelix", :platform=>"Super Nintendo (SNES)"},
223
- {:id=>18225, :ReleaseDate=>"07/15/1999", :name=>"Asterix & Obelix", :title=>"Asterix & Obelix", :platform=>"Nintendo Game Boy Color"},
224
- ```
124
+ ### Developers
225
125
 
226
- ### Get Art
227
- http://wiki.thegamesdb.net/index.php/GetArt
228
- >This API feature returns a list of available artwork types and locations specific to the requested game id in the database. It also lists the resolution of any images available.
126
+ - [ ] /Developers
229
127
 
230
- **Usage**
128
+ ### Publishers
231
129
 
232
- * Parameters: id (integer): The numeric ID of the game in Gamesdb
233
- * Returns: Hash with images: `logo`, `boxart` (Hash - front, back), `screenshots`, `fanart`
234
-
235
- ```ruby
236
- irb(main):007:0> Gamesdb.art(2208)
237
- => {
238
- :boxart=>{
239
- :back=>{:url=>"boxart/original/back/2208-1.jpg", :width=>"800", :height=>"569", :thumb=>"boxart/thumb/original/back/2208-1.jpg"},
240
- :front=>{:url=>"boxart/original/front/2208-1.jpg", :width=>"2099", :height=>"1513", :thumb=>"boxart/thumb/original/front/2208-1.jpg"}
241
- },
242
- :screenshot=>[
243
- {:original=>[{:width=>"768", :height=>"672"}, "screenshots/2208-1.jpg"], :thumb=>"screenshots/thumb/2208-1.jpg"},
244
- {:original=>[{:width=>"768", :height=>"672"}, "screenshots/2208-2.jpg"], :thumb=>"screenshots/thumb/2208-2.jpg"},
245
- {:original=>[{:width=>"768", :height=>"672"}, "screenshots/2208-3.jpg"], :thumb=>"screenshots/thumb/2208-3.jpg"}
246
- ],
247
- :clearlogo=>[{:width=>"400", :height=>"44"}, "clearlogo/2208.png"],
248
- :logo=>"clearlogo/2208.png"
249
- }
250
- ```
130
+ - [ ] /Publishers
251
131
 
252
132
  ## Contributing
253
133
 
254
134
  1. Fork it ( http://github.com/picandocodogio/gamesdb/fork )
255
135
  2. Create your feature branch (`git checkout -b my-new-feature`)
256
- 3. Write your tests and run `rake test` (make sure they pass)
136
+ 3. Write your tests and run `GAMESDB_API_KEY='your_api_key' rake test` (make sure they pass)
257
137
  4. Commit your changes (`git commit -am 'Add some feature'`)
258
138
  5. Push to the branch (`git push origin my-new-feature`)
259
139
  6. Create new Pull Request
data/lib/thegamesdb.rb CHANGED
@@ -1,28 +1,29 @@
1
1
  require 'thegamesdb/version'
2
- require 'ox'
2
+ require 'thegamesdb/config'
3
3
  require 'net/http'
4
+ require 'json'
4
5
 
5
6
  # Client for TheGamesDB API (thegamesdb.net)
6
7
  module Gamesdb
7
- BASE_URL = 'http://legacy.thegamesdb.net/api/'
8
- IMAGES_BASE_URL = 'http://legacy.thegamesdb.net/banners/'
8
+ BASE_URL = 'https://api.thegamesdb.net/'.freeze
9
+ IMAGES_BASE_URL = 'https://legacy.thegamesdb.net/banners/'.freeze
9
10
 
10
11
  # Method for listing platform's games
11
- # http://wiki.thegamesdb.net/index.php?title=GetPlatformGames
12
+ # https://api.thegamesdb.net/#/operations/Games/GamesByPlatformID
12
13
  #
13
- # Parameters: platform id (int) || platform slug (string)
14
- # For information on how to attain a valid platform slug see `platform`
14
+ # Parameters: platform id (int)
15
15
  #
16
16
  # == Returns:
17
17
  # Array of Hashes with games info
18
- def self.platform_games(platform)
19
- url = platform.is_a?(Numeric) ? 'GetPlatformGames.php' : 'PlatformGames.php'
20
- data = xml_response(url, platform: platform)
18
+ #
19
+ def self.games_by_platform_id(platform_id)
20
+ url = 'Games/ByPlatformID'
21
+ data = json_response(url, id: platform_id)
21
22
  process_platform_games(data)
22
23
  end
23
24
 
24
25
  # Method for listing platforms
25
- # http://wiki.thegamesdb.net/index.php?title=GetPlatformsList
26
+ # https://api.thegamesdb.net/#/operations/Platforms/Platforms
26
27
  #
27
28
  # Parameters: none
28
29
  #
@@ -30,19 +31,20 @@ module Gamesdb
30
31
  # Array of Hashes with platforms info
31
32
  #
32
33
  def self.platforms
33
- url = 'GetPlatformsList.php'
34
- data = xml_response(url)
34
+ url = 'Platforms'
35
+ data = json_response(url)
35
36
  platforms = []
36
37
 
37
- data[:Platforms].first.last.each do |platform|
38
- platforms << { name: platform[:name], id: platform[:id].to_i, slug: platform[:alias] }
38
+ data['platforms'].each do |p|
39
+ platform = p.last
40
+ platforms << { name: platform['name'], id: platform['id'].to_i, slug: platform['alias'] }
39
41
  end
40
42
  platforms
41
43
  end
42
44
 
43
45
  # This API feature returns a set of metadata and artwork data for a
44
46
  # specified Platform ID.
45
- # http://wiki.thegamesdb.net/index.php/GetPlatform
47
+ # https://api.thegamesdb.net/#/operations/Platforms/PlatformsByPlatformID
46
48
  #
47
49
  # Parameters:
48
50
  # - id - (int) The numeric ID of the platform in the GamesDB database
@@ -50,16 +52,21 @@ module Gamesdb
50
52
  # == Returns:
51
53
  # Hash with platform info
52
54
  #
53
- def self.platform(id)
54
- url = 'GetPlatform.php'
55
- data = xml_response(url, id: id)[:Platform]
56
- data[:name] = data.delete(:Platform)
57
- data
55
+ def self.platform_by_id(id)
56
+ url = 'Platforms/ByPlatformID'
57
+ params = {
58
+ id: id,
59
+ fields: 'icon,console,controller,developer,manufacturer,media,cpu,memory,graphics,sound,maxcontrollers,display,overview,youtube'
60
+ }
61
+ data = json_response(url, params)
62
+
63
+ response = data['platforms'].values.first
64
+ symbolize_keys(response)
58
65
  end
59
66
 
60
67
  # Method for getting game info
61
68
  # TODO: name and platform parameters (for search)
62
- # http://wiki.thegamesdb.net/index.php?title=GetGame
69
+ # https://api.thegamesdb.net/#/operations/Games/GamesByGameID
63
70
  #
64
71
  # Parameters:
65
72
  # - id - (int) Game id
@@ -67,38 +74,40 @@ module Gamesdb
67
74
  # == Returns:
68
75
  # Hash with game info
69
76
  #
70
- def self.game(id)
71
- url = 'GetGame.php'
72
- data = xml_response(url, id: id)
73
- game = process_game(data[:Game])
74
- game
77
+ def self.game_by_id(id)
78
+ url = 'Games/ByGameID'
79
+ params = {
80
+ id: id,
81
+ fields: 'players,publishers,genres,overview,last_updated,rating,platform,coop,youtube,os,processor,ram,hdd,video,sound,alternates',
82
+ include: 'boxart,platform'
83
+ }
84
+ data = json_response(url, params)
85
+ return [] if data["count"] == 0
86
+ symbolize_keys(data['games'].first)
75
87
  end
76
88
 
77
89
  # The GetGamesList API search returns a listing of games matched up
78
90
  # with loose search terms.
79
- # http://wiki.thegamesdb.net/index.php/GetGamesList
91
+ # https://api.thegamesdb.net/#/operations/Games/GamesByGameName
80
92
  #
81
93
  # Parameters:
82
94
  # - name (required)
83
- # - TODO: platform (optional): filters results by platform (not implemented)
84
- # - TODO: genre (optional): filters results by genre (not
85
- # implemented)
86
95
  #
87
96
  # == Returns:
88
97
  # Hash with game info: id, name (not-unique), release_date,
89
98
  # platform
90
99
  #
91
- def self.games_list(name)
92
- url = 'GetGamesList.php'
93
- data = xml_response(url, name: name)
94
- data[:Game].map { |game| process_game(game) }
100
+ def self.games_by_name(name)
101
+ url = 'Games/ByGameName'
102
+ data = json_response(url, name: name)
103
+ data['games'].map { |game| symbolize_keys(game) }
95
104
  end
96
105
 
97
106
  # This API feature returns a list of available artwork types and
98
107
  # locations specific to the requested game id in the database. It
99
108
  # also lists the resolution of any images available. Scrapers can be
100
109
  # set to use a minimum or maximum resolution for specific images
101
- # http://wiki.thegamesdb.net/index.php/GetArt
110
+ # https://api.thegamesdb.net/#/operations/Games/GamesImages
102
111
  #
103
112
  # Parameters
104
113
  # - id - (integer) The numeric ID of the game in Gamesdb that you
@@ -108,25 +117,62 @@ module Gamesdb
108
117
  # Hash with game art info: fanart (array), boxart (Hash, :front,
109
118
  # :back), screenshots (array), fanart (array)
110
119
  #
111
- def self.art(id)
112
- url = 'GetArt.php'
113
- data = xml_response(url, id: id)[:Images]
114
- data[:logo] = data[:clearlogo].last
115
- data[:boxart] = process_covers(data[:boxart])
116
- data
120
+ def self.game_images(id)
121
+ url = 'Games/Images'
122
+ data = json_response(url, games_id: id)
123
+ return [] if data['count'] == 0
124
+
125
+ response = {}
126
+ response[:base_url] = data['base_url']['original']
127
+ response[:logo] = process_logo(data, id)
128
+ response[:boxart] = process_covers(data, id)
129
+ response[:screenshot] = process_screenshots(data, id)
130
+ response[:fanart] = process_fanart(data, id)
131
+ response
132
+ end
133
+
134
+ def self.process_logo(data, id)
135
+ logo = data['images'][id.to_s].select { |a| a['type'] == "clearlogo" }
136
+ logo.empty? ? '' : logo.first['filename']
137
+ end
138
+
139
+ def self.process_fanart(data, id)
140
+ fanarts = []
141
+ fanart = data['images'][id.to_s].select do |a|
142
+ a['type'] == 'fanart'
143
+ end
144
+ return [] if fanart.empty?
145
+ fanart.each do |art|
146
+ width, height = art['resolution'].split("x") unless art['resolution'].nil?
147
+ fanarts << {
148
+ url: art['filename'],
149
+ resolution: art['resolution'],
150
+ width: width,
151
+ height: height
152
+ }
153
+ end
154
+ fanarts
117
155
  end
118
156
 
119
- def self.process_covers(boxart)
120
- boxart = boxart.flatten
157
+ def self.process_screenshots(data, id)
158
+ data['images'][id.to_s].select do |a|
159
+ a['type'] == 'screenshot'
160
+ end.map { |b| symbolize_keys(b) }
161
+ end
121
162
 
163
+ def self.process_covers(data, id)
122
164
  covers = {}
165
+ boxart = data['images'][id.to_s].select do |a|
166
+ a['type'] == "boxart"
167
+ end
168
+ return [] if boxart.empty?
123
169
  boxart.each do |art|
124
- next unless art.is_a?(Hash)
125
- covers[art[:side].to_sym] = {
126
- url: art[:thumb].gsub('thumb/',''),
127
- width: art[:width],
128
- height: art[:height],
129
- thumb: art[:thumb]
170
+ width, height = art['resolution'].split("x") unless art['resolution'].nil?
171
+ covers[art['side'].to_sym] = {
172
+ url: art['filename'],
173
+ resolution: art['resolution'],
174
+ width: width,
175
+ height: height
130
176
  }
131
177
  end
132
178
  covers
@@ -134,23 +180,31 @@ module Gamesdb
134
180
 
135
181
  private
136
182
 
183
+ def self.configuration
184
+ @configuration ||= Config.new
185
+ end
186
+
137
187
  # Api call and xml parsing
138
- def self.xml_response(url, params = {})
188
+ def self.json_response(url, params = {})
189
+ params = params.merge({apikey: configuration.api_key})
190
+
139
191
  uri = URI(BASE_URL + url)
140
192
  uri.query = URI.encode_www_form(params)
141
193
  request = Net::HTTP.get_response(uri)
142
- Ox.load(request.body, mode: :hash)[:Data]
194
+ response = JSON.parse(request.body)
195
+ response['data']
143
196
  end
144
197
 
145
198
  # Process games for platform_games
146
199
  def self.process_platform_games(data)
147
200
  games = []
148
201
 
149
- data.first.last.each do |elem|
150
- name = elem[:GameTitle]
151
- id = elem[:id].to_i
152
- date = elem.dig(:ReleaseDate)
153
- games << { name: name, id: id, release_date: date }
202
+ data['games'].each do |elem|
203
+ name = elem['game_title']
204
+ id = elem['id']
205
+ date = elem['release_date']
206
+ developers = elem['developers']
207
+ games << { name: name, id: id, release_date: date, developers: developers }
154
208
  end
155
209
  games
156
210
  end
@@ -177,4 +231,11 @@ module Gamesdb
177
231
  end
178
232
  images
179
233
  end
234
+
235
+ def self.symbolize_keys(hash)
236
+ hash.keys.each do |key|
237
+ hash[key.to_sym] = hash.delete(key)
238
+ end
239
+ hash
240
+ end
180
241
  end
@@ -0,0 +1,9 @@
1
+ module Gamesdb
2
+ class Config
3
+ attr_accessor :api_key
4
+
5
+ def initialize
6
+ @api_key = ENV['GAMESDB_API_KEY'] || nil
7
+ end
8
+ end
9
+ end
@@ -1,4 +1,4 @@
1
1
  # Gem version
2
2
  module Gamesdb
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
data/test/games_test.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require_relative './test_helper.rb'
2
2
 
3
- describe "Gamesdb - games", :vcr do
3
+ describe 'Gamesdb - games', :vcr do
4
4
  describe 'game' do
5
5
  before do
6
- @game = Gamesdb.game(109)
6
+ @game = Gamesdb.game_by_id(109)
7
7
  end
8
8
 
9
9
  it 'should have a valid id' do
@@ -12,52 +12,74 @@ describe "Gamesdb - games", :vcr do
12
12
  end
13
13
 
14
14
  it 'should have valid fields' do
15
- @game[:title].must_be_kind_of String
16
- @game[:title].length.wont_be :<, 0
15
+ @game[:game_title].must_be_kind_of String
16
+ @game[:game_title].length.wont_be :<, 0
17
17
  end
18
18
  end
19
19
 
20
- describe 'games_list' do
20
+ describe 'empty game' do
21
21
  before do
22
- @games_list = Gamesdb.games_list('turrican')
22
+ @game = Gamesdb.game_by_id(3)
23
+ end
24
+
25
+ it 'should return an empty array' do
26
+ @game.must_equal []
27
+ end
28
+ end
29
+
30
+ describe 'games by name' do
31
+ before do
32
+ @games_list = Gamesdb.games_by_name('turrican')
23
33
  end
24
34
 
25
35
  it 'should return a list' do
26
36
  game = @games_list.first
27
37
  game[:id].must_be_kind_of Integer
28
- game[:name].must_be_kind_of String
29
- game[:platform].must_be_kind_of String
38
+ game[:game_title].must_be_kind_of String
39
+ game[:platform].must_be_kind_of Integer
40
+ game[:release_date].must_be_kind_of String
30
41
  end
31
42
  end
32
43
 
33
44
  describe 'games art', :vcr do
34
- before do
35
- @images = Gamesdb.art('216')
36
- end
45
+ describe 'when most of the art is available' do
46
+ before do
47
+ @images = Gamesdb.game_images('216')
48
+ end
37
49
 
38
- it 'should return logo and boxart' do
39
- @images[:boxart].count.wont_be :<, 0
40
- @images[:logo].must_be_kind_of String
41
- @images[:boxart][:front][:url].must_be_kind_of String
42
- @images[:boxart][:front][:width].must_be_kind_of String
43
- @images[:boxart][:front][:height].must_be_kind_of String
44
- @images[:boxart][:front][:thumb].must_be_kind_of String
45
- end
50
+ it 'should return logo and boxart' do
51
+ @images[:boxart].count.wont_be :<, 0
52
+ @images[:logo].must_be_kind_of String
53
+ @images[:boxart][:front][:url].must_be_kind_of String
54
+ @images[:boxart][:front][:width].must_be_kind_of String
55
+ @images[:boxart][:front][:height].must_be_kind_of String
56
+ @images[:boxart][:front][:resolution].must_be_kind_of String
57
+ end
46
58
 
47
- it 'should return screenshots' do
48
- @images[:screenshot].count.wont_be :<, 0
49
- @images[:screenshot].first[:original][1].must_be_kind_of String
50
- @images[:screenshot].first[:original].first[:width].must_be_kind_of String
51
- @images[:screenshot].first[:original].first[:height].must_be_kind_of String
52
- @images[:screenshot].first[:thumb].must_be_kind_of String
59
+ it 'should return screenshots' do
60
+ @images[:screenshot].count.wont_be :<, 0
61
+ @images[:screenshot].first.must_be_kind_of Hash
62
+ @images[:screenshot].first[:filename].must_be_kind_of String
63
+ end
64
+
65
+ it 'should return fanart' do
66
+ @images[:fanart].count.wont_be :<, 0
67
+ @images[:fanart].first[:url].must_be_kind_of String
68
+ @images[:fanart].first[:width].must_be_kind_of String
69
+ @images[:fanart].first[:height].must_be_kind_of String
70
+ @images[:fanart].first[:resolution].must_be_kind_of String
71
+ end
53
72
  end
54
73
 
55
- it 'should return fanart' do
56
- @images[:fanart].count.wont_be :<, 0
57
- @images[:fanart].first[:original][1].must_be_kind_of String
58
- @images[:fanart].first[:original].first[:width].must_be_kind_of String
59
- @images[:fanart].first[:original].first[:height].must_be_kind_of String
60
- @images[:fanart].first[:thumb].must_be_kind_of String
74
+ describe 'when some art is missing' do
75
+ before do
76
+ @images = Gamesdb.game_images(65238)
77
+ end
78
+
79
+ it 'should return an empty array' do
80
+ @images.must_be_kind_of Array
81
+ @images.must_equal []
82
+ end
61
83
  end
62
84
  end
63
85
  end
@@ -1,4 +1,6 @@
1
- describe "GamesDB - platforms", :vcr do
1
+ require_relative './test_helper'
2
+
3
+ describe 'GamesDB - platforms', :vcr do
2
4
  describe 'platforms' do
3
5
  before do
4
6
  @platforms = Gamesdb.platforms
@@ -24,23 +26,18 @@ describe "GamesDB - platforms", :vcr do
24
26
  describe 'platform_games' do
25
27
  before do
26
28
  platforms = Gamesdb.platforms
27
- @games_by_id = Gamesdb.platform_games(platforms[0][:id])
28
- @games_by_slug = Gamesdb.platform_games(platforms[0][:slug])
29
+ @games_by_id = Gamesdb.games_by_platform_id(platforms[0][:id])
29
30
  end
30
31
 
31
32
  it 'should return games in platform by id' do
32
33
  @games_by_id.count.wont_be :<, 0
33
34
  end
34
-
35
- it 'should return games in platform' do
36
- @games_by_slug.count.wont_be :<, 0
37
- end
38
35
  end
39
36
 
40
37
  describe 'platform' do
41
38
  describe 'assigning basic info' do
42
39
  before do
43
- @platform = Gamesdb.platform 6
40
+ @platform = Gamesdb.platform_by_id 6
44
41
  end
45
42
 
46
43
  it 'should return valid platform info' do
@@ -53,20 +50,11 @@ describe "GamesDB - platforms", :vcr do
53
50
  @platform[:sound].must_be_kind_of String
54
51
  @platform[:display].must_be_kind_of String
55
52
  end
56
-
57
- it 'should assign images if provided' do
58
- images = @platform[:Images]
59
- images[:boxart][1].must_equal 'platform/boxart/6-2.jpg'
60
- images[:boxart].first[:width].must_equal '500'
61
- images[:boxart].first[:height].must_equal '750'
62
- images[:consoleart].must_equal 'platform/consoleart/6.png'
63
- images[:controllerart].must_equal 'platform/controllerart/6.png'
64
- end
65
53
  end
66
54
 
67
55
  describe 'without hardware or images' do
68
56
  before do
69
- @platform = Gamesdb.platform 4916
57
+ @platform = Gamesdb.platform_by_id 4916
70
58
  end
71
59
 
72
60
  it 'should return valid platform info' do
@@ -79,16 +67,6 @@ describe "GamesDB - platforms", :vcr do
79
67
  @platform[:sound].must_be_nil
80
68
  @platform[:display].must_be_nil
81
69
  end
82
-
83
- it 'should not fail hard if no images are provided' do
84
- images = @platform[:Images]
85
-
86
- images[:boxart][1].must_equal 'platform/boxart/4916-2.jpg'
87
- images[:boxart].first[:width].must_equal '820'
88
- images[:boxart].first[:height].must_equal '1080'
89
- images[:consoleart].must_be_nil
90
- images[:controllerart].must_be_nil
91
- end
92
70
  end
93
71
  end
94
72
  end
data/test/test_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'minitest/autorun'
4
4
  require 'minitest/reporters'
5
5
  require 'minitest/spec'
6
6
  require 'vcr'
7
- require "minitest-vcr"
7
+ require 'minitest-vcr'
8
8
  Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
9
9
  MinitestVcr::Spec.configure!
10
10
 
data/thegamesdb.gemspec CHANGED
@@ -17,8 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
- spec.add_runtime_dependency 'ox', '~> 2.1'
21
- spec.add_development_dependency 'bundler', '~> 1.5'
20
+ spec.add_development_dependency 'bundler'
22
21
  spec.add_development_dependency 'byebug'
23
22
  spec.add_development_dependency 'minitest-reporters'
24
23
  spec.add_development_dependency 'minitest-vcr'
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thegamesdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.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: 2018-08-26 00:00:00.000000000 Z
11
+ date: 2019-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ox
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.1'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '1.5'
19
+ version: '0'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '1.5'
26
+ version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: byebug
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -145,11 +131,13 @@ extra_rdoc_files: []
145
131
  files:
146
132
  - ".gitignore"
147
133
  - ".travis.yml"
134
+ - CHANGELOG.md
148
135
  - Gemfile
149
136
  - LICENSE.txt
150
137
  - README.md
151
138
  - Rakefile
152
139
  - lib/thegamesdb.rb
140
+ - lib/thegamesdb/config.rb
153
141
  - lib/thegamesdb/version.rb
154
142
  - test/games_test.rb
155
143
  - test/platform_test.rb
@@ -174,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
162
  - !ruby/object:Gem::Version
175
163
  version: '0'
176
164
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.7.6
165
+ rubygems_version: 3.0.3
179
166
  signing_key:
180
167
  specification_version: 4
181
168
  summary: Client for TheGamesDB API (thegamesdb.net).