Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ PLATFORMS
DEPENDENCIES
fakeweb (~> 1.3.0)
geckoboard-push!
httparty (~> 0.8.1)
mocha (~> 0.10.0)
rake
rdoc
2 changes: 2 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Exposes a Geckoboard::Push class allowing updates for the following widget types
* pie chart
* geckometer
* funnel chart
* highcharts

== SYNOPSIS:

Expand Down Expand Up @@ -45,6 +46,7 @@ It's best to add it to the Gemfile for your app, but if needed you can install t
== CONTRIBUTORS:

Elliott Draper
Martin Naumann

== LICENSE:

Expand Down
8 changes: 4 additions & 4 deletions geckoboard-push.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = %q{geckoboard-push}
s.version = "0.1.0"
s.version = "0.1.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Elliott Draper"]
Expand All @@ -21,16 +21,16 @@ Gem::Specification.new do |s|
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<httparty>, ["~> 0.8.1"])
s.add_runtime_dependency(%q<httparty>, ["~> 0.11.0"])
s.add_development_dependency(%q<fakeweb>, ["~> 1.3.0"])
s.add_development_dependency(%q<mocha>, ["~> 0.10.0"])
else
s.add_dependency(%q<httparty>, ["~> 0.8.1"])
s.add_dependency(%q<httparty>, ["~> 0.11.0"])
s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
s.add_dependency(%q<mocha>, ["~> 0.10.0"])
end
else
s.add_dependency(%q<httparty>, ["~> 0.8.1"])
s.add_dependency(%q<httparty>, ["~> 0.11.0"])
s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
s.add_dependency(%q<mocha>, ["~> 0.10.0"])
end
Expand Down
8 changes: 8 additions & 0 deletions lib/geckoboard/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,13 @@ def funnel(items, reverse = false, hide_percentage = false)
opts[:percentage] = "hide" if hide_percentage
self.push(opts)
end

# Values should be an array of hashes of the format {name: "some label", [10.0, 3, 8, ...]}
# Options are an optional hash with all the available highchart options
def highchart(values, options)
self.push({"highchart" => {
chart: {renderTo: 'container'}, credits: {enabled: false}, series: values
}.merge(options)})
end
end
end
7 changes: 7 additions & 0 deletions test/geckoboard/push_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def test_funnel
assert_equal true, @push.funnel([{:label => "Test1", :value => 5}, {:label => "Test2", :value => 10}], true, true)
end

def test_highcharts

expect_http_request({"api_key" => "12345", "data" => {"highchart" => { "chart" => {renderTo: 'container'}, credits: {enabled: false}, series: [{name: 'ABC', data: [1,2,3]}, {name: 'DEF', data: [4,5,6]}], yAxis: { title: {text: "LABEL"} }}}}.to_json)
assert_equal true, @push.highchart([{name: 'ABC', data: [1,2,3]}, {name: 'DEF', data: [4,5,6]}], {yAxis: {title: {text: "LABEL"}} })
end


def expect_http_request(json)
response = Net::HTTPOK.new("1.1", 200, "OK")
response.instance_variable_set(:@body, '{"success":true}')
Expand Down