giantbomb-api 1.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 032b2d2f6dabd3c02d3816ffba774a88d3d3a7e2
4
+ data.tar.gz: 6beefb52f5e58d0aff73c087c147f1b394f35ccf
5
+ SHA512:
6
+ metadata.gz: c2fd4be30245fac477442acda251ca472f60501e8d0e6d4f27167b187e5124b8319d6c8e7f20ffaaa3ad082d196278d9a12d3e76423e1b3f79ba8fbb3e539057
7
+ data.tar.gz: a6d899ca0572a4ed456a978c13a3e8843a5373cb1e1dee7b6a6073098950a7288a7517491e9494b69fe43199f41ca94d3d4eca1eafba298dcbf6e38a6a88a573
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+
5
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in giantbomb.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Vlad Radulescu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ ## A Ruby wrapper for the GiantBomb API
2
+
3
+ All credits goes to [intelekshual](https://github.com/intelekshual) for creating
4
+ mostly everything :)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'giantbomb'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install giantbomb
21
+
22
+ In your Rails application, add your API key to:
23
+ `config/initializers/giantbomb.rb`
24
+
25
+ ``` ruby
26
+ GiantBomb::Api.key('API_KEY_HERE')
27
+ ```
28
+
29
+ ### Resources
30
+
31
+ Current available resources:
32
+ * Character
33
+ * Company
34
+ * Concept
35
+ * Franchise
36
+ * Game
37
+ * Location
38
+ * Person
39
+ * Platform
40
+ * Video
41
+
42
+ All resources have access to `Resource#list` `Resource#detail` and `Resource#search`
43
+
44
+ ### Usage
45
+
46
+ ###### Finding a Game
47
+
48
+ ``` ruby
49
+ game = GiantBomb::Game.detail(1)
50
+
51
+ games = GiantBomb::Game.find('gta')
52
+ games = GiantBomb::Game.list
53
+ ```
54
+
55
+ ###### Searching for Games
56
+
57
+ ``` ruby
58
+ search = GiantBomb::Search.new
59
+ search.query('gta')
60
+ search.fetch
61
+ ```
62
+
63
+ ``` ruby
64
+ # Available filter methods
65
+
66
+ .limit(10) # limits the number of returned resources
67
+ .resources('game') # determines the type of resource
68
+ .fields('name,deck') # returns only the requested resources
69
+ .offset(100) # sets the offset
70
+
71
+ # All filters are chainable!
72
+ ```
73
+
74
+ ### Development
75
+
76
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
77
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
78
+ prompt that will allow you to experiment.
79
+
80
+ ###### TODO
81
+
82
+ * Add all resources available from: http://www.giantbomb.com/api/documentation
83
+ * Create a proper documentation showcasing all available resources and how to use them
84
+ * Tests
85
+
86
+ ### Examples
87
+
88
+ For more examples see [mygames.io](https://github.com/pacMakaveli/mygames.io)
89
+ for a live application
90
+
91
+ ## License
92
+
93
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "giantbomb"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/giantbomb.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ require './lib/giantbomb/version'
3
+
4
+ Gem::Specification.new do |g|
5
+ g.name = "giantbomb-api"
6
+ g.version = GiantBomb::VERSION
7
+ g.platform = Gem::Platform::RUBY
8
+ g.date = Date.today.to_s
9
+
10
+ g.authors = ["Robert Coker", "Vlad Radulescu"]
11
+ g.email = ["rob@robertsays.com", "pacMakaveli90@gmail.com"]
12
+
13
+ g.homepage = "http://rubygems.org/gems/giantbomb-api"
14
+ g.summary = %q{A Ruby wrapper for the GiantBomb video game wiki API.}
15
+ g.description = %q{Provides a simple, easy to use interface for the Giant Bomb video game wiki API.}
16
+
17
+ g.add_dependency("httparty")
18
+
19
+ g.files = `git ls-files`.split("\n")
20
+ g.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ g.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ g.require_paths = ["lib"]
23
+ end
data/lib/giantbomb.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+ require 'giantbomb/version'
5
+
6
+ module GiantBomb
7
+
8
+ ['api', 'search', 'resource'].each do |inc|
9
+ require File.join(File.dirname(__FILE__), 'giantbomb', inc)
10
+ end
11
+
12
+ c = ['character', 'company', 'concept']
13
+ f = ['franchise']
14
+ g = ['game']
15
+ l = ['location']
16
+ o = ['object']
17
+ p = ['person', 'platform']
18
+ r = ['review']
19
+ u = ['user_review']
20
+ v = ['video']
21
+
22
+ [c, f, g, l, o, p, r, u, v].flatten.each do |inc|
23
+ require File.join(File.dirname(__FILE__), 'giantbomb', inc)
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module GiantBomb
2
+ module Api
3
+ include HTTParty
4
+
5
+ base_uri 'http://www.giantbomb.com/api/'
6
+
7
+ def self.config
8
+ @@config
9
+ end
10
+
11
+ def self.key(api_key)
12
+ @@config = {
13
+ api_key: api_key,
14
+ format: 'json'
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,40 @@
1
+ module GiantBomb
2
+ class Character < Resource
3
+ has_resource 'character', plural: 'characters', id: '3005'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-4
6
+ # http://www.giantbomb.com/api/documentation#toc-0-5
7
+ #
8
+ @@fields = [
9
+ :aliases, # List of aliases that the character is known by. A \n (newline) separates each alias.
10
+ :api_detail_url, # URL pointing to the character detail resource
11
+ :birthday, # Birthday of the character
12
+ :companies, # Companies that have used the character in a game
13
+ :concepts, # Concepts related to the character
14
+ :date_added, # Date the character was added to Giant Bomb
15
+ :date_last_updated, # Date the character was last updated on Giant Bomb
16
+ :deck, # Brief summary of the character
17
+ :description, # Description of the character
18
+ :enemies, # Enemies of the character
19
+ :first_appeared_in_game, # Game that the character first appeared in
20
+ :franchises, # Franchises the character has appeared in
21
+ :friends, # Friends of the character
22
+ :games, # Games the character has appeared in
23
+ :gender, # Gender of the character. Available options are: Male, Female, Other
24
+ :id, # Unique ID of the character
25
+ :image, # Main Image of the character
26
+ :last_name, # Last name of the character
27
+ :locations, # Locations related to the character
28
+ :name, # Name of the character
29
+ :objects, # Objects related to the character
30
+ :people, # People who have worked with the character
31
+ :platforms, # Platforms having a game the character has appeared in
32
+ :real_name, # Real name of the character
33
+ :site_detail_url # URL pointing to the character on Giant Bomb
34
+ ]
35
+
36
+ @@fields.each do |field|
37
+ attr_accessor field
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,44 @@
1
+ module GiantBomb
2
+ class Company < Resource
3
+ has_resource 'company', plural: 'companies', id: '3010'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-8
6
+ # http://www.giantbomb.com/api/documentation#toc-0-9
7
+ #
8
+ @@fields = [
9
+ :abbreviation, # Abbreviation of the company
10
+ :aliases, # List of aliases the company is known by. A \n (newline) separates each alias.
11
+ :api_detail_url, # URL pointing to the company detail resource
12
+ :characters, # Characters the company has used in a game
13
+ :concepts, # Concepts related to the company
14
+ :date_added, # Date the company was added to Giant Bomb
15
+ :date_founded, # Date the company was founded
16
+ :date_last_updated, # Date the company was last updated on Giant Bomb
17
+ :deck, # Brief summary of the company
18
+ :description, # Description of the company
19
+ :developed_games, # Games the company has developed
20
+ :developer_releases, # Releases the company has developed
21
+ :distributor_releases, # Releases the company has distributed
22
+ :id, # Unique ID of the company
23
+ :image, # Main Image of the company
24
+ :location_address, # Street address of the company
25
+ :location_city, # City the company resides in
26
+ :location_country, # Country the company resides in
27
+ :location_state, # State the company resides in
28
+ :locations, # Locations related to the company
29
+ :name, # Name of the company
30
+ :objects, # Objects related to the company
31
+ :people, # People who have worked for the company
32
+ :phone, # Phone number of the company
33
+ :published_games, # Games published by the company
34
+ :publisher_releases, # Releases the company has published
35
+ :site_detail_url, # URL pointing to the company on Giant Bomb
36
+ :website # URL to the company website
37
+ ]
38
+
39
+ @@fields.each do |field|
40
+ attr_accessor field
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,38 @@
1
+ module GiantBomb
2
+ class Concept < Resource
3
+ has_resource 'concept', plural: 'concepts', id: '3015'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-10
6
+ # http://www.giantbomb.com/api/documentation#toc-0-11
7
+ #
8
+ @@fields = [
9
+ :aliases, # List of aliases the concept is known by. A \n (newline) separates each alias.
10
+ :api_detail_url, # URL pointing to the concept detail resource
11
+ :characters, # Characters related to the concept
12
+ :companies, # Companies related to the concept
13
+ :concepts, # Other concepts related to the concept
14
+ :date_added, # Date the concept was added to Giant Bomb
15
+ :date_last_updated, # Date the concept was last updated on Giant Bomb
16
+ :deck, # Brief summary of the concept
17
+ :description, # Description of the concept
18
+ :first_appeared_in_franchise, # Franchise that the concept first appeared in
19
+ :first_appeared_in_game, # Game that the concept first appeared in
20
+ :franchises, # Franchises related to the concept
21
+ :games, # Games related to the concept
22
+ :id, # Unique ID of the concept
23
+ :image, # Main Image of the concept
24
+ :locations, # Locations related to the concept
25
+ :name, # Name of the concept
26
+ :objects, # Objects related to the concept
27
+ :people, # People related to the concept
28
+ :platforms, # Platforms related to the concept
29
+ :related_concepts, # Other concepts related to the concept
30
+ :site_detail_url # URL pointing to the concept on Giant Bomb
31
+ ]
32
+
33
+ @@fields.each do |field|
34
+ attr_accessor field
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,32 @@
1
+ module GiantBomb
2
+ class Franchise < Resource
3
+ has_resource 'franchise', plural: 'franchises', id: '3025'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-12
6
+ # http://www.giantbomb.com/api/documentation#toc-0-13
7
+ #
8
+ @@fields = [
9
+ :aliases, # List of aliases the franchise is known by. A \n (newline) separates each alias.
10
+ :api_detail_url, # URL pointing to the franchise detail resource
11
+ :characters, # Characters related to the franchise
12
+ :concepts, # Concepts related to the franchise
13
+ :date_added, # Date the franchise was added to Giant Bomb
14
+ :date_last_updated, # Date the franchise was last updated on Giant Bomb
15
+ :deck, # Brief summary of the franchise
16
+ :description, # Description of the franchise
17
+ :games, # Games related to the franchise
18
+ :id, # Unique ID of the franchise
19
+ :image, # Main Image of the franchise
20
+ :locations, # Locations related to the franchise
21
+ :name, # Name of the franchise
22
+ :objects, # Objects related to the franchise
23
+ :people, # People related to the franchise
24
+ :site_detail_url # URL pointing to the franchise on Giant Bomb
25
+ ]
26
+
27
+ @@fields.each do |field|
28
+ attr_accessor field
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,55 @@
1
+ module GiantBomb
2
+ class Game < Resource
3
+ has_resource 'game', plural: 'games', id: '3030'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-14
6
+ # http://www.giantbomb.com/api/documentation#toc-0-15
7
+ #
8
+ @@fields = [
9
+ :aliases, # List of aliases the game is known by. A \n (newline) separates each alias.
10
+ :api_detail_url, # URL pointing to the game detail resource
11
+ :characters, # Characters related to the game
12
+ :concepts, # Concepts related to the game
13
+ :date_added, # Date the game was added to Giant Bomb
14
+ :date_last_updated, # Date the game was last updated on Giant Bomb
15
+ :deck, # Brief summary of the game
16
+ :description, # Description of the game
17
+ :developers, # Companies that developed the game
18
+ :expected_release_day, # Expected day the game will be released in. The day is represented numerically.
19
+ :expected_release_month, # Expected month the game will be released in. The month is represented numerically.
20
+ :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.
21
+ :expected_release_year, # Expected year the game will be released in.
22
+ :first_appearance_characters, # Characters that first appeared in the game
23
+ :first_appearance_concepts, # Concepts that first appeared in the game
24
+ :first_appearance_locations, # Locations that first appeared in the game
25
+ :first_appearance_objects, # Objects that first appeared in the game
26
+ :first_appearance_people, # People that were first credited in the game
27
+ :franchises, # Franchises the game is a part of
28
+ :genres, # Genres that encompass the game
29
+ :id, # Unique ID of the game
30
+ :image, # Main Image of the game
31
+ :images, # List of images associated to the game
32
+ :killed_characters, # Characters killed in the game
33
+ :locations, # Locations related to the game
34
+ :name, # Name of the game
35
+ :number_of_user_reviews, # Number of user reviews of the game on Giant Bomb
36
+ :objects, # Objects related to the game
37
+ :original_game_rating, # Rating of the first release of the game
38
+ :original_release_date, # Date the game was first released
39
+ :people, # People related to the game
40
+ :platforms, # Platforms the game can be played on
41
+ :publishers, # Companies that published the game
42
+ :releases, # Releases of the game
43
+ :reviews, # Staff reviews of the game
44
+ :similar_games, # Other games that are similar to the game
45
+ :site_detail_url, # URL pointing to the game on Giant Bomb
46
+ :themes, # Themes that encompass the game
47
+ :videos # Videos associated to the game
48
+ ]
49
+
50
+ @@fields.each do |field|
51
+ attr_accessor field
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,27 @@
1
+ module GiantBomb
2
+ class Location < Resource
3
+ has_resource 'location', plural: 'locations', id: '3035'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-20
6
+ # http://www.giantbomb.com/api/documentation#toc-0-21
7
+ #
8
+ @@fields = [
9
+ :aliases, # List of aliases the location is known by. A \n (newline) separates each alias.
10
+ :api_detail_url, # URL pointing to the location detail resource
11
+ :date_added, # Date the location was added to Giant Bomb
12
+ :date_last_updated, # Date the location was last updated on Giant Bomb
13
+ :deck, # Brief summary of the location
14
+ :description, # Description of the location
15
+ :first_appeared_in_game, # Game the location first appeared in
16
+ :id, # Unique ID of the location
17
+ :image, # Main Image of the location
18
+ :name, # Name of the location
19
+ :site_detail_url # URL pointing to the location on Giant Bomb
20
+ ]
21
+
22
+ @@fields.each do |field|
23
+ attr_accessor field
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ module GiantBomb
2
+ class GameObject < Resource
3
+ has_resource 'object', plural: 'objects', id: '3055'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-22
6
+ # http://www.giantbomb.com/api/documentation#toc-0-23
7
+ #
8
+ @@fields = [
9
+ :aliases, # List of aliases the object is known by. A \n (newline) separates each alias.
10
+ :api_detail_url, # URL pointing to the object detail resource
11
+ :characters, # Characters related to the object
12
+ :companies, # Companies related to the object
13
+ :concepts, # Concepts related to the object
14
+ :date_added, # Date the object was added to Giant Bomb
15
+ :date_last_updated, # Date the object was last updated on Giant Bomb
16
+ :deck, # Brief summary of the object
17
+ :description, # Description of the object
18
+ :first_appeared_in_game, # Game the object first appeared in
19
+ :franchises, # Franchises related to the object
20
+ :games, # Games related to the object
21
+ :id, # Unique ID of the object
22
+ :image, # Main Image of the object
23
+ :locations, # Locations related to the object
24
+ :name, # Name of the object
25
+ :objects, # Other objects related to the object
26
+ :people, # People related to the object
27
+ :platforms, # Platforms related to the object
28
+ :site_detail_url # URL pointing to the object on Giant Bomb
29
+ ]
30
+
31
+ @@fields.each do |field|
32
+ attr_accessor field
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ module GiantBomb
2
+ class Person < Resource
3
+ has_resource 'person', plural: 'people', id: '3040'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-24
6
+ # http://www.giantbomb.com/api/documentation#toc-0-25
7
+ #
8
+ @@fields = [
9
+ :aliases, # List of aliases the person is known by. A \n (newline) separates each alias.
10
+ :api_detail_url, # URL pointing to the person detail resource
11
+ :birth_date, # Date the person was born
12
+ :characters, # Characters related to the person
13
+ :companies, # Companies the person has worked with
14
+ :concepts, # Concepts related to the person
15
+ :country, # Country the person resides in
16
+ :date_added, # Date the person was added to Giant Bomb
17
+ :date_last_updated, # Date the person was last updated on Giant Bomb
18
+ :death_date, # Date the person died
19
+ :deck, # Brief summary of the person
20
+ :description, # Description of the person
21
+ :first_credited_game, # Game the person was first credited in
22
+ :franchises, # Franchises the person has worked on
23
+ :games, # Games the person has worked on
24
+ :gender, # Gender of the person. Available options are: Male, Female, Other
25
+ :hometown, # City or town the person resides in
26
+ :id, # Unique ID of the person
27
+ :image, # Main Image of the person
28
+ :locations, # Locations related to the person
29
+ :name, # Name of the person
30
+ :objects, # Objects related to the person
31
+ :people, # Other people related to the person
32
+ :platforms, # Platforms related to the person
33
+ :site_detail_url # URL pointing to the person on Giant Bomb
34
+ ]
35
+
36
+ @@fields.each do |field|
37
+ attr_accessor field
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,30 @@
1
+ module GiantBomb
2
+ class Platform < Resource
3
+ has_resource 'platform', plural: 'platforms', id: '3045'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-26
6
+ # http://www.giantbomb.com/api/documentation#toc-0-27
7
+ #
8
+ @@fields = [
9
+ :abbreviation, # Abbreviation of the platform.
10
+ :api_detail_url, # URL pointing to the platform detail resource
11
+ :company, # Company that created the platform.
12
+ :date_added, # Date the platform was added to Giant Bomb
13
+ :date_last_updated, # Date the platform was last updated on Giant Bomb
14
+ :deck, # Brief summary of the platform
15
+ :description, # Description of the platform
16
+ :id, # Unique ID of the platform
17
+ :image, # Main Image of the platform
18
+ :install_base, # Approximate number of sold hardware units.
19
+ :name, # Name of the platform
20
+ :online_support, # Flag indicating whether the platform has online capabilities.
21
+ :original_price, # Initial price point of the platform.
22
+ :release_date, # Date of the platform
23
+ :site_detail_url, # URL pointing to the platform on Giant Bomb.
24
+ ]
25
+
26
+ @@fields.each do |field|
27
+ attr_accessor field
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,58 @@
1
+ module GiantBomb
2
+ class Resource
3
+ @@endpoints = {}
4
+ @@endpoint_id = {}
5
+
6
+ def self.has_resource(singular=nil, opts={})
7
+ @@endpoints[self.name.downcase] = {
8
+ singular: singular.nil? ? "#{self.name.downcase}" : singular,
9
+ plural: opts[:plural].nil? ? "#{self.name.downcase}s" : opts[:plural]
10
+ }
11
+ @@endpoint_id[self.name.downcase] = opts[:id].nil? ? "" : "#{opts[:id]}-"
12
+ end
13
+
14
+ def self.endpoints
15
+ @@endpoints[self.name.downcase]
16
+ end
17
+
18
+ def self.endpoint_id
19
+ @@endpoint_id[self.name.downcase]
20
+ end
21
+
22
+ def self.detail(id, conditions={})
23
+ search = GiantBomb::Search.new("/#{self.endpoints[:singular]}/#{self.endpoint_id + id.to_s}/")
24
+ search.filter(conditions)
25
+ self.new(search.fetch)
26
+ end
27
+
28
+ def self.list(conditions={})
29
+ search = GiantBomb::Search.new("/#{self.endpoints[:plural]}")
30
+ search.filter(conditions)
31
+ search.fetch.collect do |result|
32
+ self.new(result)
33
+ end
34
+ end
35
+
36
+ def self.search(query)
37
+ search = GiantBomb::Search.new
38
+ search.resources("#{self.endpoints[:singular]}")
39
+ search.query(query)
40
+ search.fetch.collect do |result|
41
+ self.new(result)
42
+ end
43
+ end
44
+
45
+ class << self
46
+ alias_method :find, :search
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
+ end
58
+ end
@@ -0,0 +1,27 @@
1
+ module GiantBomb
2
+ class Review < Resource
3
+ has_resource 'review', plural: 'reviews', id: '1900'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-36
6
+ # http://www.giantbomb.com/api/documentation#toc-0-37
7
+ #
8
+ @@fields = [
9
+ :api_detail_url, # URL pointing to the review detail resource
10
+ :deck, # Brief summary of the review
11
+ :description, # Description of the review
12
+ :dlc, # Date the franchise was added to Giant Bomb
13
+ :dlc_name, # Name of the Downloadable Content package
14
+ :game, # Game the review is for
15
+ :publish_date, # Date the review was published on Giant Bomb
16
+ :release, # Release of game for review
17
+ :reviewer, # Name of the review's author
18
+ :score, # The score given to the game on a scale of 1 to 5
19
+ :site_detail_url, # URL pointing to the review on Giant Bomb
20
+ :platforms, # Platforms the review appeared in.
21
+ ]
22
+
23
+ @@fields.each do |field|
24
+ attr_accessor field
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,112 @@
1
+ module GiantBomb
2
+ # Wrapper for the Giant Bomb Search resource
3
+ #
4
+ # @see http://api.giantbomb.com/documentation/#search
5
+ class Search
6
+ include GiantBomb::Api
7
+
8
+ # @private
9
+ attr_reader :query, :resource
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')
16
+ def initialize(resource=nil)
17
+ @params = {}
18
+ @resource = resource.nil? ? '/search' : resource
19
+ self
20
+ end
21
+
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
28
+ def fields(fields)
29
+ @params[:field_list] = "#{fields}"
30
+ self
31
+ end
32
+
33
+ # Only return a limited number of resources
34
+ #
35
+ # @param limit [Integer] Nmber of items to limit by.
36
+ # @return [GiantBomb::Search] self
37
+ def limit(limit)
38
+ @params[:limit] = "#{limit}"
39
+ self
40
+ end
41
+
42
+ # Only include resources starting from a given offset
43
+ #
44
+ # @param limit [Integer] Number of items to skip.
45
+ # @return [GiantBomb::Search] self
46
+ def offset(offset)
47
+ @params[:offset] = "#{offset}"
48
+ self
49
+ end
50
+
51
+ # Search query
52
+ #
53
+ # @param query [String] The search query.
54
+ # @return [GiantBomb::Search] self
55
+ def query(query)
56
+ @params[:query] = "#{query}"
57
+ self
58
+ end
59
+
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
64
+ def resources(resources)
65
+ @params[:resources] = "#{resources}"
66
+ self
67
+ end
68
+
69
+ # A convenience method that takes a hash where each key is
70
+ # the symbol of a method, and each value is the parameters
71
+ # passed to that method.
72
+ def filter(conditions)
73
+ if conditions
74
+ conditions.each do |key, value|
75
+ if self.respond_to?(key)
76
+ self.send(key, value)
77
+ end
78
+ end
79
+ end
80
+ end
81
+
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
87
+ def fetch
88
+ fetch_response['results']
89
+ end
90
+
91
+ # Fetch the full response of the query, including metadata
92
+ # Keys returned:
93
+ # status_code
94
+ # error
95
+ # number_of_total_results
96
+ # number_of_page_results
97
+ # limit
98
+ # offset
99
+ # results
100
+ #
101
+ # @return [Hash] Hash of the api response
102
+ # @example
103
+ # search = GiantBomb::Search.new.query("Duke Nukem").fetch_response
104
+ # @see http://api.giantbomb.com/documentation/#handling_responses
105
+ def fetch_response
106
+ options = @params.merge(Api.config)
107
+ response = Api.get(@resource, query: options)
108
+ response.to_hash
109
+ end
110
+
111
+ end
112
+ end
@@ -0,0 +1,24 @@
1
+ module GiantBomb
2
+ class UserReview < Resource
3
+ has_resource 'user_review', plural: 'user_reviews', id: '2200'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-42
6
+ # http://www.giantbomb.com/api/documentation#toc-0-43
7
+ #
8
+ @@fields = [
9
+ :api_detail_url, # URL pointing to the review detail resource
10
+ :date_added, # Date the user_review was added to Giant Bomb
11
+ :date_last_updated, # Date the user_review was last updated on Giant Bomb
12
+ :deck, # Brief summary of the user_review
13
+ :description, # Description of the user_review
14
+ :game, # Game the user_review is for
15
+ :reviewer, # Name of the review's author
16
+ :score, # The score given to the game on a scale of 1 to 5
17
+ :site_detail_url, # URL pointing to the user_review on Giant Bomb
18
+ ]
19
+
20
+ @@fields.each do |field|
21
+ attr_accessor field
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ module GiantBomb
2
+ VERSION = "1.5.7"
3
+
4
+ # Changelog
5
+ #
6
+ # v1.5.5 -
7
+ # v1.5.6 - Add Review resource
8
+ # v1.5.7 - Add User Review Resource
9
+ ## v1.5.8 - Planned
10
+ #
11
+
12
+ end
@@ -0,0 +1,24 @@
1
+ module GiantBomb
2
+ class Video < Resource
3
+ has_resource 'video', plural: 'videos', id: '2300'
4
+
5
+ # http://www.giantbomb.com/api/documentation#toc-0-44
6
+ #
7
+ @@fields = [
8
+ :api_detail_url, # URL pointing to the video detail resource
9
+ :deck, # Brief summary of the video
10
+ :id, # Unique ID of the video
11
+ :image, # Image associated with the video
12
+ :name, # Title of the video
13
+ :publish_date, # Date the video was published on Giant Bomb
14
+ :site_detail_url, # URL pointing to the video on Giant Bomb
15
+ :url, # The video's filename
16
+ :user # Author of the video
17
+ ]
18
+
19
+ @@fields.each do |field|
20
+ attr_accessor field
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe GiantBomb do
4
+ it 'has a version number' do
5
+ expect(GiantBomb::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'giantbomb'
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: giantbomb-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.7
5
+ platform: ruby
6
+ authors:
7
+ - Robert Coker
8
+ - Vlad Radulescu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-01-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: Provides a simple, easy to use interface for the Giant Bomb video game
29
+ wiki API.
30
+ email:
31
+ - rob@robertsays.com
32
+ - pacMakaveli90@gmail.com
33
+ executables:
34
+ - console
35
+ - setup
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - ".gitignore"
40
+ - ".rspec"
41
+ - ".travis.yml"
42
+ - Gemfile
43
+ - Gemfile.lock
44
+ - LICENSE.txt
45
+ - README.md
46
+ - Rakefile
47
+ - bin/console
48
+ - bin/setup
49
+ - giantbomb.gemspec
50
+ - lib/giantbomb.rb
51
+ - lib/giantbomb/api.rb
52
+ - lib/giantbomb/character.rb
53
+ - lib/giantbomb/company.rb
54
+ - lib/giantbomb/concept.rb
55
+ - lib/giantbomb/franchise.rb
56
+ - lib/giantbomb/game.rb
57
+ - lib/giantbomb/location.rb
58
+ - lib/giantbomb/object.rb
59
+ - lib/giantbomb/person.rb
60
+ - lib/giantbomb/platform.rb
61
+ - lib/giantbomb/resource.rb
62
+ - lib/giantbomb/review.rb
63
+ - lib/giantbomb/search.rb
64
+ - lib/giantbomb/user_review.rb
65
+ - lib/giantbomb/version.rb
66
+ - lib/giantbomb/video.rb
67
+ - spec/giantbomb_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: http://rubygems.org/gems/giantbomb-api
70
+ licenses: []
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.4.8
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: A Ruby wrapper for the GiantBomb video game wiki API.
92
+ test_files:
93
+ - spec/giantbomb_spec.rb
94
+ - spec/spec_helper.rb