giantbomb 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +1 -2
- data/README.textile +41 -0
- data/giantbomb.gemspec +4 -2
- data/lib/giantbomb.rb +6 -2
- data/lib/giantbomb/concept.rb +36 -0
- data/lib/giantbomb/franchise.rb +30 -0
- data/lib/giantbomb/location.rb +25 -0
- data/lib/giantbomb/object.rb +34 -0
- data/lib/giantbomb/person.rb +39 -0
- data/lib/giantbomb/resource.rb +7 -7
- data/lib/giantbomb/search.rb +37 -7
- data/lib/giantbomb/video.rb +23 -0
- metadata +27 -8
- data/README +0 -18
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.textile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
h1. A Ruby wrapper for the GiantBomb API
|
2
|
+
|
3
|
+
h2. Configuration
|
4
|
+
|
5
|
+
GiantBomb::Api.key(API_KEY_HERE)
|
6
|
+
|
7
|
+
h2. Resources
|
8
|
+
|
9
|
+
Current available resources:
|
10
|
+
* Game
|
11
|
+
* Company
|
12
|
+
* Character
|
13
|
+
|
14
|
+
All resources have access to Resource#list, Resource#detail, and Resource#search.
|
15
|
+
|
16
|
+
h3. Example
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
@game = Game.detail(1)
|
20
|
+
@games = Game.find("Duke Nukem")
|
21
|
+
@games = Game.list
|
22
|
+
</pre>
|
23
|
+
|
24
|
+
h2. Search
|
25
|
+
|
26
|
+
GiantBomb::Search defaults to using the GiantBomb search resource and is the basis for all other resource requests. The implementation is inspired by jnunemaker's Twitter library.
|
27
|
+
|
28
|
+
All of the "filter" methods in GiantBomb::Search are chainable.
|
29
|
+
|
30
|
+
h3. Usage
|
31
|
+
|
32
|
+
<pre>
|
33
|
+
@search = GiantBomb::Search.new
|
34
|
+
@search.limit(10) # limits number of returned resources
|
35
|
+
@search.resources('game') # determines type(s) of resources
|
36
|
+
@search.fields('name,deck') # limits fields returned
|
37
|
+
@search.offset(100) # sets the offset
|
38
|
+
@search.query('duke nukem') # the query to search against
|
39
|
+
@search.fetch # makes request
|
40
|
+
</pre>
|
41
|
+
|
data/giantbomb.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Robert Coker"]
|
10
10
|
s.email = ["rob@robertsays.com"]
|
11
11
|
s.homepage = "http://rubygems.org/gems/giantbomb"
|
12
|
-
s.summary = %q{A Ruby wrapper for the
|
13
|
-
s.description = %q{Provides a simple, easy to use interface for the
|
12
|
+
s.summary = %q{A Ruby wrapper for the Giant Bomb video game wiki API.}
|
13
|
+
s.description = %q{Provides a simple, easy to use interface for the Giant Bomb video game wiki API.}
|
14
14
|
|
15
15
|
s.rubyforge_project = "giantbomb"
|
16
16
|
|
@@ -18,4 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency('httparty')
|
21
23
|
end
|
data/lib/giantbomb.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'httparty'
|
3
3
|
|
4
|
-
["api",
|
4
|
+
["api","search","resource"].each do |inc|
|
5
|
+
require File.join(File.dirname(__FILE__), "giantbomb", inc)
|
6
|
+
end
|
7
|
+
|
8
|
+
["game","company","character","franchise","concept","object","location","person","video"].each do |inc|
|
5
9
|
require File.join(File.dirname(__FILE__), "giantbomb", inc)
|
6
10
|
end
|
7
11
|
|
8
12
|
module GiantBomb
|
9
|
-
VERSION = "0.
|
13
|
+
VERSION = "0.5.0"
|
10
14
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Concept < Resource
|
3
|
+
has_resource 'concept', :plural => 'concepts'
|
4
|
+
|
5
|
+
# http://api.giantbomb.com/documentation/#concept
|
6
|
+
@@fields = [
|
7
|
+
:aliases, # List of aliases the concept is known by. A \n (newline) separates each alias.
|
8
|
+
:api_detail_url, # URL pointing to the concept detail resource
|
9
|
+
:characters, # Characters related to the concept
|
10
|
+
:companies, # Companies related to the concept
|
11
|
+
:concepts, # Other concepts related to the concept
|
12
|
+
:date_added, # Date the concept was added to Giant Bomb
|
13
|
+
:date_last_updated, # Date the concept was last updated on Giant Bomb
|
14
|
+
:deck, # Brief summary of the concept
|
15
|
+
:description, # Description of the concept
|
16
|
+
:first_appeared_in_franchise, # Franchise that the concept first appeared in
|
17
|
+
:first_appeared_in_game, # Game that the concept first appeared in
|
18
|
+
:franchises, # Franchises related to the concept
|
19
|
+
:games, # Games related to the concept
|
20
|
+
:id, # Unique ID of the concept
|
21
|
+
:image, # Main Image of the concept
|
22
|
+
:locations, # Locations related to the concept
|
23
|
+
:name, # Name of the concept
|
24
|
+
:objects, # Objects related to the concept
|
25
|
+
:people, # People related to the concept
|
26
|
+
:platforms, # Platforms related to the concept
|
27
|
+
:related_concepts, # Other concepts related to the concept
|
28
|
+
:site_detail_url # URL pointing to the concept on Giant Bomb
|
29
|
+
]
|
30
|
+
|
31
|
+
@@fields.each do |field|
|
32
|
+
attr_accessor field
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Franchise < Resource
|
3
|
+
has_resource 'franchise', :plural => 'franchises'
|
4
|
+
|
5
|
+
# http://api.giantbomb.com/documentation/#franchise
|
6
|
+
@@fields = [
|
7
|
+
:aliases, # List of aliases the franchise is known by. A \n (newline) separates each alias.
|
8
|
+
:api_detail_url, # URL pointing to the franchise detail resource
|
9
|
+
:characters, # Characters related to the franchise
|
10
|
+
:concepts, # Concepts related to the franchise
|
11
|
+
:date_added, # Date the franchise was added to Giant Bomb
|
12
|
+
:date_last_updated, # Date the franchise was last updated on Giant Bomb
|
13
|
+
:deck, # Brief summary of the franchise
|
14
|
+
:description, # Description of the franchise
|
15
|
+
:games, # Games related to the franchise
|
16
|
+
:id, # Unique ID of the franchise
|
17
|
+
:image, # Main Image of the franchise
|
18
|
+
:locations, # Locations related to the franchise
|
19
|
+
:name, # Name of the franchise
|
20
|
+
:objects, # Objects related to the franchise
|
21
|
+
:people, # People related to the franchise
|
22
|
+
:site_detail_url # URL pointing to the franchise on Giant Bomb
|
23
|
+
]
|
24
|
+
|
25
|
+
@@fields.each do |field|
|
26
|
+
attr_accessor field
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Location < Resource
|
3
|
+
has_resource 'location', :plural => 'locations'
|
4
|
+
|
5
|
+
# http://api.giantbomb.com/documentation/#location
|
6
|
+
@@fields = [
|
7
|
+
:aliases, # List of aliases the location is known by. A \n (newline) separates each alias.
|
8
|
+
:api_detail_url, # URL pointing to the location detail resource
|
9
|
+
:date_added, # Date the location was added to Giant Bomb
|
10
|
+
:date_last_updated, # Date the location was last updated on Giant Bomb
|
11
|
+
:deck, # Brief summary of the location
|
12
|
+
:description, # Description of the location
|
13
|
+
:first_appeared_in_game, # Game the location first appeared in
|
14
|
+
:id, # Unique ID of the location
|
15
|
+
:image, # Main Image of the location
|
16
|
+
:name, # Name of the location
|
17
|
+
:site_detail_url # URL pointing to the location on Giant Bomb
|
18
|
+
]
|
19
|
+
|
20
|
+
@@fields.each do |field|
|
21
|
+
attr_accessor field
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class GameObject < Resource
|
3
|
+
has_resource 'object', :plural => 'objects'
|
4
|
+
|
5
|
+
# http://api.giantbomb.com/documentation/#object
|
6
|
+
@@fields = [
|
7
|
+
:aliases, # List of aliases the object is known by. A \n (newline) separates each alias.
|
8
|
+
:api_detail_url, # URL pointing to the object detail resource
|
9
|
+
:characters, # Characters related to the object
|
10
|
+
:companies, # Companies related to the object
|
11
|
+
:concepts, # Concepts related to the object
|
12
|
+
:date_added, # Date the object was added to Giant Bomb
|
13
|
+
:date_last_updated, # Date the object was last updated on Giant Bomb
|
14
|
+
:deck, # Brief summary of the object
|
15
|
+
:description, # Description of the object
|
16
|
+
:first_appeared_in_game, # Game the object first appeared in
|
17
|
+
:franchises, # Franchises related to the object
|
18
|
+
:games, # Games related to the object
|
19
|
+
:id, # Unique ID of the object
|
20
|
+
:image, # Main Image of the object
|
21
|
+
:locations, # Locations related to the object
|
22
|
+
:name, # Name of the object
|
23
|
+
:objects, # Other objects related to the object
|
24
|
+
:people, # People related to the object
|
25
|
+
:platforms, # Platforms related to the object
|
26
|
+
:site_detail_url # URL pointing to the object on Giant Bomb
|
27
|
+
]
|
28
|
+
|
29
|
+
@@fields.each do |field|
|
30
|
+
attr_accessor field
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Person < Resource
|
3
|
+
has_resource 'person', :plural => 'people'
|
4
|
+
|
5
|
+
# http://api.giantbomb.com/documentation/#person
|
6
|
+
@@fields = [
|
7
|
+
:aliases, # List of aliases the person is known by. A \n (newline) separates each alias.
|
8
|
+
:api_detail_url, # URL pointing to the person detail resource
|
9
|
+
:birth_date, # Date the person was born
|
10
|
+
:characters, # Characters related to the person
|
11
|
+
:companies, # Companies the person has worked with
|
12
|
+
:concepts, # Concepts related to the person
|
13
|
+
:country, # Country the person resides in
|
14
|
+
:date_added, # Date the person was added to Giant Bomb
|
15
|
+
:date_last_updated, # Date the person was last updated on Giant Bomb
|
16
|
+
:death_date, # Date the person died
|
17
|
+
:deck, # Brief summary of the person
|
18
|
+
:description, # Description of the person
|
19
|
+
:first_credited_game, # Game the person was first credited in
|
20
|
+
:franchises, # Franchises the person has worked on
|
21
|
+
:games, # Games the person has worked on
|
22
|
+
:gender, # Gender of the person. Available options are: Male, Female, Other
|
23
|
+
:hometown, # City or town the person resides in
|
24
|
+
:id, # Unique ID of the person
|
25
|
+
:image, # Main Image of the person
|
26
|
+
:locations, # Locations related to the person
|
27
|
+
:name, # Name of the person
|
28
|
+
:objects, # Objects related to the person
|
29
|
+
:people, # Other people related to the person
|
30
|
+
:platforms, # Platforms related to the person
|
31
|
+
:site_detail_url # URL pointing to the person on Giant Bomb
|
32
|
+
]
|
33
|
+
|
34
|
+
@@fields.each do |field|
|
35
|
+
attr_accessor field
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/giantbomb/resource.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
module GiantBomb
|
2
2
|
class Resource
|
3
|
-
@@
|
3
|
+
@@endpoints = {}
|
4
4
|
|
5
5
|
def self.has_resource(singular=nil, opts={})
|
6
|
-
@@
|
6
|
+
@@endpoints[self.name.downcase] = {
|
7
7
|
:singular => singular.nil? ? "#{self.name.downcase}" : singular,
|
8
8
|
:plural => opts[:plural].nil? ? "#{self.name.downcase}s" : opts[:plural]
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
13
|
-
@@
|
12
|
+
def self.endpoints
|
13
|
+
@@endpoints[self.name.downcase]
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.detail(id, conditions={})
|
17
|
-
search = GiantBomb::Search.new("/#{self.
|
17
|
+
search = GiantBomb::Search.new("/#{self.endpoints[:singular]}/#{id}/")
|
18
18
|
search.filter(conditions)
|
19
19
|
self.new(search.fetch)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.list(conditions={})
|
23
|
-
search = GiantBomb::Search.new("/#{self.
|
23
|
+
search = GiantBomb::Search.new("/#{self.endpoints[:plural]}")
|
24
24
|
search.filter(conditions)
|
25
25
|
search.fetch.collect do |result|
|
26
26
|
self.new(result)
|
@@ -29,7 +29,7 @@ module GiantBomb
|
|
29
29
|
|
30
30
|
def self.search(query)
|
31
31
|
search = GiantBomb::Search.new
|
32
|
-
search.resources("#{self.
|
32
|
+
search.resources("#{self.endpoints[:singular]}")
|
33
33
|
search.query(query)
|
34
34
|
search.fetch.collect do |result|
|
35
35
|
self.new(result)
|
data/lib/giantbomb/search.rb
CHANGED
@@ -1,46 +1,72 @@
|
|
1
1
|
module GiantBomb
|
2
|
+
# Wrapper for the Giant Bomb Search resource
|
3
|
+
#
|
4
|
+
# @see http://api.giantbomb.com/documentation/#search
|
2
5
|
class Search
|
3
6
|
include GiantBomb::Api
|
4
7
|
|
8
|
+
# @private
|
5
9
|
attr_reader :query, :resource
|
6
10
|
|
11
|
+
# Creates a new search
|
12
|
+
#
|
13
|
+
# @example Initialize a Giant Bomb search
|
14
|
+
# search = GiantBomb::Search.new
|
15
|
+
# search = GiantBomb::Search.new('game')
|
7
16
|
def initialize(resource=nil)
|
8
17
|
@params = {}
|
9
18
|
@resource = resource.nil? ? '/search' : resource
|
10
19
|
self
|
11
20
|
end
|
12
21
|
|
13
|
-
#
|
22
|
+
# @group Generic filters
|
23
|
+
|
24
|
+
# Only return the specified fields for the given resource
|
25
|
+
#
|
26
|
+
# @param fields [String] A comma delimited list of fields to return.
|
27
|
+
# @return [GiantBomb::Search] self
|
14
28
|
def fields(fields)
|
15
29
|
@params[:field_list] = "#{fields}"
|
16
30
|
self
|
17
31
|
end
|
18
32
|
|
19
|
-
#
|
33
|
+
# Only return a limited number of resources
|
34
|
+
#
|
35
|
+
# @param limit [Integer] Nmber of items to limit by.
|
36
|
+
# @return [GiantBomb::Search] self
|
20
37
|
def limit(limit)
|
21
38
|
@params[:limit] = "#{limit}"
|
22
39
|
self
|
23
40
|
end
|
24
41
|
|
25
|
-
#
|
42
|
+
# Only include resources starting from a given offset
|
43
|
+
#
|
44
|
+
# @param limit [Integer] Number of items to skip.
|
45
|
+
# @return [GiantBomb::Search] self
|
26
46
|
def offset(offset)
|
27
47
|
@params[:offset] = "#{offset}"
|
28
48
|
self
|
29
49
|
end
|
30
50
|
|
31
|
-
#
|
51
|
+
# Search query
|
52
|
+
#
|
53
|
+
# @param query [String] The search query.
|
54
|
+
# @return [GiantBomb::Search] self
|
32
55
|
def query(query)
|
33
56
|
@params[:query] = "#{query}"
|
34
57
|
self
|
35
58
|
end
|
36
59
|
|
37
|
-
#
|
60
|
+
# Only include items of the specified resources
|
61
|
+
#
|
62
|
+
# @param resources [String] A comma delimited list of resources to search.
|
63
|
+
# @return [GiantBomb::Search] self
|
38
64
|
def resources(resources)
|
39
65
|
@params[:resources] = "#{resources}"
|
40
66
|
self
|
41
67
|
end
|
42
68
|
|
43
|
-
#
|
69
|
+
# A convenience method that takes a hash where each key is
|
44
70
|
# the symbol of a method, and each value is the parameters
|
45
71
|
# passed to that method.
|
46
72
|
def filter(conditions)
|
@@ -53,7 +79,11 @@ module GiantBomb
|
|
53
79
|
end
|
54
80
|
end
|
55
81
|
|
56
|
-
#
|
82
|
+
# Fetch the results of the query
|
83
|
+
#
|
84
|
+
# @return [Array] Items that match the specified query.
|
85
|
+
# @example
|
86
|
+
# search = GiantBomb::Search.new.query("Duke Nukem").fetch
|
57
87
|
def fetch
|
58
88
|
options = @params.merge(Api.config)
|
59
89
|
response = Api.get(@resource, :query => options)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Video < Resource
|
3
|
+
has_resource 'video', :plural => 'videos'
|
4
|
+
|
5
|
+
# http://api.giantbomb.com/documentation/#video
|
6
|
+
@@fields = [
|
7
|
+
:api_detail_url, # URL pointing to the video detail resource
|
8
|
+
:deck, # Brief summary of the video
|
9
|
+
:id, # Unique ID of the video
|
10
|
+
:image, # Image associated with the video
|
11
|
+
:name, # Title of the video
|
12
|
+
:publish_date, # Date the video was published on Giant Bomb
|
13
|
+
:site_detail_url, # URL pointing to the video on Giant Bomb
|
14
|
+
:url, # The video's filename
|
15
|
+
:user # Author of the video
|
16
|
+
]
|
17
|
+
|
18
|
+
@@fields.each do |field|
|
19
|
+
attr_accessor field
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giantbomb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robert Coker
|
@@ -17,9 +17,22 @@ cert_chain: []
|
|
17
17
|
|
18
18
|
date: 2011-01-11 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: httparty
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Provides a simple, easy to use interface for the Giant Bomb video game wiki API.
|
23
36
|
email:
|
24
37
|
- rob@robertsays.com
|
25
38
|
executables: []
|
@@ -31,16 +44,22 @@ extra_rdoc_files: []
|
|
31
44
|
files:
|
32
45
|
- .gitignore
|
33
46
|
- Gemfile
|
34
|
-
- README
|
47
|
+
- README.textile
|
35
48
|
- Rakefile
|
36
49
|
- giantbomb.gemspec
|
37
50
|
- lib/giantbomb.rb
|
38
51
|
- lib/giantbomb/api.rb
|
39
52
|
- lib/giantbomb/character.rb
|
40
53
|
- lib/giantbomb/company.rb
|
54
|
+
- lib/giantbomb/concept.rb
|
55
|
+
- lib/giantbomb/franchise.rb
|
41
56
|
- lib/giantbomb/game.rb
|
57
|
+
- lib/giantbomb/location.rb
|
58
|
+
- lib/giantbomb/object.rb
|
59
|
+
- lib/giantbomb/person.rb
|
42
60
|
- lib/giantbomb/resource.rb
|
43
61
|
- lib/giantbomb/search.rb
|
62
|
+
- lib/giantbomb/video.rb
|
44
63
|
has_rdoc: true
|
45
64
|
homepage: http://rubygems.org/gems/giantbomb
|
46
65
|
licenses: []
|
@@ -74,6 +93,6 @@ rubyforge_project: giantbomb
|
|
74
93
|
rubygems_version: 1.4.2
|
75
94
|
signing_key:
|
76
95
|
specification_version: 3
|
77
|
-
summary: A Ruby wrapper for the
|
96
|
+
summary: A Ruby wrapper for the Giant Bomb video game wiki API.
|
78
97
|
test_files: []
|
79
98
|
|
data/README
DELETED
@@ -1,18 +0,0 @@
|
|
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
|
-
|