heyzap_publisher_api 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 +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +25 -0
- data/README.rdoc +56 -0
- data/Rakefile +2 -0
- data/heyzap_publisher_api.gemspec +22 -0
- data/lib/heyzap_publisher_api.rb +5 -0
- data/lib/heyzap_publisher_api/category.rb +12 -0
- data/lib/heyzap_publisher_api/game.rb +26 -0
- data/lib/heyzap_publisher_api/heyzap.rb +171 -0
- data/lib/heyzap_publisher_api/version.rb +3 -0
- data/spec/game_spec.rb +51 -0
- data/spec/heyzap_spec.rb +55 -0
- data/spec/spec_helper.rb +6 -0
- metadata +96 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
heyzap_publisher_api (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
rspec (2.5.0)
|
11
|
+
rspec-core (~> 2.5.0)
|
12
|
+
rspec-expectations (~> 2.5.0)
|
13
|
+
rspec-mocks (~> 2.5.0)
|
14
|
+
rspec-core (2.5.1)
|
15
|
+
rspec-expectations (2.5.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.5.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
bundler (>= 1.0.0.rc.6)
|
24
|
+
heyzap_publisher_api!
|
25
|
+
rspec
|
data/README.rdoc
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
= HeyzapPublisherApi
|
2
|
+
|
3
|
+
Unofficial Heyzap Ruby wrapper API for game publishing on your site
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
Add this line to your gemfile
|
8
|
+
|
9
|
+
gem 'heyzap_publisher_api', :git => 'git@github.com:tmlee/heyzap_publisher_api.git'
|
10
|
+
|
11
|
+
== Resources
|
12
|
+
|
13
|
+
* Heyzap Publisher API Reference (http://www.heyzap.com/publishers/documentation/api-reference)
|
14
|
+
* Get the Site key and Secret key (http://www.heyzap.com/publishers)
|
15
|
+
|
16
|
+
== Examples
|
17
|
+
|
18
|
+
HeyzapPublisherApi currently supports
|
19
|
+
games_by_name
|
20
|
+
games_by_keyword
|
21
|
+
games_gallery
|
22
|
+
categories
|
23
|
+
|
24
|
+
=== Initialize
|
25
|
+
|
26
|
+
# Initialize HeyzapPublisherApi with SITE_KEY and SECRET_KEY
|
27
|
+
@heyzap = HeyzapPublisherApi::Heyzap.new(:site_key => SITE_KEY, :secret_key => SECRET_KEY)
|
28
|
+
|
29
|
+
=== Games By Keyword
|
30
|
+
|
31
|
+
games = @heyzap.games_by_keyword(:keyword => "car", :per_page => 5) # => {:status => 200, :games => [#<HeyzapPublisherApi::Game:0x00000100958ae8..]}
|
32
|
+
games[:games].first.name # => "webbliracers"
|
33
|
+
games[:games].first.embed_code # => returns embeddable html flash game code
|
34
|
+
|
35
|
+
=== Games By Category
|
36
|
+
|
37
|
+
games = @heyzap.games_by_category(:featured => true, :hot_new => true)
|
38
|
+
|
39
|
+
=== Games By Name
|
40
|
+
|
41
|
+
games = @heyzap.games_by_name(["star-fever", "epicduel"])
|
42
|
+
games[:games].first.name # => "Star Fever Agency"
|
43
|
+
|
44
|
+
=== Games Gallery
|
45
|
+
|
46
|
+
gallery = @heyzap.games_gallery
|
47
|
+
gallery[:categories] # => Array of Gallery Category
|
48
|
+
gallery[:categories].first.name # => First gallery category, "featured"
|
49
|
+
gallery[:categories].last.games # => Returns an array of games in the last gallery category "social"
|
50
|
+
|
51
|
+
=== Categories
|
52
|
+
|
53
|
+
categories = @heyzap.categories
|
54
|
+
categories[:categories].first # => #<HeyzapPublisherApi::Category:0x000001010de6f0 @name="featured", @display_name="Featured", @num_games=29>
|
55
|
+
categories[:categories].first.name # => "featured"
|
56
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/heyzap_publisher_api/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "heyzap_publisher_api"
|
6
|
+
s.version = HeyzapPublisherApi::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["tm lee"]
|
9
|
+
s.email = ["tm89lee@gmail.com"]
|
10
|
+
s.homepage = "http://rubygems.org/gems/heyzap_publisher_api"
|
11
|
+
s.summary = "Unofficial Heyzap Ruby wrapper API for game publishing on your site."
|
12
|
+
s.description = "Unofficial Heyzap Ruby wrapper API for game publishing on your site."
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "heyzap_publisher_api"
|
16
|
+
|
17
|
+
s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
21
|
+
s.require_path = 'lib'
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module HeyzapPublisherApi
|
2
|
+
class Game
|
3
|
+
BASIC_ATTRIBUTES = [
|
4
|
+
:name, :display_name, :description, :categories, :width,
|
5
|
+
:height, :thumb_100x100, :thumb_640x480, :embed_code, :rating,
|
6
|
+
:last_updated
|
7
|
+
].freeze
|
8
|
+
FEATURED_ATTRIBUTES = [
|
9
|
+
:creative_favicon, :creative_splash_banner, :creative_featured_thumbnail, :creative_context_banner, :creative_screenshot,
|
10
|
+
:creative_thumbnail
|
11
|
+
].freeze
|
12
|
+
ATTRIBUTES = BASIC_ATTRIBUTES | FEATURED_ATTRIBUTES
|
13
|
+
ATTRIBUTES.each do |attribute|
|
14
|
+
attr_accessor attribute
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(options={})
|
18
|
+
options.each do |key,value|
|
19
|
+
instance_variable_set "@#{key}", value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module HeyzapPublisherApi
|
2
|
+
class Heyzap
|
3
|
+
attr_accessor :site_key, :secret_key
|
4
|
+
|
5
|
+
ROOT_URL = "http://heyzap.com/publisher_api/"
|
6
|
+
VERSION = "v2/"
|
7
|
+
API_URL = ROOT_URL + VERSION
|
8
|
+
API_SUCCESSFUL_REQUEST = 200
|
9
|
+
API_COULDNT_FIND_GAME_REQUEST = 104
|
10
|
+
|
11
|
+
def initialize(options={})
|
12
|
+
@site_key = options[:site_key]
|
13
|
+
@secret_key = options[:secret_key]
|
14
|
+
end
|
15
|
+
|
16
|
+
def games_by_category(options={})
|
17
|
+
default_category_options = {
|
18
|
+
:featured => nil,
|
19
|
+
:hot_new => nil,
|
20
|
+
:popular => nil,
|
21
|
+
:sports => nil,
|
22
|
+
:shooter => nil,
|
23
|
+
:strategy => nil,
|
24
|
+
:puzzle => nil,
|
25
|
+
:action => nil,
|
26
|
+
:multiplayer => nil,
|
27
|
+
:adventure => nil,
|
28
|
+
:lifestyle => nil,
|
29
|
+
:social => nil,
|
30
|
+
}
|
31
|
+
category_options = []
|
32
|
+
options.each do |key,value|
|
33
|
+
if default_category_options.include?(key)
|
34
|
+
category_options << key unless value.nil?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
category_options = category_options.join(',')
|
38
|
+
|
39
|
+
default_options = {
|
40
|
+
:per_page => 20, :page => 1, :swf_only => "false"
|
41
|
+
}
|
42
|
+
options = default_options.merge(options)
|
43
|
+
|
44
|
+
parsed_result = json_parse(API_URL + "games_by_category?category=#{category_options}&embed_key=#{@site_key}&secret_key=#{@secret_key}&per_page=#{options[:per_page]}&page=#{options[:page]}&swf_only=#{options[:swf_only]}&format=json")
|
45
|
+
|
46
|
+
if parsed_result["status"] == API_SUCCESSFUL_REQUEST
|
47
|
+
returned_games = parsed_result["games"]
|
48
|
+
games = []
|
49
|
+
|
50
|
+
returned_games.each do |returned_game|
|
51
|
+
game = Game.new
|
52
|
+
returned_game.each do |key, value|
|
53
|
+
game.instance_variable_set "@#{key}", value
|
54
|
+
end
|
55
|
+
games << game
|
56
|
+
end
|
57
|
+
result = {:status => API_SUCCESSFUL_REQUEST, :games => games}
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def games_gallery
|
65
|
+
parsed_result = json_parse(API_URL + "games_gallery?embed_key=#{@site_key}&secret_key=#{@secret_key}&format=json")
|
66
|
+
|
67
|
+
if parsed_result["status"] == API_SUCCESSFUL_REQUEST
|
68
|
+
returned_categories = parsed_result["categories"]
|
69
|
+
categories = []
|
70
|
+
returned_categories.each do |returned_category|
|
71
|
+
category = Category.new
|
72
|
+
category.display_name = returned_category["display_name"]
|
73
|
+
category.name = returned_category["name"]
|
74
|
+
category.num_games = returned_category["num_games"]
|
75
|
+
games = []
|
76
|
+
returned_category["games"].each do |returned_game|
|
77
|
+
game = Game.new
|
78
|
+
returned_game.each do |key, value|
|
79
|
+
game.instance_variable_set "@#{key}", value
|
80
|
+
end
|
81
|
+
games << game
|
82
|
+
end
|
83
|
+
category.games = games
|
84
|
+
categories << category
|
85
|
+
end
|
86
|
+
return {:status => API_SUCCESSFUL_REQUEST, :categories => categories}
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def games_by_name(names=[], options={})
|
92
|
+
default_options = {:per_page => 20, :page => 1, :swf_only => "false"}
|
93
|
+
options = default_options.merge(options)
|
94
|
+
game_names = names.join(',')
|
95
|
+
|
96
|
+
parsed_result = json_parse(API_URL + "games_by_name?names=#{game_names}&embed_key=#{@site_key}&per_page=#{options[:per_page]}&page=#{options[:page]}&swf_only=#{options[:swf_only]}&secret_key=#{@secret_key}&format=json")
|
97
|
+
returned_games = parsed_result["games"]
|
98
|
+
|
99
|
+
if parsed_result["status"] == API_SUCCESSFUL_REQUEST
|
100
|
+
games = []
|
101
|
+
returned_games.each do |returned_game|
|
102
|
+
game = Game.new
|
103
|
+
returned_game.each do |key, value|
|
104
|
+
game.instance_variable_set "@#{key}", value
|
105
|
+
end
|
106
|
+
games << game
|
107
|
+
end
|
108
|
+
result = {:status => API_SUCCESSFUL_REQUEST, :games => games}
|
109
|
+
elsif parsed_result["status"] == API_COULDNT_FIND_GAME_REQUEST.to_s
|
110
|
+
result = {:status => API_COULDNT_FIND_GAME_REQUEST, :message => "Couldn't find game with given name."}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def games_by_keyword(options={})
|
115
|
+
default_options = {:per_page => 20, :page => 1, :swf_only => "false"}
|
116
|
+
options = default_options.merge(options)
|
117
|
+
|
118
|
+
parsed_result = json_parse(API_URL + "games_by_keyword?keyword=#{options[:keyword]}&embed_key=#{@site_key}&per_page=#{options[:per_page]}&page=#{options[:page]}&swf_only=#{options[:swf_only]}&secret_key=#{@secret_key}&format=json")
|
119
|
+
|
120
|
+
returned_games = parsed_result["games"]
|
121
|
+
games = []
|
122
|
+
|
123
|
+
if parsed_result["status"] == API_SUCCESSFUL_REQUEST
|
124
|
+
|
125
|
+
returned_games.each do |returned_game|
|
126
|
+
game = Game.new
|
127
|
+
returned_game.each do |key, value|
|
128
|
+
game.instance_variable_set "@#{key}", value
|
129
|
+
end
|
130
|
+
games << game
|
131
|
+
end
|
132
|
+
|
133
|
+
result = {:status => API_SUCCESSFUL_REQUEST, :games => games}
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
def categories
|
140
|
+
|
141
|
+
parsed_result = json_parse(API_URL + "categories?embed_key=#{@site_key}&secret_key=#{@secret_key}&format=json")
|
142
|
+
|
143
|
+
returned_categories = parsed_result["categories"]
|
144
|
+
categories = []
|
145
|
+
|
146
|
+
if parsed_result["status"] == API_SUCCESSFUL_REQUEST
|
147
|
+
|
148
|
+
returned_categories.each do |returned_category|
|
149
|
+
category = Category.new(:name => returned_category["name"],
|
150
|
+
:display_name => returned_category["display_name"],
|
151
|
+
:num_games => returned_category["num_games"])
|
152
|
+
categories << category
|
153
|
+
end
|
154
|
+
|
155
|
+
result = {:status => API_SUCCESSFUL_REQUEST, :categories => categories }
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
private
|
161
|
+
|
162
|
+
def json_parse(base_url)
|
163
|
+
resp = Net::HTTP.get_response(URI.parse(base_url))
|
164
|
+
data = resp.body
|
165
|
+
result = JSON.parse(data)
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
data/spec/game_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HeyzapPublisherApi::Game do
|
4
|
+
|
5
|
+
it "should have the appropriate game details assigned" do
|
6
|
+
game_attribute = {
|
7
|
+
:categories => "Life & Style,Strategy",
|
8
|
+
:creative_context_banner => "http://hzmedia.heyzap.com/game_creatives/images/1424/original/Context Banner.jpg?1298937346",
|
9
|
+
:creative_favicon => "http://hzmedia.heyzap.com/game_creatives/images/1420/original/HeyZap_Favicon_V1.jpg?1298937298",
|
10
|
+
:creative_featured_thumbnail => "http://hzmedia.heyzap.com/game_creatives/images/1422/original/Heyzap_FeatSelThumb_VN2.jpg?1300311949",
|
11
|
+
:creative_screenshot => "http://hzmedia.heyzap.com/game_creatives/images/1425/original/Star-Pageopt.jpg?1298939712",
|
12
|
+
:creative_splash_banner => "http://hzmedia.heyzap.com/game_creatives/images/1421/original/Heyzap_FeatSplashIm_F1.jpg?1298937299",
|
13
|
+
:creative_thumbnail => "http://hzmedia.heyzap.com/game_creatives/images/1423/original/Heyzap_GameSelThumb_New4.jpg?1299097821",
|
14
|
+
:description => "Experience the glam and drama of SFA! Look after wannabe actors, compete for movie roles and pick out the hottest fashion. Can you turn them into red carpet A-listers? ",
|
15
|
+
:display_name => "Star Fever Agency",
|
16
|
+
:embed_code => "<script type=\"text/javascript\">\n (function() {\n var code = \"<div><iframe width=\\\"756\\\" scrolling=\\\"no\\\" height=\\\"480\\\" frameborder=\\\"0\\\" allowtransparency=\\\"true\\\" vspace=\\\"0\\\" hspace=\\\"0\\\" marginheight=\\\"0\\\" marginwidth=\\\"0\\\" src=\\\"http://www.heyzap.com/heyzap?embed=1&embed_key=ueJIszJiUd&game_only=true&height=480&permalink=star-fever&play=1&width=756__JuDxBjzscLO5Mrl__\\\"></iframe></div>\\n<a target=\\\"_blank\\\" href=\\\"http://www.heyzap.com\\\">heyzap.com - embed games</a>\\n\";\n var match = window.location.href.match(/[?&]parent_url=([^&#]*)/);\n try {\n var top_href = top.location.href;\n } catch (err) {\n top_href = undefined;\n }\n var param = \"&\";\n param += 'parent_url=';\n if (top_href) {\n var replacement = param + encodeURIComponent(top.location.href);\n } else if (match) {\n replacement = param + match[1];\n } else if (false){\n replacement = param + encodeURIComponent(window.location.href);\n } else {\n replacement = ''; \n }\n code = code.replace(\"__JuDxBjzscLO5Mrl__\", replacement);\n document.write(code + '<noscript>');\n })();\n</script>\n<div><iframe width=\"756\" scrolling=\"no\" height=\"480\" frameborder=\"0\" allowtransparency=\"true\" vspace=\"0\" hspace=\"0\" marginheight=\"0\" marginwidth=\"0\" src=\"http://www.heyzap.com/heyzap?embed=1&embed_key=ueJIszJiUd&game_only=true&height=480&permalink=star-fever&play=1&width=756\"></iframe></div>\n<a target=\"_blank\" href=\"http://www.heyzap.com\">heyzap.com - embed games</a>\n</noscript>",
|
17
|
+
:height => 480,
|
18
|
+
:last_updated => "2011-03-16T17:16:49-05:00",
|
19
|
+
:name => "star-fever",
|
20
|
+
:rating => 2.5,
|
21
|
+
:thumb_100x100 => "http://hzmedia.heyzap.com/production_thumbnail_games_star-fever_100x100.jpeg",
|
22
|
+
:thumb_640x480 => "http://www.heyzap.com/util/thumbnail/1014271",
|
23
|
+
:width => 756
|
24
|
+
}
|
25
|
+
game = HeyzapPublisherApi::Game.new
|
26
|
+
game_attribute.each do |key, value|
|
27
|
+
game.instance_variable_set "@#{key}", value
|
28
|
+
end
|
29
|
+
|
30
|
+
game.name.should == "star-fever"
|
31
|
+
game.display_name.should == "Star Fever Agency"
|
32
|
+
game.description.should == "Experience the glam and drama of SFA! Look after wannabe actors, compete for movie roles and pick out the hottest fashion. Can you turn them into red carpet A-listers? "
|
33
|
+
game.categories.should == "Life & Style,Strategy"
|
34
|
+
game.width.should == 756
|
35
|
+
game.height.should == 480
|
36
|
+
game.thumb_100x100.should == "http://hzmedia.heyzap.com/production_thumbnail_games_star-fever_100x100.jpeg"
|
37
|
+
game.thumb_640x480.should == "http://www.heyzap.com/util/thumbnail/1014271"
|
38
|
+
game.embed_code.should == "<script type=\"text/javascript\">\n (function() {\n var code = \"<div><iframe width=\\\"756\\\" scrolling=\\\"no\\\" height=\\\"480\\\" frameborder=\\\"0\\\" allowtransparency=\\\"true\\\" vspace=\\\"0\\\" hspace=\\\"0\\\" marginheight=\\\"0\\\" marginwidth=\\\"0\\\" src=\\\"http://www.heyzap.com/heyzap?embed=1&embed_key=ueJIszJiUd&game_only=true&height=480&permalink=star-fever&play=1&width=756__JuDxBjzscLO5Mrl__\\\"></iframe></div>\\n<a target=\\\"_blank\\\" href=\\\"http://www.heyzap.com\\\">heyzap.com - embed games</a>\\n\";\n var match = window.location.href.match(/[?&]parent_url=([^&#]*)/);\n try {\n var top_href = top.location.href;\n } catch (err) {\n top_href = undefined;\n }\n var param = \"&\";\n param += 'parent_url=';\n if (top_href) {\n var replacement = param + encodeURIComponent(top.location.href);\n } else if (match) {\n replacement = param + match[1];\n } else if (false){\n replacement = param + encodeURIComponent(window.location.href);\n } else {\n replacement = ''; \n }\n code = code.replace(\"__JuDxBjzscLO5Mrl__\", replacement);\n document.write(code + '<noscript>');\n })();\n</script>\n<div><iframe width=\"756\" scrolling=\"no\" height=\"480\" frameborder=\"0\" allowtransparency=\"true\" vspace=\"0\" hspace=\"0\" marginheight=\"0\" marginwidth=\"0\" src=\"http://www.heyzap.com/heyzap?embed=1&embed_key=ueJIszJiUd&game_only=true&height=480&permalink=star-fever&play=1&width=756\"></iframe></div>\n<a target=\"_blank\" href=\"http://www.heyzap.com\">heyzap.com - embed games</a>\n</noscript>"
|
39
|
+
game.rating.should == 2.5
|
40
|
+
game.last_updated.should == "2011-03-16T17:16:49-05:00"
|
41
|
+
game.creative_favicon.should == "http://hzmedia.heyzap.com/game_creatives/images/1420/original/HeyZap_Favicon_V1.jpg?1298937298"
|
42
|
+
game.creative_splash_banner.should == "http://hzmedia.heyzap.com/game_creatives/images/1421/original/Heyzap_FeatSplashIm_F1.jpg?1298937299"
|
43
|
+
game.creative_featured_thumbnail.should == "http://hzmedia.heyzap.com/game_creatives/images/1422/original/Heyzap_FeatSelThumb_VN2.jpg?1300311949"
|
44
|
+
game.creative_context_banner.should == "http://hzmedia.heyzap.com/game_creatives/images/1424/original/Context Banner.jpg?1298937346"
|
45
|
+
game.creative_screenshot.should == "http://hzmedia.heyzap.com/game_creatives/images/1425/original/Star-Pageopt.jpg?1298939712"
|
46
|
+
game.creative_thumbnail.should == "http://hzmedia.heyzap.com/game_creatives/images/1423/original/Heyzap_GameSelThumb_New4.jpg?1299097821"
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
data/spec/heyzap_spec.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HeyzapPublisherApi::Heyzap do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@heyzap = HeyzapPublisherApi::Heyzap.new(:site_key => "ueJIszJiUd", :secret_key => "YPGXEX0dsq" )
|
7
|
+
end
|
8
|
+
|
9
|
+
# it 'should return specified number of games' do
|
10
|
+
# number_of_games = 5
|
11
|
+
# keyword = "car"
|
12
|
+
# games = @heyzap.games_by_keyword(:keyword => keyword, :per_page => number_of_games)
|
13
|
+
# games[:status].should == 200
|
14
|
+
# games[:games].count.should equal 5
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# it 'should fetch star-fever game information correctly in an array' do
|
18
|
+
# games = @heyzap.games_by_name(["star-fever"])
|
19
|
+
# games[:status].should == 200
|
20
|
+
# game = games[:games].first
|
21
|
+
# game.name.should == "star-fever"
|
22
|
+
# game.display_name.should == "Star Fever Agency"
|
23
|
+
# game.description.should == "Experience the glam and drama of SFA! Look after wannabe actors, compete for movie roles and pick out the hottest fashion. Can you turn them into red carpet A-listers? "
|
24
|
+
# game.categories.should == "Life & Style,Strategy"
|
25
|
+
# game.width.should == 756
|
26
|
+
# game.height.should == 480
|
27
|
+
# game.thumb_100x100.should == "http://hzmedia.heyzap.com/production_thumbnail_games_star-fever_100x100.jpeg"
|
28
|
+
# game.thumb_640x480.should == "http://www.heyzap.com/util/thumbnail/1014271"
|
29
|
+
# game.rating.should == 2.5
|
30
|
+
# game.last_updated.should == "2011-03-16T17:16:49-05:00"
|
31
|
+
# game.creative_favicon.should == "http://hzmedia.heyzap.com/game_creatives/images/1420/original/HeyZap_Favicon_V1.jpg?1298937298"
|
32
|
+
# game.creative_splash_banner.should == "http://hzmedia.heyzap.com/game_creatives/images/1421/original/Heyzap_FeatSplashIm_F1.jpg?1298937299"
|
33
|
+
# game.creative_featured_thumbnail.should == "http://hzmedia.heyzap.com/game_creatives/images/1422/original/Heyzap_FeatSelThumb_VN2.jpg?1300311949"
|
34
|
+
# game.creative_context_banner.should == "http://hzmedia.heyzap.com/game_creatives/images/1424/original/Context Banner.jpg?1298937346"
|
35
|
+
# game.creative_screenshot.should == "http://hzmedia.heyzap.com/game_creatives/images/1425/original/Star-Pageopt.jpg?1298939712"
|
36
|
+
# game.creative_thumbnail.should == "http://hzmedia.heyzap.com/game_creatives/images/1423/original/Heyzap_GameSelThumb_New4.jpg?1299097821"
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# it 'should handle when game name is not found' do
|
40
|
+
# games = @heyzap.games_by_name(["star-fever", "aaaa"])
|
41
|
+
# games[:status].should == 104
|
42
|
+
# games[:message].should == "Couldn't find game with given name."
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# it 'should return games from a category'
|
46
|
+
|
47
|
+
it 'should return games from various hot categories of gallery' do
|
48
|
+
games = @heyzap.games_by_category(:featured => true, :hot_new => true)
|
49
|
+
puts games.class
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heyzap_publisher_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- tm lee
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-21 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
- rc
|
33
|
+
- 6
|
34
|
+
version: 1.0.0.rc.6
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Unofficial Heyzap Ruby wrapper API for game publishing on your site.
|
38
|
+
email:
|
39
|
+
- tm89lee@gmail.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- heyzap_publisher_api.gemspec
|
53
|
+
- lib/heyzap_publisher_api.rb
|
54
|
+
- lib/heyzap_publisher_api/category.rb
|
55
|
+
- lib/heyzap_publisher_api/game.rb
|
56
|
+
- lib/heyzap_publisher_api/heyzap.rb
|
57
|
+
- lib/heyzap_publisher_api/version.rb
|
58
|
+
- spec/game_spec.rb
|
59
|
+
- spec/heyzap_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://rubygems.org/gems/heyzap_publisher_api
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 1
|
85
|
+
- 3
|
86
|
+
- 6
|
87
|
+
version: 1.3.6
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project: heyzap_publisher_api
|
91
|
+
rubygems_version: 1.3.7
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Unofficial Heyzap Ruby wrapper API for game publishing on your site.
|
95
|
+
test_files: []
|
96
|
+
|