giant_bomb 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/giant_bomb.gemspec +8 -2
- data/lib/giant_bomb/attributes.rb +52 -0
- data/lib/giant_bomb/core_extensions.rb +18 -0
- data/lib/giant_bomb/developer.rb +21 -0
- data/lib/giant_bomb/game.rb +23 -15
- data/lib/giant_bomb/genre.rb +21 -0
- data/lib/giant_bomb/publisher.rb +21 -0
- data/lib/giant_bomb/search.rb +11 -3
- data/lib/giant_bomb.rb +5 -0
- data/test/fixtures/get_info.json +117 -0
- data/test/giant_bomb_test.rb +59 -32
- data/test/test_helper.rb +2 -0
- metadata +8 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/giant_bomb.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{giant_bomb}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jon Maddox"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-27}
|
13
13
|
s.description = %q{Simple library to talkto the awesome GiantBomb data}
|
14
14
|
s.email = %q{jon@fanzter.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,9 +25,15 @@ Gem::Specification.new do |s|
|
|
25
25
|
"VERSION",
|
26
26
|
"giant_bomb.gemspec",
|
27
27
|
"lib/giant_bomb.rb",
|
28
|
+
"lib/giant_bomb/attributes.rb",
|
29
|
+
"lib/giant_bomb/core_extensions.rb",
|
30
|
+
"lib/giant_bomb/developer.rb",
|
28
31
|
"lib/giant_bomb/game.rb",
|
32
|
+
"lib/giant_bomb/genre.rb",
|
29
33
|
"lib/giant_bomb/httparty_icebox.rb",
|
34
|
+
"lib/giant_bomb/publisher.rb",
|
30
35
|
"lib/giant_bomb/search.rb",
|
36
|
+
"test/fixtures/get_info.json",
|
31
37
|
"test/fixtures/search.json",
|
32
38
|
"test/fixtures/sketchy_results.json",
|
33
39
|
"test/giant_bomb_test.rb",
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
module Attributes
|
3
|
+
# based on http://github.com/nullstyle/ruby-satisfaction
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
extend ClassMethods
|
8
|
+
include InstanceMethods
|
9
|
+
attr_reader :attributes
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def attributes(*names)
|
15
|
+
options = names.extract_options!
|
16
|
+
|
17
|
+
names.each do |name|
|
18
|
+
attribute name, options unless name.blank?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def attribute(name, options)
|
23
|
+
options.replace({:type => 'nil', :lazy=>false}.merge(options))
|
24
|
+
raise "Name can't be empty" if name.blank?
|
25
|
+
lazy_load = "self.#{options[:lazy]} unless self.loaded?" if options[:lazy]
|
26
|
+
class_eval <<-EOS
|
27
|
+
def #{name}
|
28
|
+
#{lazy_load}
|
29
|
+
@#{name} ||= decode_raw_attribute(@attributes['#{name}'], #{options[:type]}) if @attributes
|
30
|
+
end
|
31
|
+
EOS
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
module InstanceMethods
|
37
|
+
def attributes=(value)
|
38
|
+
@attributes = value
|
39
|
+
end
|
40
|
+
|
41
|
+
def loaded?
|
42
|
+
@loaded
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def decode_raw_attribute(value, type)
|
47
|
+
return nil unless value
|
48
|
+
type.respond_to?(:parse) ? type.parse(value) : value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Developer
|
3
|
+
include Attributes
|
4
|
+
attributes :name, :id
|
5
|
+
|
6
|
+
def initialize(values)
|
7
|
+
self.attributes = values
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse(data)
|
11
|
+
return unless data
|
12
|
+
if data.is_a?(Array)
|
13
|
+
data.collect do |g|
|
14
|
+
Developer.new(g)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
[Developer.new(data)]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/giant_bomb/game.rb
CHANGED
@@ -1,26 +1,34 @@
|
|
1
1
|
module GiantBomb
|
2
2
|
class Game
|
3
|
-
|
4
|
-
|
3
|
+
include Attributes
|
4
|
+
attr_reader :client
|
5
5
|
|
6
|
-
|
7
|
-
@image = {}
|
6
|
+
attributes :id, :name, :deck, :description, :original_game_rating, :image
|
8
7
|
|
9
|
-
|
10
|
-
|
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"]
|
8
|
+
attributes :number_of_user_reviews, :type => Integer
|
9
|
+
attributes :date_last_updated, :original_release_date, :date_added, :type => Date
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
attributes :genres, :lazy => :get_info!, :type => Genre
|
12
|
+
attributes :publishers, :lazy => :get_info!, :type => Publisher
|
13
|
+
attributes :developers, :lazy => :get_info!, :type => Developer
|
20
14
|
|
21
|
-
|
15
|
+
attributes :images, :lazy => :get_info!
|
16
|
+
|
17
|
+
alias_method :cover, :image
|
18
|
+
|
19
|
+
def initialize(values, client)
|
20
|
+
@client = client
|
21
|
+
self.attributes = values
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_info!
|
25
|
+
game = client.get_game_info(self.id)
|
26
|
+
@attributes.merge!(game.attributes) if game
|
27
|
+
@loaded = true
|
22
28
|
end
|
23
29
|
|
30
|
+
|
31
|
+
|
24
32
|
end
|
25
33
|
|
26
34
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Genre
|
3
|
+
include Attributes
|
4
|
+
attributes :name, :id
|
5
|
+
|
6
|
+
def initialize(values)
|
7
|
+
self.attributes = values
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse(data)
|
11
|
+
return unless data
|
12
|
+
if data.is_a?(Array)
|
13
|
+
data.collect do |g|
|
14
|
+
Genre.new(g)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
[Genre.new(data)]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GiantBomb
|
2
|
+
class Publisher
|
3
|
+
include Attributes
|
4
|
+
attributes :name, :id
|
5
|
+
|
6
|
+
def initialize(values)
|
7
|
+
self.attributes = values
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse(data)
|
11
|
+
return unless data
|
12
|
+
if data.is_a?(Array)
|
13
|
+
data.collect do |g|
|
14
|
+
Publisher.new(g)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
[Publisher.new(data)]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/giant_bomb/search.rb
CHANGED
@@ -2,8 +2,8 @@ module GiantBomb
|
|
2
2
|
class Search
|
3
3
|
include HTTParty
|
4
4
|
format :json
|
5
|
-
include HTTParty::Icebox
|
6
|
-
cache :store => 'file', :timeout => 120, :location => Dir.tmpdir
|
5
|
+
# include HTTParty::Icebox
|
6
|
+
# cache :store => 'file', :timeout => 120, :location => Dir.tmpdir
|
7
7
|
|
8
8
|
base_uri 'api.giantbomb.com'
|
9
9
|
|
@@ -21,7 +21,15 @@ module GiantBomb
|
|
21
21
|
options = {"query" => keywords, "resources" => "game"}
|
22
22
|
options.merge!(default_query_options)
|
23
23
|
response = self.class.get("/search", :query => options)
|
24
|
-
response["results"].collect{|r| Game.new(r)}
|
24
|
+
response["results"].collect{|r| Game.new(r, self)}
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_game_info(game_id)
|
28
|
+
field_list = %w{developers genres images publishers}
|
29
|
+
options = {"field_list" => field_list.join(',')}
|
30
|
+
options.merge!(default_query_options)
|
31
|
+
response = self.class.get("/game/#{game_id}/", :query => options)
|
32
|
+
Game.new(response["results"], self)
|
25
33
|
end
|
26
34
|
|
27
35
|
end
|
data/lib/giant_bomb.rb
CHANGED
@@ -2,5 +2,10 @@ require 'httparty'
|
|
2
2
|
|
3
3
|
directory = File.expand_path(File.dirname(__FILE__))
|
4
4
|
require File.join(directory, 'giant_bomb', 'httparty_icebox')
|
5
|
+
require File.join(directory, 'giant_bomb', 'core_extensions')
|
6
|
+
require File.join(directory, 'giant_bomb', 'attributes')
|
5
7
|
require File.join(directory, 'giant_bomb', 'search')
|
8
|
+
require File.join(directory, 'giant_bomb', 'genre')
|
9
|
+
require File.join(directory, 'giant_bomb', 'developer')
|
10
|
+
require File.join(directory, 'giant_bomb', 'publisher')
|
6
11
|
require File.join(directory, 'giant_bomb', 'game')
|
@@ -0,0 +1,117 @@
|
|
1
|
+
{
|
2
|
+
"number_of_page_results": 1,
|
3
|
+
"status_code": 1,
|
4
|
+
"error": "OK",
|
5
|
+
"results": {
|
6
|
+
"images": [{
|
7
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141522-odst_campaign_onialphasite_screen.jpg",
|
8
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141522-odst_campaign_onialphasite_small.jpg",
|
9
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141522-odst_campaign_onialphasite_thumb.jpg",
|
10
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141522-odst_campaign_onialphasite_tiny.jpg",
|
11
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141522-odst_campaign_onialphasite_super.jpg"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141521-odst_campaign_kizingo04_screen.jpg",
|
15
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141521-odst_campaign_kizingo04_small.jpg",
|
16
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141521-odst_campaign_kizingo04_thumb.jpg",
|
17
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141521-odst_campaign_kizingo04_tiny.jpg",
|
18
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141521-odst_campaign_kizingo04_super.jpg"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141520-odst_campaign_kizingo03_screen.jpg",
|
22
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141520-odst_campaign_kizingo03_small.jpg",
|
23
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141520-odst_campaign_kizingo03_thumb.jpg",
|
24
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141520-odst_campaign_kizingo03_tiny.jpg",
|
25
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141520-odst_campaign_kizingo03_super.jpg"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141518-odst_campaign_kizingo02_screen.jpg",
|
29
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141518-odst_campaign_kizingo02_small.jpg",
|
30
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141518-odst_campaign_kizingo02_thumb.jpg",
|
31
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141518-odst_campaign_kizingo02_tiny.jpg",
|
32
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141518-odst_campaign_kizingo02_super.jpg"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141517-odst_campaign_kizingo01_screen.jpg",
|
36
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141517-odst_campaign_kizingo01_small.jpg",
|
37
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141517-odst_campaign_kizingo01_thumb.jpg",
|
38
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141517-odst_campaign_kizingo01_tiny.jpg",
|
39
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141517-odst_campaign_kizingo01_super.jpg"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141516-odst_campaign_kikowani03_screen.jpg",
|
43
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141516-odst_campaign_kikowani03_small.jpg",
|
44
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141516-odst_campaign_kikowani03_thumb.jpg",
|
45
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141516-odst_campaign_kikowani03_tiny.jpg",
|
46
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141516-odst_campaign_kikowani03_super.jpg"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141515-odst_campaign_kikowani02_screen.jpg",
|
50
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141515-odst_campaign_kikowani02_small.jpg",
|
51
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141515-odst_campaign_kikowani02_thumb.jpg",
|
52
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141515-odst_campaign_kikowani02_tiny.jpg",
|
53
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141515-odst_campaign_kikowani02_super.jpg"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141514-odst_campaign_kikowani01_screen.jpg",
|
57
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141514-odst_campaign_kikowani01_small.jpg",
|
58
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141514-odst_campaign_kikowani01_thumb.jpg",
|
59
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141514-odst_campaign_kikowani01_tiny.jpg",
|
60
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141514-odst_campaign_kikowani01_super.jpg"
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141511-odst_firefight_lostplatoon08_screen.jpg",
|
64
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141511-odst_firefight_lostplatoon08_small.jpg",
|
65
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141511-odst_firefight_lostplatoon08_thumb.jpg",
|
66
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141511-odst_firefight_lostplatoon08_tiny.jpg",
|
67
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141511-odst_firefight_lostplatoon08_super.jpg"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"screen_url": "http://media.giantbomb.com/uploads/0/26/1141504-odst_firefight_lostplatoon06_screen.jpg",
|
71
|
+
"small_url": "http://media.giantbomb.com/uploads/0/26/1141504-odst_firefight_lostplatoon06_small.jpg",
|
72
|
+
"thumb_url": "http://media.giantbomb.com/uploads/0/26/1141504-odst_firefight_lostplatoon06_thumb.jpg",
|
73
|
+
"tiny_url": "http://media.giantbomb.com/uploads/0/26/1141504-odst_firefight_lostplatoon06_tiny.jpg",
|
74
|
+
"super_url": "http://media.giantbomb.com/uploads/0/26/1141504-odst_firefight_lostplatoon06_super.jpg"
|
75
|
+
}],
|
76
|
+
"publishers": [{
|
77
|
+
"api_detail_url": "http://api.giantbomb.com/company/6753/",
|
78
|
+
"id": 6753,
|
79
|
+
"name": "343 Industries"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"api_detail_url": "http://api.giantbomb.com/company/340/",
|
83
|
+
"id": 340,
|
84
|
+
"name": "Microsoft Game Studios"
|
85
|
+
}],
|
86
|
+
"genres": [{
|
87
|
+
"api_detail_url": "http://api.giantbomb.com/genre/11/",
|
88
|
+
"id": 11,
|
89
|
+
"name": "Shooter"
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"api_detail_url": "http://api.giantbomb.com/genre/1/",
|
93
|
+
"id": 1,
|
94
|
+
"name": "Action"
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"api_detail_url": "http://api.giantbomb.com/genre/32/",
|
98
|
+
"id": 32,
|
99
|
+
"name": "First-Person Shooter"
|
100
|
+
}],
|
101
|
+
"developers": [{
|
102
|
+
"api_detail_url": "http://api.giantbomb.com/company/476/",
|
103
|
+
"id": 476,
|
104
|
+
"name": "Bungie Studios"
|
105
|
+
}],
|
106
|
+
"image": {
|
107
|
+
"screen_url": "http://media.giantbomb.com/uploads/1/14735/1101733-20090611232449_halo_3_odst_box_art_screen.png",
|
108
|
+
"small_url": "http://media.giantbomb.com/uploads/1/14735/1101733-20090611232449_halo_3_odst_box_art_small.png",
|
109
|
+
"thumb_url": "http://media.giantbomb.com/uploads/1/14735/1101733-20090611232449_halo_3_odst_box_art_thumb.png",
|
110
|
+
"tiny_url": "http://media.giantbomb.com/uploads/1/14735/1101733-20090611232449_halo_3_odst_box_art_tiny.png",
|
111
|
+
"super_url": "http://media.giantbomb.com/uploads/1/14735/1101733-20090611232449_halo_3_odst_box_art_super.png"
|
112
|
+
}
|
113
|
+
},
|
114
|
+
"limit": 1,
|
115
|
+
"offset": 0,
|
116
|
+
"number_of_total_results": 1
|
117
|
+
}
|
data/test/giant_bomb_test.rb
CHANGED
@@ -6,104 +6,131 @@ class GiantBombTest < Test::Unit::TestCase
|
|
6
6
|
setup do
|
7
7
|
@gb = GiantBomb::Search.new("key")
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
context 'searching' do
|
11
11
|
context 'for a game' do
|
12
12
|
setup do
|
13
|
-
stub_get('/search
|
13
|
+
stub_get('/search?format=json&api_key=key&resources=game&query=halo', 'search.json')
|
14
14
|
@results = @gb.find_game('halo')
|
15
15
|
end
|
16
16
|
|
17
17
|
should "return an array" do
|
18
18
|
assert_equal Array, @results.class
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
should "return an array of Games" do
|
22
22
|
assert_equal GiantBomb::Game, @results.first.class
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
context 'Games' do
|
28
28
|
context 'with good data' do
|
29
29
|
setup do
|
30
|
-
stub_get('/search
|
30
|
+
stub_get('/search?format=json&api_key=key&resources=game&query=halo', 'search.json')
|
31
|
+
stub_get('/game/24035/?format=json&api_key=key&field_list=developers%2Cgenres%2Cimages%2Cpublishers', 'get_info.json')
|
32
|
+
|
31
33
|
@game = @gb.find_game('halo').first
|
32
34
|
end
|
33
|
-
|
35
|
+
|
34
36
|
should "have a name" do
|
35
37
|
assert_equal 'Halo 3: ODST', @game.name
|
36
38
|
end
|
37
|
-
|
39
|
+
|
38
40
|
should "have a deck" do
|
39
41
|
assert_not_nil @game.deck
|
40
42
|
end
|
41
|
-
|
43
|
+
|
42
44
|
should "have a description" do
|
43
45
|
assert_not_nil @game.deck
|
44
46
|
end
|
45
|
-
|
47
|
+
|
46
48
|
should "have parsed date_last_updated to be a real date" do
|
47
|
-
assert_equal
|
49
|
+
assert_equal Date, @game.date_last_updated.class
|
48
50
|
end
|
49
|
-
|
51
|
+
|
50
52
|
should "have parsed original_release_date to be a real date" do
|
51
|
-
assert_equal
|
53
|
+
assert_equal Date, @game.original_release_date.class
|
52
54
|
end
|
53
|
-
|
55
|
+
|
54
56
|
should "have parsed date_added to be a real date" do
|
55
|
-
assert_equal
|
57
|
+
assert_equal Date, @game.date_added.class
|
56
58
|
end
|
57
|
-
|
59
|
+
|
58
60
|
context 'with an image' do
|
61
|
+
|
62
|
+
should 'cover should be an alias to image' do
|
63
|
+
assert_equal @game.image, @game.cover
|
64
|
+
end
|
59
65
|
|
60
66
|
should 'have an image hash' do
|
61
67
|
assert_equal Hash, @game.image.class
|
62
68
|
end
|
63
|
-
|
69
|
+
|
64
70
|
should 'have multiple sizes for the image' do
|
65
71
|
assert_equal 5, @game.image.keys.size
|
66
72
|
end
|
67
|
-
|
73
|
+
|
68
74
|
should 'have these sizes with symbols for keys' do
|
69
|
-
assert_not_nil @game.image[
|
70
|
-
assert_not_nil @game.image[
|
71
|
-
assert_not_nil @game.image[
|
72
|
-
assert_not_nil @game.image[
|
73
|
-
assert_not_nil @game.image[
|
75
|
+
assert_not_nil @game.image["super_url"]
|
76
|
+
assert_not_nil @game.image["small_url"]
|
77
|
+
assert_not_nil @game.image["thumb_url"]
|
78
|
+
assert_not_nil @game.image["tiny_url"]
|
79
|
+
assert_not_nil @game.image["screen_url"]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'lazy loaded attrs' do
|
84
|
+
|
85
|
+
should 'have a genres array' do
|
86
|
+
assert_equal Array, @game.genres.class
|
87
|
+
end
|
88
|
+
|
89
|
+
should 'have a developers array' do
|
90
|
+
assert_equal Array, @game.developers.class
|
91
|
+
end
|
92
|
+
|
93
|
+
should 'have a publishers array' do
|
94
|
+
assert_equal Array, @game.publishers.class
|
95
|
+
end
|
96
|
+
|
97
|
+
should 'have an images array' do
|
98
|
+
assert_equal Array, @game.images.class
|
74
99
|
end
|
75
100
|
|
101
|
+
should 'have an images array of hashes' do
|
102
|
+
assert_equal Hash, @game.images.first.class
|
103
|
+
end
|
104
|
+
|
76
105
|
end
|
106
|
+
|
77
107
|
end
|
78
108
|
|
79
109
|
|
80
110
|
context 'with sketchy data' do
|
81
111
|
setup do
|
82
|
-
stub_get('/search
|
112
|
+
stub_get('/search?format=json&api_key=key&resources=game&query=halo2', 'sketchy_results.json')
|
83
113
|
@game = @gb.find_game('halo2').first
|
84
|
-
puts @game.name
|
85
114
|
end
|
86
115
|
|
87
116
|
should 'handle not having date_added' do
|
88
117
|
assert_nil @game.date_added
|
89
118
|
end
|
90
|
-
|
119
|
+
|
91
120
|
should 'handle not having original_release_date' do
|
92
121
|
assert_nil @game.original_release_date
|
93
122
|
end
|
94
|
-
|
123
|
+
|
95
124
|
should 'handle not having date_last_updated' do
|
96
125
|
assert_nil @game.date_last_updated
|
97
126
|
end
|
98
|
-
|
127
|
+
|
99
128
|
should 'handle not having image urls' do
|
100
|
-
|
101
|
-
assert_equal 0, @game.image.keys.size
|
129
|
+
assert_nil @game.image
|
102
130
|
end
|
103
|
-
|
104
131
|
end
|
105
|
-
|
106
|
-
|
132
|
+
|
133
|
+
|
107
134
|
end
|
108
135
|
|
109
136
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giant_bomb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Maddox
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-27 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -60,9 +60,15 @@ files:
|
|
60
60
|
- VERSION
|
61
61
|
- giant_bomb.gemspec
|
62
62
|
- lib/giant_bomb.rb
|
63
|
+
- lib/giant_bomb/attributes.rb
|
64
|
+
- lib/giant_bomb/core_extensions.rb
|
65
|
+
- lib/giant_bomb/developer.rb
|
63
66
|
- lib/giant_bomb/game.rb
|
67
|
+
- lib/giant_bomb/genre.rb
|
64
68
|
- lib/giant_bomb/httparty_icebox.rb
|
69
|
+
- lib/giant_bomb/publisher.rb
|
65
70
|
- lib/giant_bomb/search.rb
|
71
|
+
- test/fixtures/get_info.json
|
66
72
|
- test/fixtures/search.json
|
67
73
|
- test/fixtures/sketchy_results.json
|
68
74
|
- test/giant_bomb_test.rb
|