giant_bomb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jon Maddox
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,27 @@
1
+ h1. GiantBomb!
2
+
3
+ h2. What?
4
+
5
+ A simple Ruby library to talk to "GiantBomb":http://www.giantbomb.com
6
+
7
+ It's super simple right now. All it can do is search games and return the shallow details.
8
+
9
+ h2. How?
10
+
11
+ <pre><code>
12
+ require 'giant_bomb'
13
+ gb = GiantBomb::Search.new("api_key")
14
+ results = gb.find_game('Halo 3: ODST')
15
+
16
+ halo = results.first
17
+
18
+ halo.name => "Halo 3: ODST"
19
+ halo.image[:super] => "http://media.giantbomb.com/uploads/1/14735/1101733-20090611232449_halo_3_odst_box_art_super.png"
20
+
21
+ </code></pre>
22
+
23
+ h2. Install
24
+
25
+ gem install giant_bomb
26
+
27
+ Gem hosted on Gemcutter
data/Rakefile ADDED
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "giant_bomb"
8
+ gem.summary = %Q{Simple library to talk to the awesome GiantBomb data}
9
+ gem.description = %Q{Simple library to talkto the awesome GiantBomb data}
10
+ gem.email = "jon@fanzter.com"
11
+ gem.homepage = "http://github.com/fanzter/giant_bomb"
12
+ gem.authors = ["Jon Maddox"]
13
+ gem.add_dependency('httparty', '>= 0.4.3')
14
+
15
+ gem.add_development_dependency('fakeweb')
16
+ gem.add_development_dependency "thoughtbot-shoulda"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/*_test.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/*_test.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ if File.exist?('VERSION')
50
+ version = File.read('VERSION')
51
+ else
52
+ version = ""
53
+ end
54
+
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = "giant_bomb #{version}"
57
+ rdoc.rdoc_files.include('README*')
58
+ rdoc.rdoc_files.include('lib/**/*.rb')
59
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,26 @@
1
+ module GiantBomb
2
+ class Game
3
+ attr_accessor :id, :name, :deck, :description, :date_last_updated, :original_release_date, :site_detail_url,
4
+ :number_of_user_reviews, :date_added, :original_game_rating, :image
5
+
6
+ def initialize(options={})
7
+ @image = {}
8
+
9
+ @id = options["id"]
10
+ @name = options["name"]
11
+ @deck = options["deck"]
12
+ @description = options["description"]
13
+ @site_detail_url = options["site_detail_url"]
14
+ @number_of_user_reviews = options["number_of_user_reviews"]
15
+ @original_game_rating = options["original_game_rating"]
16
+
17
+ @date_last_updated = DateTime.parse(options["date_last_updated"]) if options["date_last_updated"]
18
+ @original_release_date = DateTime.parse(options["original_release_date"]) if options["original_release_date"]
19
+ @date_added = DateTime.parse(options["date_added"]) if options["date_added"]
20
+
21
+ options["image"].each{|key,value| @image[key.gsub('_url', '').to_sym] = value }
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,28 @@
1
+ module GiantBomb
2
+ class Search
3
+ include HTTParty
4
+ format :json
5
+ # include HTTParty::Icebox
6
+ # cache :store => 'file', :timeout => 120, :location => Dir.tmpdir
7
+
8
+ base_uri 'api.giantbomb.com'
9
+
10
+ def initialize(the_api_key)
11
+ @api_key = the_api_key
12
+ end
13
+
14
+ def default_query_options
15
+ {"api_key" => @api_key, "format" => 'json'}
16
+ end
17
+
18
+
19
+ # http://api.giantbomb.com/search/?api_key=ABCDEF123456&query=halo&resources=game&format=json
20
+ def find_game(keywords)
21
+ options = {"query" => keywords, "resources" => "game"}
22
+ options.merge!(default_query_options)
23
+ response = self.class.get("/search", :query => options)
24
+ response["results"].collect{|r| Game.new(r)}
25
+ end
26
+
27
+ end
28
+ end
data/lib/giant_bomb.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'httparty'
2
+
3
+ directory = File.expand_path(File.dirname(__FILE__))
4
+ # require File.join(directory, 'giant_bomb', 'httparty_icebox')
5
+ require File.join(directory, 'giant_bomb', 'search')
6
+ require File.join(directory, 'giant_bomb', 'game')