giantbomb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +5 -0
- data/README +18 -0
- data/Rakefile +2 -0
- data/giantbomb.gemspec +21 -0
- data/lib/giantbomb.rb +10 -0
- data/lib/giantbomb/api.rb +11 -0
- data/lib/giantbomb/game.rb +83 -0
- data/lib/giantbomb/search.rb +62 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
A Ruby wrapper for the GiantBomb API.
|
2
|
+
|
3
|
+
Configuration:
|
4
|
+
|
5
|
+
GiantBomb::Api.key(API_KEY_HERE)
|
6
|
+
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
search = GiantBomb::Search.new
|
11
|
+
search.limit(10) # optional - limits number of items returned
|
12
|
+
search.resources('game') # optional - specifies types of resource to search
|
13
|
+
search.fields('name,deck') # optional - specifies fields to return
|
14
|
+
search.offset(100) # optional - number of items to offset by
|
15
|
+
search.query('duke nukem') # required - the search term
|
16
|
+
|
17
|
+
results = search.fetch
|
18
|
+
|
data/Rakefile
ADDED
data/giantbomb.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "giantbomb"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "giantbomb"
|
7
|
+
s.version = GiantBomb::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Robert Coker"]
|
10
|
+
s.email = ["rob@robertsays.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/giantbomb"
|
12
|
+
s.summary = %q{A Ruby wrapper for the GiantBomb API.}
|
13
|
+
s.description = %q{Provides a simple, easy to use interface for the GiantBomb API.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "giantbomb"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/giantbomb.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Game < Api
|
3
|
+
# http://api.giantbomb.com/documentation/#game
|
4
|
+
@@fields = [
|
5
|
+
:aliases, # List of aliases the game is known by. A \n (newline) separates each alias.
|
6
|
+
:api_detail_url, # URL pointing to the game detail resource
|
7
|
+
:characters, # Characters related to the game
|
8
|
+
:concepts, # Concepts related to the game
|
9
|
+
:date_added, # Date the game was added to Giant Bomb
|
10
|
+
:date_last_updated, # Date the game was last updated on Giant Bomb
|
11
|
+
:deck, # Brief summary of the game
|
12
|
+
:description, # Description of the game
|
13
|
+
:developers, # Companies that developed the game
|
14
|
+
:expected_release_month, # Expected month the game will be released in. The month is represented numerically.
|
15
|
+
:expected_release_quarter, # Expected quarter game will be released in. The quarter is represented numerically, where 1 = Q1, 2 = Q2, 3 = Q3, and 4 = Q4.
|
16
|
+
:expected_release_year, # Expected year the game will be released in.
|
17
|
+
:first_appearance_characters, # Characters that first appeared in the game
|
18
|
+
:first_appearance_concepts, # Concepts that first appeared in the game
|
19
|
+
:first_appearance_locations, # Locations that first appeared in the game
|
20
|
+
:first_appearance_objects, # Objects that first appeared in the game
|
21
|
+
:first_appearance_people, # People that were first credited in the game
|
22
|
+
:franchises, # Franchises the game is a part of
|
23
|
+
:genres, # Genres that encompass the game
|
24
|
+
:id, # Unique ID of the game
|
25
|
+
:image, # Main Image of the game
|
26
|
+
:images, # List of images associated to the game
|
27
|
+
:killed_characters, # Characters killed in the game
|
28
|
+
:locations, # Locations related to the game
|
29
|
+
:name, # Name of the game
|
30
|
+
:number_of_user_reviews, # Number of user reviews of the game on Giant Bomb
|
31
|
+
:objects, # Objects related to the game
|
32
|
+
:original_game_rating, # Rating of the first release of the game
|
33
|
+
:original_release_date, # Date the game was first released
|
34
|
+
:people, # People related to the game
|
35
|
+
:platforms, # Platforms the game can be played on
|
36
|
+
:publishers, # Companies that published the game
|
37
|
+
:releases, # Releases of the game
|
38
|
+
:reviews, # Staff reviews of the game
|
39
|
+
:similar_games, # Other games that are similar to the game
|
40
|
+
:site_detail_url, # URL pointing to the game on Giant Bomb
|
41
|
+
:themes, # Themes that encompass the game
|
42
|
+
:videos # Videos associated to the game
|
43
|
+
]
|
44
|
+
|
45
|
+
@@fields.each do |field|
|
46
|
+
attr_accessor field
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(attributes={})
|
50
|
+
attributes.each do |key, value|
|
51
|
+
if self.respond_to?(key.to_sym)
|
52
|
+
self.instance_variable_set("@#{key}", value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.detail(id, conditions={})
|
58
|
+
search = GiantBomb::Search.new("/game/#{id}/")
|
59
|
+
search.filter(conditions)
|
60
|
+
Game.new(search.fetch)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.list(conditions={})
|
64
|
+
search = GiantBomb::Search.new("/games")
|
65
|
+
search.filter(conditions)
|
66
|
+
search.fetch.collect do |result|
|
67
|
+
Game.new(result)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.search(query)
|
72
|
+
search = GiantBomb::Search.new
|
73
|
+
search.resources('game')
|
74
|
+
search.query(query)
|
75
|
+
search.fetch
|
76
|
+
end
|
77
|
+
|
78
|
+
class << self
|
79
|
+
alias_method :find, :search
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Search < Api
|
3
|
+
attr_reader :query, :resource
|
4
|
+
|
5
|
+
def initialize(resource=nil)
|
6
|
+
@params = {}
|
7
|
+
@resource = resource.nil? ? '/search' : resource
|
8
|
+
self
|
9
|
+
end
|
10
|
+
|
11
|
+
# GiantBomb::Search.new.fields('name,deck')
|
12
|
+
def fields(fields)
|
13
|
+
@params[:field_list] = "#{fields}"
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
# GiantBomb::Search.new.limit(1)
|
18
|
+
def limit(limit)
|
19
|
+
@params[:limit] = "#{limit}"
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
# GiantBomb::Search.new.offset(100)
|
24
|
+
def offset(offset)
|
25
|
+
@params[:offset] = "#{offset}"
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
# GiantBomb::Search.new.query('duke nukem')
|
30
|
+
def query(query)
|
31
|
+
@params[:query] = "#{query}"
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
# GiantBomb::Search.new.resources('game')
|
36
|
+
def resources(resources)
|
37
|
+
@params[:resources] = "#{resources}"
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
# a convenience method that takes a hash where each key is
|
42
|
+
# the symbol of a method, and each value is the parameters
|
43
|
+
# passed to that method.
|
44
|
+
def filter(conditions)
|
45
|
+
if conditions
|
46
|
+
conditions.each do |key, value|
|
47
|
+
if self.respond_to?(key)
|
48
|
+
self.send(key, value)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# GiantBomb::Search.new.query('duke nukem').fetch
|
55
|
+
def fetch
|
56
|
+
options = @params.merge(@@config)
|
57
|
+
response = self.class.get(@resource, :query => options)
|
58
|
+
response['results']
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: giantbomb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Robert Coker
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-10 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Provides a simple, easy to use interface for the GiantBomb API.
|
23
|
+
email:
|
24
|
+
- rob@robertsays.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- README
|
35
|
+
- Rakefile
|
36
|
+
- giantbomb.gemspec
|
37
|
+
- lib/giantbomb.rb
|
38
|
+
- lib/giantbomb/api.rb
|
39
|
+
- lib/giantbomb/game.rb
|
40
|
+
- lib/giantbomb/search.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://rubygems.org/gems/giantbomb
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: giantbomb
|
71
|
+
rubygems_version: 1.4.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: A Ruby wrapper for the GiantBomb API.
|
75
|
+
test_files: []
|
76
|
+
|