thegamesdb 0.1.2 → 0.2.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
- SHA1:
3
- metadata.gz: 345770d314e513f50b4e7e743e21673ae41a3f2c
4
- data.tar.gz: 279e8c8d54ba58f6142c8682eb827d7863ae9dc5
2
+ SHA256:
3
+ metadata.gz: d98f6062fe9aeb46eaa145ae984dddde93598e658527ca7fb97cc407fed5c5f5
4
+ data.tar.gz: ea3afe6ed630d5cdda83f8d5e62eafe08ef0c4bf08cd2f74f2f3c9ea1a599963
5
5
  SHA512:
6
- metadata.gz: 1c5f50b81932e3f115d8ca84875548f9be58b4d04b3e03a1ae45b06073dcf2cb2712a042b0a7b07fce1f48a1d18b1fb3b0916f420b822bf147b3b1d005ec7700
7
- data.tar.gz: ac9b14f2ecbf4503512bd21d1a10a95dddf11cf9482ad0c1e72bd9ae8cee16b56337cf51edda8cb1a9870db0282497b16585d90cad99f75d52ff544a9ed6377c
6
+ metadata.gz: e6b20ed995691fe0ef6f4b50994a2b78c521400d8ba04366a03e7675adda0bebc290aa12f7d8f9ae68ec6c38f29ed7465fdc45b2341cb5c082c96bae620b98dd
7
+ data.tar.gz: f7d4a9a807f20549656f6546289892721418d4142709eec2adb67ce8edf7e8a59cdf395da13d8d82def77d2a7c06f393d8d008671f74e0ec75437571f7b026f1
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.7
4
+ - 2.4.4
5
+ - 2.5.1
6
+ cache: bundler
7
+ install: bundle install
8
+ script:
9
+ - bundle exec rake test
data/README.md CHANGED
@@ -1,31 +1,42 @@
1
1
  # Gamesdb
2
+ A Ruby gem to interact with [TheGamesDB](http://thegamesdb.net) API.
2
3
 
3
- A Ruby gem to interact with [TheGamesDB](http://thegamesdb.net) [API](http://wiki.thegamesdb.net/index.php?title=API_Introduction).
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.
5
+
6
+ [![Build Status](https://api.travis-ci.com/picandocodigo/gamesdb.svg?branch=master)](https://travis-ci.com/picandocodigo/gamesdb)
4
7
 
5
8
  ## Installation
6
9
 
10
+ This gem requires Ruby version 2.3 or more.
11
+
7
12
  Add this line to your application's Gemfile:
8
13
 
9
14
  gem 'thegamesdb'
10
15
 
11
- And then execute:
16
+ And then run:
12
17
 
13
- $ bundle
18
+ $ bundle install
14
19
 
15
- Or install it yourself as:
20
+ Or install it in your system with:
16
21
 
17
22
  $ gem install thegamesdb
18
23
 
19
24
  ## Usage
20
25
 
21
- This is still a work in progress, but for now you can use:
22
-
23
- * [Get Platforms](#get-platforms)
24
- * [Get Platform Games || Platform Games](#get-platform-games)
25
- * [Get Platform](#get-platform)
26
- * [Get Game](#get-game)
27
- * [Get Games List](#get-game-list)
28
- * [Get Art](#get-art)
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
40
 
30
41
  ### Get Platforms
31
42
  http://wiki.thegamesdb.net/index.php?title=GetPlatformsList
@@ -37,18 +48,24 @@ http://wiki.thegamesdb.net/index.php?title=GetPlatformsList
37
48
  * Returns: Array with platforms info in Hashes with `:id`, `:name` and `:slug`.
38
49
 
39
50
  ```ruby
40
- $ irb
41
- 2.1.2 :001 > require 'gamesdb'
42
- => true
43
- 2.1.2 :002 > Gamesdb.platforms
44
- => [{:name=>"3DO", :id=>25, :slug=>nil},
45
- {:name=>"Amiga", :id=>4911, :slug=>nil},
46
- {:name=>"Amstrad CPC", :id=>4914, :slug=>nil},
47
- {:name=>"Android", :id=>4916, :slug=>nil},
48
- {:name=>"Arcade", :id=>23, :slug=>nil},
49
- {:name=>"Atari 2600", :id=>22, :slug=>nil},
50
- {:name=>"Atari 5200", :id=>26, :slug=>nil},
51
- ...
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"},
52
69
  ```
53
70
 
54
71
  ### Get Platform Games OR Platform Games
@@ -69,29 +86,30 @@ http://wiki.thegamesdb.net/index.php/PlatformGames
69
86
  With id:
70
87
 
71
88
  ```ruby
72
- 2.1.2 :003 > Gamesdb.platform_games(6)
73
- => [{:name=>"Super Mario Kart", :id=>"41", :release_date=>"09/01/1992"},
74
- {:name=>"Final Fantasy VI", :id=>"83", :release_date=>"04/02/1994"},
75
- {:name=>"Contra III: The Alien Wars", :id=>"122", :release_date=>"04/06/1992"},
76
- {:name=>"Donkey Kong Country", :id=>"131", :release_date=>"11/21/1994"},
77
- {:name=>"Super Mario World", :id=>"136", :release_date=>"11/21/1990"},
78
- {:name=>"Super Mario World 2: Yoshi's Island", :id=>"137", :release_date=>"10/04/1995"},
79
- {:name=>"Mega Man X", :id=>"143", :release_date=>"01/01/1994"},
80
- {:name=>"Teenage Mutant Ninja Turtles IV: Turtles In Time", :id=>"188", :release_date=>"08/01/1992"},
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"},
81
98
  ...
82
99
  ```
83
100
 
84
101
  With slug:
85
102
 
86
103
  ```ruby
87
- 2.3.1 :001 > Gamesdb.platform_games("3do")
88
- => [
89
- {:name=>"Mad Dog McCree", :id=>"6429", :release_date=>"01/01/1994"},
90
- {:name=>"AD&D: Slayer", :id=>"3143", :release_date=>"01/01/1994"},
91
- {:name=>"Blade Force", :id=>"4826", :release_date=>"04/05/1995"},
92
- {:name=>"Battle Chess", :id=>"4829", :release_date=>"01/01/1993"},
93
- {:name=>"Brain Dead 13", :id=>"4830", :release_date=>"01/01/1996"},
94
- ...
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"},
95
113
  ```
96
114
 
97
115
  ### Get Platform
@@ -104,32 +122,36 @@ http://wiki.thegamesdb.net/index.php/GetPlatform
104
122
  * Returns: Hash with platform info
105
123
 
106
124
  ```ruby
107
- 2.3.1 :001 > Gamesdb.platform(6)
108
- => {:name=>"Super Nintendo (SNES)",
109
- :id=>"6",
110
- :Platform=>"Super Nintendo (SNES)",
111
- :console=>"http://www.youtube.com/watch?v=6.png",
112
- :controller=>"http://www.youtube.com/watch?v=6.png",
113
- :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...",
114
- :developer=>"Nintendo",
115
- :manufacturer=>"Nintendo",
116
- :cpu=>"16-bit 65c816 Ricoh 5A22 3.58 MHz",
117
- :memory=>"128kb",
118
- :sound=>"8-bit Sony SPC700",
119
- :display=>"512 × 239",
120
- :media=>"Cartridge",
121
- :maxcontrollers=>"2",
122
- :Youtube=>"http://www.youtube.com/watch?v=9fSAnVpJ42w",
123
- :Rating=>"7.5909",
124
- :Images=>{
125
- :boxart=>{
126
- :url=>"platform/boxart/6-2.jpg",
127
- :width=>"500",
128
- :height=>"750"
129
- },
130
- :console_art=>"platform/consoleart/6.png",
131
- :controller_image=>"platform/controllerart/6.png"
132
- }
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)"
133
155
  }
134
156
  ```
135
157
 
@@ -143,17 +165,39 @@ http://wiki.thegamesdb.net/index.php?title=GetGame
143
165
  * Returns: Array with games info in Hashes `:id`, `:title`, `:release_date`, `:platform`, `:overview`, `:publisher`, `:developer`, `:genres` (comma separated string), `:images {:front, :back}`
144
166
 
145
167
  ```ruby
146
- 2.1.2 :006 > Gamesdb.game(109)
147
- => {:id=>109,
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",
148
198
  :title=>"The Legend of Zelda: Twilight Princess",
149
- :release_date=>"11/19/2006",
150
- :platform=>"Nintendo Wii",
151
- :overview=>"In the next chapter in the Legend of Zelda series, Link can transform into a wolf to scour the darkened land of Hyrule. With the help of Midna, a mysterious being, you must guide Link through hordes of foul creatures and challenging bosses using new moves and a new horseback combat system. Many puzzles stand between Link and the fulfillment of his quest, so you must sharpen your wits as you hunt for weapons and items.",
152
- :publisher=>"Nintendo",
153
- :developer=>"Nintendo",
154
- :genres=>"Action, Adventure",
155
- :images=>{:back=>"boxart/original/back/109-1.jpg",
156
- :front=>"boxart/original/front/109-1.jpg"}}
199
+ :platform=>"Nintendo Wii"}
200
+
157
201
  ```
158
202
 
159
203
  ### Get Games List
@@ -166,13 +210,17 @@ http://wiki.thegamesdb.net/index.php/GetGamesList
166
210
  * Returns: Hash with game info: `:id`, `:name` (not-unique), `:release_date`, `platform`
167
211
 
168
212
  ```ruby
169
- 2.2.4 :001 > Gamesdb.games_list "Asterix"
170
- => [{:id=>"2981", :name=>"Asterix", :release_date=>"01/01/1991", :platform=>"Sega Master System"},
171
- {:id=>"3160", :name=>"Asterix", :release_date=>"01/01/1993", :platform=>"Super Nintendo (SNES)"},
172
- {:id=>"9243", :name=>"Asterix", :release_date=>"01/01/1983", :platform=>"Atari 2600"},
173
- {:id=>"21170", :name=>"Asterix", :release_date=>"01/01/1993", :platform=>"Nintendo Game Boy"},
174
- {:id=>"330", :name=>"Asterix", :release_date=>"03/23/2015", :platform=>"Nintendo Entertainment System (NES)"},
175
- ...
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"},
176
224
  ```
177
225
 
178
226
  ### Get Art
@@ -185,30 +233,20 @@ http://wiki.thegamesdb.net/index.php/GetArt
185
233
  * Returns: Hash with images: `logo`, `boxart` (Hash - front, back), `screenshots`, `fanart`
186
234
 
187
235
  ```ruby
188
- 2.2.4 :001 > Gamesdb.art(2208)
189
- => {
190
- :logo=>"clearlogo/2208.png",
191
- :boxart=>
192
- {
193
- :front=>{
194
- :url=>"boxart/original/front/2208-1.jpg", :width=>"2099",
195
- :height=>"1513",
196
- :thumb=>"boxart/thumb/original/front/2208-1.jpg"
197
- },
198
- :back=>{
199
- :url=>"boxart/original/front/2208-1.jpg",
200
- :width=>"2099",
201
- :height=>"1513",
202
- :thumb=>"boxart/thumb/original/front/2208-1.jpg"
203
- }
204
- },
205
- :screenshots=>[
206
- {:url=>"screenshots/2208-1.jpg", :width=>"768", :height=>"672", :thumb=>"screenshots/thumb/2208-1.jpg"},
207
- {:url=>"screenshots/2208-2.jpg", :width=>"768", :height=>"672", :thumb=>"screenshots/thumb/2208-2.jpg"},
208
- {:url=>"screenshots/2208-3.jpg", :width=>"768", :height=>"672", :thumb=>"screenshots/thumb/2208-3.jpg"}
209
- ],
210
- :fanart=>[]
211
- }
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
+ }
212
250
  ```
213
251
 
214
252
  ## Contributing
data/lib/thegamesdb.rb CHANGED
@@ -4,8 +4,8 @@ require 'net/http'
4
4
 
5
5
  # Client for TheGamesDB API (thegamesdb.net)
6
6
  module Gamesdb
7
- BASE_URL = 'http://thegamesdb.net/api/'
8
- IMAGES_BASE_URL = 'http://thegamesdb.net/banners/'
7
+ BASE_URL = 'http://legacy.thegamesdb.net/api/'
8
+ IMAGES_BASE_URL = 'http://legacy.thegamesdb.net/banners/'
9
9
 
10
10
  # Method for listing platform's games
11
11
  # http://wiki.thegamesdb.net/index.php?title=GetPlatformGames
@@ -16,7 +16,7 @@ module Gamesdb
16
16
  # == Returns:
17
17
  # Array of Hashes with games info
18
18
  def self.platform_games(platform)
19
- url = (platform.is_a? Numeric) ? 'GetPlatformGames.php' : 'PlatformGames.php'
19
+ url = platform.is_a?(Numeric) ? 'GetPlatformGames.php' : 'PlatformGames.php'
20
20
  data = xml_response(url, platform: platform)
21
21
  process_platform_games(data)
22
22
  end
@@ -34,11 +34,8 @@ module Gamesdb
34
34
  data = xml_response(url)
35
35
  platforms = []
36
36
 
37
- data.nodes[0].Platforms.nodes.each do |platform|
38
- id = platform.id.text
39
- name = platform.nodes[1].text
40
- slug = platform.respond_to?(:alias) ? platform.alias.text : ''
41
- platforms << { name: name, id: id.to_i, slug: slug }
37
+ data[:Platforms].first.last.each do |platform|
38
+ platforms << { name: platform[:name], id: platform[:id].to_i, slug: platform[:alias] }
42
39
  end
43
40
  platforms
44
41
  end
@@ -55,23 +52,9 @@ module Gamesdb
55
52
  #
56
53
  def self.platform(id)
57
54
  url = 'GetPlatform.php'
58
- data = xml_response(url, id: id).Data.Platform
59
- platform = { name: data.Platform.text }
60
- data.nodes.each do |node|
61
- platform[node.value.to_sym] = node.text
62
- end
63
- if data.Images
64
- platform[:Images] = {
65
- boxart: {
66
- url: data.Images.boxart.text,
67
- width: data.Images.boxart.attributes[:width],
68
- height: data.Images.boxart.attributes[:height]
69
- },
70
- console_art: data.Images.consoleart.text,
71
- controller_image: data.Images.controllerart.text
72
- }
73
- end
74
- platform
55
+ data = xml_response(url, id: id)[:Platform]
56
+ data[:name] = data.delete(:Platform)
57
+ data
75
58
  end
76
59
 
77
60
  # Method for getting game info
@@ -87,8 +70,8 @@ module Gamesdb
87
70
  def self.game(id)
88
71
  url = 'GetGame.php'
89
72
  data = xml_response(url, id: id)
90
- game = data.nodes[0].Game
91
- process_game(game)
73
+ game = process_game(data[:Game])
74
+ game
92
75
  end
93
76
 
94
77
  # The GetGamesList API search returns a listing of games matched up
@@ -108,7 +91,7 @@ module Gamesdb
108
91
  def self.games_list(name)
109
92
  url = 'GetGamesList.php'
110
93
  data = xml_response(url, name: name)
111
- build_games_list(data)
94
+ data[:Game].map { |game| process_game(game) }
112
95
  end
113
96
 
114
97
  # This API feature returns a list of available artwork types and
@@ -127,8 +110,26 @@ module Gamesdb
127
110
  #
128
111
  def self.art(id)
129
112
  url = 'GetArt.php'
130
- data = xml_response(url, id: id)
131
- build_images(data.Data.Images)
113
+ data = xml_response(url, id: id)[:Images]
114
+ data[:logo] = data[:clearlogo].last
115
+ data[:boxart] = process_covers(data[:boxart])
116
+ data
117
+ end
118
+
119
+ def self.process_covers(boxart)
120
+ boxart = boxart.flatten
121
+
122
+ covers = {}
123
+ 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]
130
+ }
131
+ end
132
+ covers
132
133
  end
133
134
 
134
135
  private
@@ -138,95 +139,34 @@ module Gamesdb
138
139
  uri = URI(BASE_URL + url)
139
140
  uri.query = URI.encode_www_form(params)
140
141
  request = Net::HTTP.get_response(uri)
141
- Ox.parse(request.body)
142
+ Ox.load(request.body, mode: :hash)[:Data]
142
143
  end
143
144
 
144
145
  # Process games for platform_games
145
146
  def self.process_platform_games(data)
146
147
  games = []
147
148
 
148
- data.nodes[0].nodes.each do |elem|
149
- name = elem.GameTitle.text
150
- id = elem.id.text
151
- date = nil
152
- # TODO: Fix this:
153
- begin
154
- date = elem.ReleaseDate.text
155
- rescue NoMethodError
156
- # No release date, nothing to do
157
- end
149
+ data.first.last.each do |elem|
150
+ name = elem[:GameTitle]
151
+ id = elem[:id].to_i
152
+ date = elem.dig(:ReleaseDate)
158
153
  games << { name: name, id: id, release_date: date }
159
154
  end
160
155
  games
161
156
  end
162
157
 
163
158
  def self.process_game(game)
164
- images = {}
165
- game.locate('Images/boxart').each do |a|
166
- key = a.attributes[:side].to_sym
167
- images[key] = a.text
168
- end
169
- {
170
- id: game.id.text.to_i, title: game.GameTitle.text,
171
- release_date: game.ReleaseDate.text, platform: game.Platform.text,
172
- overview: game.Overview.text, publisher: game.Publisher.text,
173
- developer: game.Developer.text,
174
- genres: game.Genres.nodes.map(&:text).join(', '),
175
- # esrb: game.ESRB.text, rating: game.Rating.text,
176
- images: images
177
- }
178
- end
179
-
180
- def self.build_games_list(data)
181
- games = []
182
- data.Data.nodes.each do |node|
183
- games << {
184
- id: node.nodes[0].nodes.first,
185
- name: node.nodes[1].nodes.first,
186
- release_date: node.nodes[2].nodes.first,
187
- platform: node.nodes[3].nodes.first
188
- }
189
- end
190
- games
191
- end
192
-
193
- # Process the XML into a hash with screenshots, box art and fan art
194
- # The URL's stored are the ones coming from the GamesDB, to access
195
- # the images append Gamesdb::IMAGES_BASE_URL to the urls.
196
- def self.build_images(data)
197
- boxart = data.nodes.select { |a| a.value == "boxart" }
198
- fanart = data.nodes.select { |a| a.value == "fanart" }
199
- screenshots = data.nodes.select{ |s| s.value == "screenshot"}
200
- images = {
201
- logo: data.clearlogo.text,
202
- boxart: build_boxart(boxart),
203
- screenshots: images_from_nodes(screenshots),
204
- fanart: images_from_nodes(fanart)
205
- }
206
- images
207
- end
208
-
209
- # Get the front and back box art into a Hash
210
- def self.build_boxart(boxart)
211
- front = boxart.select { |b| b.attributes[:side] == 'front' }[0]
212
- back = boxart.pop
213
- art = {}
214
- ['front', 'back'].each do |face|
215
- name = eval(face)
216
- art[face.to_sym] = {
217
- url: name.text,
218
- width: name.attributes[:width],
219
- height: name.attributes[:height],
220
- thumb: name.attributes[:thumb]
221
- }
222
- end
223
- art
159
+ game[:id] = game[:id].to_i
160
+ game[:name] = game.delete(:GameTitle)
161
+ game[:title] = game[:name]
162
+ game[:platform] = game.delete(:Platform)
163
+ game
224
164
  end
225
165
 
226
166
  # Method for processing the fan art and screenshots into a uniform
227
167
  # collection with url, width, height and thumb url
228
168
  def self.images_from_nodes(data)
229
- images = Array.new
169
+ images = []
230
170
  data.each do |art|
231
171
  images << {
232
172
  url: art.original.nodes[0],
@@ -237,5 +177,4 @@ module Gamesdb
237
177
  end
238
178
  images
239
179
  end
240
-
241
180
  end
@@ -1,4 +1,4 @@
1
1
  # Gem version
2
2
  module Gamesdb
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'.freeze
4
4
  end
@@ -0,0 +1,63 @@
1
+ require_relative './test_helper.rb'
2
+
3
+ describe "Gamesdb - games", :vcr do
4
+ describe 'game' do
5
+ before do
6
+ @game = Gamesdb.game(109)
7
+ end
8
+
9
+ it 'should have a valid id' do
10
+ @game[:id].must_be_kind_of Integer
11
+ @game[:id].must_equal 109
12
+ end
13
+
14
+ it 'should have valid fields' do
15
+ @game[:title].must_be_kind_of String
16
+ @game[:title].length.wont_be :<, 0
17
+ end
18
+ end
19
+
20
+ describe 'games_list' do
21
+ before do
22
+ @games_list = Gamesdb.games_list('turrican')
23
+ end
24
+
25
+ it 'should return a list' do
26
+ game = @games_list.first
27
+ game[:id].must_be_kind_of Integer
28
+ game[:name].must_be_kind_of String
29
+ game[:platform].must_be_kind_of String
30
+ end
31
+ end
32
+
33
+ describe 'games art', :vcr do
34
+ before do
35
+ @images = Gamesdb.art('216')
36
+ end
37
+
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
46
+
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
53
+ end
54
+
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
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,94 @@
1
+ describe "GamesDB - platforms", :vcr do
2
+ describe 'platforms' do
3
+ before do
4
+ @platforms = Gamesdb.platforms
5
+ end
6
+
7
+ it 'should get gaming platforms' do
8
+ @platforms.count.wont_be :<, 0
9
+ end
10
+
11
+ it 'should have a valid name' do
12
+ @platforms[0][:name].must_be_kind_of String
13
+ end
14
+
15
+ it 'should have a valid id' do
16
+ @platforms[0][:id].must_be_kind_of Integer
17
+ end
18
+
19
+ it 'should have a valid slug' do
20
+ @platforms[0][:slug].must_be_kind_of String
21
+ end
22
+ end
23
+
24
+ describe 'platform_games' do
25
+ before do
26
+ platforms = Gamesdb.platforms
27
+ @games_by_id = Gamesdb.platform_games(platforms[0][:id])
28
+ @games_by_slug = Gamesdb.platform_games(platforms[0][:slug])
29
+ end
30
+
31
+ it 'should return games in platform by id' do
32
+ @games_by_id.count.wont_be :<, 0
33
+ end
34
+
35
+ it 'should return games in platform' do
36
+ @games_by_slug.count.wont_be :<, 0
37
+ end
38
+ end
39
+
40
+ describe 'platform' do
41
+ describe 'assigning basic info' do
42
+ before do
43
+ @platform = Gamesdb.platform 6
44
+ end
45
+
46
+ it 'should return valid platform info' do
47
+ @platform[:name].must_equal 'Super Nintendo (SNES)'
48
+ @platform[:overview].must_be_kind_of String
49
+ @platform[:developer].must_be_kind_of String
50
+ @platform[:manufacturer].must_equal 'Nintendo'
51
+ @platform[:cpu].must_be_kind_of String
52
+ @platform[:memory].must_be_kind_of String
53
+ @platform[:sound].must_be_kind_of String
54
+ @platform[:display].must_be_kind_of String
55
+ 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
+ end
66
+
67
+ describe 'without hardware or images' do
68
+ before do
69
+ @platform = Gamesdb.platform 4916
70
+ end
71
+
72
+ it 'should return valid platform info' do
73
+ @platform[:name].must_equal 'Android'
74
+ @platform[:overview].must_be_kind_of String
75
+ @platform[:developer].must_be_kind_of String
76
+ @platform[:manufacturer].must_be_nil
77
+ @platform[:cpu].must_be_nil
78
+ @platform[:memory].must_be_nil
79
+ @platform[:sound].must_be_nil
80
+ @platform[:display].must_be_nil
81
+ 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
+ end
93
+ end
94
+ end
@@ -0,0 +1,16 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+ require 'minitest/autorun'
4
+ require 'minitest/reporters'
5
+ require 'minitest/spec'
6
+ require 'vcr'
7
+ require "minitest-vcr"
8
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
9
+ MinitestVcr::Spec.configure!
10
+
11
+ require 'thegamesdb'
12
+
13
+ VCR.configure do |c|
14
+ c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
15
+ c.hook_into :webmock
16
+ end
data/thegamesdb.gemspec CHANGED
@@ -1,5 +1,5 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
+
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'thegamesdb/version'
5
5
 
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
  spec.add_runtime_dependency 'ox', '~> 2.1'
21
21
  spec.add_development_dependency 'bundler', '~> 1.5'
22
- spec.add_development_dependency 'rake'
23
- spec.add_development_dependency 'vcr', '~> 2.9'
24
- spec.add_development_dependency 'minitest'
25
- spec.add_development_dependency 'minitest-reporters'
26
- spec.add_development_dependency 'webmock'
27
22
  spec.add_development_dependency 'byebug'
23
+ spec.add_development_dependency 'minitest-reporters'
24
+ spec.add_development_dependency 'minitest-vcr'
25
+ spec.add_development_dependency 'rake'
28
26
  spec.add_development_dependency 'simplecov'
27
+ spec.add_development_dependency 'vcr', '~> 4'
28
+ spec.add_development_dependency 'webmock'
29
29
  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: 0.1.2
4
+ version: 0.2.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: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2018-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: byebug
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,21 +53,21 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: vcr
56
+ name: minitest-reporters
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '2.9'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '2.9'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: minitest
70
+ name: minitest-vcr
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: minitest-reporters
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: webmock
98
+ name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,21 +109,21 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: byebug
112
+ name: vcr
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '4'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '4'
125
125
  - !ruby/object:Gem::Dependency
126
- name: simplecov
126
+ name: webmock
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -144,13 +144,16 @@ extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
146
  - ".gitignore"
147
+ - ".travis.yml"
147
148
  - Gemfile
148
149
  - LICENSE.txt
149
150
  - README.md
150
151
  - Rakefile
151
152
  - lib/thegamesdb.rb
152
153
  - lib/thegamesdb/version.rb
153
- - test/gamesdb_test.rb
154
+ - test/games_test.rb
155
+ - test/platform_test.rb
156
+ - test/test_helper.rb
154
157
  - thegamesdb.gemspec
155
158
  homepage: http://github.com/picandocodigo/gamesdb
156
159
  licenses:
@@ -172,9 +175,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
175
  version: '0'
173
176
  requirements: []
174
177
  rubyforge_project:
175
- rubygems_version: 2.5.1
178
+ rubygems_version: 2.7.6
176
179
  signing_key:
177
180
  specification_version: 4
178
181
  summary: Client for TheGamesDB API (thegamesdb.net).
179
182
  test_files:
180
- - test/gamesdb_test.rb
183
+ - test/games_test.rb
184
+ - test/platform_test.rb
185
+ - test/test_helper.rb
data/test/gamesdb_test.rb DELETED
@@ -1,162 +0,0 @@
1
- require 'simplecov'
2
- SimpleCov.start
3
- require 'vcr'
4
- require 'minitest/spec'
5
- require 'minitest/autorun'
6
- require "minitest/reporters"
7
- Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
8
- require 'thegamesdb'
9
-
10
- VCR.configure do |c|
11
- c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
12
- c.hook_into :webmock
13
- end
14
-
15
- describe Gamesdb do
16
-
17
- describe 'platforms' do
18
- before do
19
- VCR.insert_cassette('platforms')
20
- @platforms = Gamesdb.platforms
21
- end
22
-
23
- after do
24
- VCR.eject_cassette
25
- end
26
-
27
- it 'should get gaming platforms' do
28
- @platforms.count.wont_be :<, 0
29
- end
30
-
31
- it 'should have a valid name' do
32
- @platforms[0][:name].must_be_kind_of String
33
- end
34
-
35
- it 'should have a valid id' do
36
- @platforms[0][:id].must_be_kind_of Integer
37
- end
38
-
39
- it 'should have a valid slug' do
40
- @platforms[0][:slug].must_be_kind_of String
41
- end
42
- end
43
-
44
- describe 'platform_games' do
45
- before do
46
- VCR.insert_cassette('platform_games')
47
- platforms = Gamesdb.platforms
48
- @games_by_id = Gamesdb.platform_games(platforms[0][:id])
49
- @games_by_slug = Gamesdb.platform_games(platforms[0][:slug])
50
- end
51
-
52
- after do
53
- VCR.eject_cassette
54
- end
55
-
56
- it 'should return games in platform by id' do
57
- @games_by_id.count.wont_be :<, 0
58
- end
59
-
60
- it 'should return games in platform' do
61
- @games_by_slug.count.wont_be :<, 0
62
- end
63
- end
64
-
65
- describe 'platform' do
66
- before do
67
- VCR.insert_cassette('platform')
68
- @platform = Gamesdb.platform 6
69
- end
70
-
71
- after do
72
- VCR.eject_cassette
73
- end
74
-
75
- it 'should return valid platform info' do
76
- @platform[:name].must_equal 'Super Nintendo (SNES)'
77
- @platform[:overview].must_be_kind_of String
78
- @platform[:developer].must_be_kind_of String
79
- @platform[:manufacturer].must_equal 'Nintendo'
80
- @platform[:cpu].must_be_kind_of String
81
- @platform[:memory].must_be_kind_of String
82
- @platform[:sound].must_be_kind_of String
83
- @platform[:display].must_be_kind_of String
84
- end
85
- end
86
-
87
- describe 'game' do
88
- before do
89
- VCR.insert_cassette('game')
90
- @game = Gamesdb.game(109)
91
- end
92
-
93
- after do
94
- VCR.eject_cassette
95
- end
96
-
97
- it 'should have a valid id' do
98
- @game[:id].must_be_kind_of Integer
99
- @game[:id].must_equal 109
100
- end
101
-
102
- it 'should have valid fields' do
103
- @game[:title].must_be_kind_of String
104
- @game[:title].length.wont_be :<, 0
105
- end
106
- end
107
-
108
- describe 'games_list' do
109
- before do
110
- VCR.insert_cassette('games_list')
111
- @games_list = Gamesdb.games_list('asterix')
112
- end
113
-
114
- after do
115
- VCR.eject_cassette
116
- end
117
-
118
- it 'should return a list' do
119
- @games_list.count.wont_be :<, 0
120
- game = @games_list.first
121
- game[:id].must_be_kind_of String
122
- game[:name].must_be_kind_of String
123
- game[:platform].must_be_kind_of String
124
- end
125
- end
126
-
127
- describe 'games art' do
128
- before do
129
- VCR.insert_cassette('game_art')
130
- @images = Gamesdb.art("216")
131
- end
132
-
133
- after do
134
- VCR.eject_cassette
135
- end
136
-
137
- it 'should return logo and boxart' do
138
- @images[:boxart].count.wont_be :<, 0
139
- @images[:logo].must_be_kind_of String
140
- @images[:boxart][:front][:url].must_be_kind_of String
141
- @images[:boxart][:front][:width].must_be_kind_of String
142
- @images[:boxart][:front][:height].must_be_kind_of String
143
- @images[:boxart][:front][:thumb].must_be_kind_of String
144
- end
145
-
146
- it 'should return screenshots' do
147
- @images[:screenshots].count.wont_be :<, 0
148
- @images[:screenshots].first[:url].must_be_kind_of String
149
- @images[:screenshots].first[:width].must_be_kind_of String
150
- @images[:screenshots].first[:height].must_be_kind_of String
151
- @images[:screenshots].first[:thumb].must_be_kind_of String
152
- end
153
-
154
- it 'should return fanart' do
155
- @images[:fanart].count.wont_be :<, 0
156
- @images[:fanart].first[:url].must_be_kind_of String
157
- @images[:fanart].first[:width].must_be_kind_of String
158
- @images[:fanart].first[:height].must_be_kind_of String
159
- @images[:fanart].first[:thumb].must_be_kind_of String
160
- end
161
- end
162
- end