gamesdb 0.0.1 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  gamesdb (0.0.1)
5
+ awesome_print
5
6
  cistern
6
7
  excon
7
8
  nokogiri
@@ -10,7 +11,8 @@ PATH
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- cistern (0.1.4)
14
+ awesome_print (1.1.0)
15
+ cistern (0.2.1)
14
16
  coderay (1.0.8)
15
17
  diff-lcs (1.1.3)
16
18
  excon (0.16.10)
@@ -26,7 +28,7 @@ GEM
26
28
  lumberjack (1.0.2)
27
29
  method_source (0.8.1)
28
30
  mime-types (1.21)
29
- nokogiri (1.5.5)
31
+ nokogiri (1.5.6)
30
32
  pry (0.9.10)
31
33
  coderay (~> 1.0.5)
32
34
  method_source (~> 0.8)
@@ -20,4 +20,5 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'excon'
21
21
  gem.add_dependency 'nokogiri'
22
22
  gem.add_dependency 'rest-client'
23
+ gem.add_dependency 'awesome_print'
23
24
  end
@@ -4,6 +4,9 @@ require 'excon'
4
4
  require 'nokogiri'
5
5
  require 'cistern'
6
6
  require 'rest-client'
7
+ require 'awesome_print'
8
+
9
+ Cistern.formatter = Cistern::Formatter::AwesomePrint
7
10
 
8
11
  module Gamesdb
9
12
  autoload :Client, 'gamesdb/client'
@@ -6,6 +6,13 @@ class Gamesdb::Client < Cistern::Service
6
6
  model :game
7
7
  collection :games
8
8
  request :list_games
9
+ request :get_game
10
+
11
+ model :platform
12
+ collection :platforms
13
+ request :list_platforms
14
+ request :get_platform
15
+ request :get_platform_games
9
16
 
10
17
  class Real
11
18
  attr_reader :connection
@@ -23,7 +30,7 @@ class Gamesdb::Client < Cistern::Service
23
30
  headers = options[:headers] || {}
24
31
  body = options[:body] || nil
25
32
  expects = options[:expects] || 200
26
- query = options[:query] || nil
33
+ query = options[:query] || {}
27
34
 
28
35
  connect_hash = {
29
36
  :method => method,
@@ -2,6 +2,21 @@ class Gamesdb::Client::Game < Cistern::Model
2
2
  identity :id
3
3
 
4
4
  attribute :game_title, aliases: "GameTitle"
5
- attribute :release_data, aliases: "ReleaseDate"
5
+ attribute :release_date, aliases: "ReleaseDate"
6
6
  attribute :platform, aliases: "Platform"
7
+ attribute :overview, aliases: "Overview"
8
+ attribute :esrb, aliases: "ESRB"
9
+ attribute :genres, aliases: "Genres", squash: "genre"
10
+ attribute :players, aliases: "Players"
11
+ attribute :coop, aliases: "Co-op"
12
+ attribute :youtube, aliases: "Youtube"
13
+ attribute :publisher, aliases: "Publisher"
14
+ attribute :developer, aliases: "Developer"
15
+ attribute :rating, aliases: "Rating"
16
+ attribute :fanart, squash: "Images", type: Array
17
+ attribute :boxart, squash: "Images", type: Array
18
+ attribute :banner, squash: "Images", type: Array
19
+ attribute :screenshot, squash: "Images", type: Array
20
+ attribute :thumb, squash: "Images", type: Array
21
+ attribute :clearlogo, squash: "Images", type: Array
7
22
  end
@@ -7,4 +7,10 @@ class Gamesdb::Client::Games < Cistern::Collection
7
7
  self.clone.load(data)
8
8
  end
9
9
  end
10
+
11
+ def get(id)
12
+ if data = self.connection.get_game(id)["Game"]
13
+ self.clone.new(data)
14
+ end
15
+ end
10
16
  end
@@ -0,0 +1,29 @@
1
+ class Gamesdb::Client::Platform < Cistern::Model
2
+ identity :id
3
+
4
+ attribute :name
5
+ attribute :alias
6
+ attribute :console
7
+ attribute :controller
8
+ attribute :overview
9
+ attribute :developer
10
+ attribute :manufacturer
11
+ attribute :cpu
12
+ attribute :memory
13
+ attribute :graphics
14
+ attribute :sound
15
+ attribute :display
16
+ attribute :media
17
+ attribute :maxcontrollers
18
+ attribute :rating, aliases: "Rating"
19
+ attribute :fanart, squash: "Images", type: Array
20
+ attribute :boxart, squash: "Images", type: Array
21
+ attribute :banner, squash: "Images", type: Array
22
+ attribute :consoleart, squash: "Images", type: Array
23
+ attribute :controllerart, squash: "Images", type: Array
24
+
25
+ def games
26
+ data = connection.get_platform_games(identity)["Game"]
27
+ connection.games.load(data)
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ class Gamesdb::Client::Platforms < Cistern::Collection
2
+
3
+ model Gamesdb::Client::Platform
4
+
5
+ def all
6
+ if data = self.connection.list_platforms["Platforms"]["Platform"]
7
+ self.clone.load(data)
8
+ end
9
+ end
10
+
11
+ def get(id)
12
+ if data = self.connection.get_platform(id)["Platform"]
13
+ self.clone.new(data)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ class Gamesdb::Client
2
+ class Real
3
+ def get_game(id)
4
+ request(
5
+ :path => "/GetGame.php",
6
+ :query => {"id" => id}
7
+ )
8
+ end
9
+ end
10
+
11
+ class Mock
12
+ def get_game(id)
13
+ YAML.load_file(File.expand_path("../../seeds/games.yaml", __FILE__))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ class Gamesdb::Client
2
+ class Real
3
+ def get_platform(id)
4
+ request(
5
+ :path => "/GetPlatform.php",
6
+ :query => {"id" => id}
7
+ )
8
+ end
9
+ end
10
+
11
+ class Mock
12
+ def get_platform
13
+ YAML.load_file(File.expand_path("../../seeds/platforms.yaml", __FILE__))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ class Gamesdb::Client
2
+ class Real
3
+ def get_platform_games(id)
4
+ request(
5
+ :path => "/GetPlatformGames.php",
6
+ :query => {"platform" => id}
7
+ )
8
+ end
9
+ end
10
+
11
+ class Mock
12
+ def get_platform_games(id)
13
+ games = YAML.load_file(File.expand_path("../../seeds/games.yaml", __FILE__))["Game"]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ class Gamesdb::Client
2
+ class Real
3
+ def list_platforms
4
+ request(
5
+ :path => "/GetPlatformsList.php"
6
+ )
7
+ end
8
+ end
9
+
10
+ class Mock
11
+ def list_games
12
+ YAML.load_file(File.expand_path("../../seeds/platforms.yaml", __FILE__))
13
+ end
14
+ end
15
+ end
@@ -11,9 +11,7 @@ class Gamesdb::SaxDocument < Nokogiri::XML::SAX::Document
11
11
  end
12
12
 
13
13
  def body
14
- @stack.first.each do |key, value|
15
- @stack.first[key] = [value] if value.is_a?(Hash)
16
- end
14
+ @stack.first
17
15
  end
18
16
 
19
17
  def end_element(name)
@@ -0,0 +1,146 @@
1
+ ---
2
+ basePlatformUrl: http://thegamesdb.net/platform/
3
+ Platforms:
4
+ - Platform:
5
+ - id: '25'
6
+ name: 3DO
7
+ alias: 3do
8
+ - id: '4911'
9
+ name: Amiga
10
+ alias: amiga
11
+ - id: '4914'
12
+ name: Amstrad CPC
13
+ alias: amstrad-cpc
14
+ - id: '4916'
15
+ name: Android
16
+ - id: '23'
17
+ name: Arcade
18
+ alias: arcade
19
+ - id: '22'
20
+ name: Atari 2600
21
+ alias: atari-2600
22
+ - id: '26'
23
+ name: Atari 5200
24
+ alias: atari-5200
25
+ - id: '27'
26
+ name: Atari 7800
27
+ alias: atari-7800
28
+ - id: '28'
29
+ name: Atari Jaguar
30
+ alias: atari-jaguar
31
+ - id: '29'
32
+ name: Atari Jaguar CD
33
+ alias: atari-jaguar-cd
34
+ - id: '30'
35
+ name: Atari XE
36
+ alias: atari-xe
37
+ - id: '31'
38
+ name: Colecovision
39
+ alias: colecovision
40
+ - id: '40'
41
+ name: Commodore 64
42
+ alias: commodore-64
43
+ - id: '32'
44
+ name: Intellivision
45
+ alias: intellivision
46
+ - id: '4915'
47
+ name: IOS
48
+ - id: '37'
49
+ name: Mac OS
50
+ alias: mac-os
51
+ - id: '14'
52
+ name: Microsoft Xbox
53
+ alias: microsoft-xbox
54
+ - id: '15'
55
+ name: Microsoft Xbox 360
56
+ alias: microsoft-xbox-360
57
+ - id: '24'
58
+ name: NeoGeo
59
+ alias: neogeo
60
+ - id: '4912'
61
+ name: Nintendo 3DS
62
+ alias: nintendo-3ds
63
+ - id: '3'
64
+ name: Nintendo 64
65
+ alias: nintendo-64
66
+ - id: '8'
67
+ name: Nintendo DS
68
+ alias: nintendo-ds
69
+ - id: '7'
70
+ name: Nintendo Entertainment System (NES)
71
+ alias: nintendo-entertainment-system-nes
72
+ - id: '4'
73
+ name: Nintendo Game Boy
74
+ alias: nintendo-gameboy
75
+ - id: '5'
76
+ name: Nintendo Game Boy Advance
77
+ alias: nintendo-gameboy-advance
78
+ - id: '41'
79
+ name: Nintendo Game Boy Color
80
+ alias: nintendo-gameboy-color
81
+ - id: '2'
82
+ name: Nintendo GameCube
83
+ alias: nintendo-gamecube
84
+ - id: '4918'
85
+ name: Nintendo Virtual Boy
86
+ alias: nintendo-virtual-boy
87
+ - id: '9'
88
+ name: Nintendo Wii
89
+ alias: nintendo-wii
90
+ - id: '38'
91
+ name: Nintendo Wii U
92
+ alias: nintendo-wii-u
93
+ - id: '1'
94
+ name: PC
95
+ alias: pc
96
+ - id: '4917'
97
+ name: Philips CD-i
98
+ alias: philips-cd-i
99
+ - id: '33'
100
+ name: Sega 32X
101
+ alias: sega-32x
102
+ - id: '21'
103
+ name: Sega CD
104
+ alias: sega-cd
105
+ - id: '16'
106
+ name: Sega Dreamcast
107
+ alias: sega-dreamcast
108
+ - id: '20'
109
+ name: Sega Game Gear
110
+ alias: sega-game-gear
111
+ - id: '18'
112
+ name: Sega Genesis
113
+ alias: sega-genesis
114
+ - id: '35'
115
+ name: Sega Master System
116
+ alias: sega-master-system
117
+ - id: '36'
118
+ name: Sega Mega Drive
119
+ alias: sega-mega-drive
120
+ - id: '17'
121
+ name: Sega Saturn
122
+ alias: sega-saturn
123
+ - id: '4913'
124
+ name: Sinclair ZX Spectrum
125
+ alias: sinclair-zx-spectrum
126
+ - id: '10'
127
+ name: Sony Playstation
128
+ alias: sony-playstation
129
+ - id: '11'
130
+ name: Sony Playstation 2
131
+ alias: sony-playstation-2
132
+ - id: '12'
133
+ name: Sony Playstation 3
134
+ alias: sony-playstation-3
135
+ - id: '39'
136
+ name: Sony Playstation Vita
137
+ alias: sony-playstation-vita
138
+ - id: '13'
139
+ name: Sony PSP
140
+ alias: sony-psp
141
+ - id: '6'
142
+ name: Super Nintendo (SNES)
143
+ alias: super-nintendo-snes
144
+ - id: '34'
145
+ name: TurboGrafx 16
146
+ alias: turbografx-16
@@ -1,3 +1,3 @@
1
1
  module Gamesdb
2
- Version = "0.0.1"
2
+ Version = "1.0"
3
3
  end
@@ -7,4 +7,10 @@ describe "Gamesdb::Games" do
7
7
  games.should_not be_empty
8
8
  games.first.should be_a_kind_of(Gamesdb::Client::Game)
9
9
  end
10
+
11
+ it "should get a game" do
12
+ game = client.games.get(15)
13
+ game.should_not be_nil
14
+ game.should be_a_kind_of(Gamesdb::Client::Game)
15
+ end
10
16
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Gamesdb::Platforms" do
4
+ let(:client) { create_client }
5
+ it "should have platforms" do
6
+ platforms = client.platforms.all
7
+ platforms.should_not be_empty
8
+ platforms.first.should be_a_kind_of(Gamesdb::Client::Platform)
9
+ end
10
+
11
+ it "should get a platform" do
12
+ platform = client.platforms.get(15)
13
+ platform.should_not be_nil
14
+ platform.should be_a_kind_of(Gamesdb::Client::Platform)
15
+ end
16
+
17
+ it "should have platform games" do
18
+ platform = client.platforms.get(15)
19
+ platform.games.should_not be_nil
20
+ platform.games.first.should be_a_kind_of(Gamesdb::Client::Game)
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamesdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: '1.0'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: awesome_print
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
78
94
  description:
79
95
  email: eugene@xtreme-computers.net
80
96
  executables: []
@@ -89,11 +105,19 @@ files:
89
105
  - lib/gamesdb/client.rb
90
106
  - lib/gamesdb/models/game.rb
91
107
  - lib/gamesdb/models/games.rb
108
+ - lib/gamesdb/models/platform.rb
109
+ - lib/gamesdb/models/platforms.rb
110
+ - lib/gamesdb/requests/get_game.rb
111
+ - lib/gamesdb/requests/get_platform.rb
112
+ - lib/gamesdb/requests/get_platform_games.rb
92
113
  - lib/gamesdb/requests/list_games.rb
114
+ - lib/gamesdb/requests/list_platforms.rb
93
115
  - lib/gamesdb/saxdocument.rb
94
116
  - lib/gamesdb/seeds/games.yaml
117
+ - lib/gamesdb/seeds/platforms.yaml
95
118
  - lib/gamesdb/version.rb
96
119
  - spec/games_spec.rb
120
+ - spec/platforms_spec.rb
97
121
  - spec/spec_helper.rb
98
122
  - spec/support/client_helper.rb
99
123
  homepage: https://github.com/ehowe/gamesdb.git