diff --git a/Gemfile.lock b/Gemfile.lock index 1d5d0ad..76cd75c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,7 +27,6 @@ PLATFORMS DEPENDENCIES fakeweb (~> 1.3.0) geckoboard-push! - httparty (~> 0.8.1) mocha (~> 0.10.0) rake rdoc diff --git a/README.rdoc b/README.rdoc index 5b74bef..524f0e0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -17,6 +17,7 @@ Exposes a Geckoboard::Push class allowing updates for the following widget types * pie chart * geckometer * funnel chart +* highcharts == SYNOPSIS: @@ -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: diff --git a/geckoboard-push.gemspec b/geckoboard-push.gemspec index 5d4efc9..066886a 100644 --- a/geckoboard-push.gemspec +++ b/geckoboard-push.gemspec @@ -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"] @@ -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, ["~> 0.8.1"]) + s.add_runtime_dependency(%q, ["~> 0.11.0"]) s.add_development_dependency(%q, ["~> 1.3.0"]) s.add_development_dependency(%q, ["~> 0.10.0"]) else - s.add_dependency(%q, ["~> 0.8.1"]) + s.add_dependency(%q, ["~> 0.11.0"]) s.add_dependency(%q, ["~> 1.3.0"]) s.add_dependency(%q, ["~> 0.10.0"]) end else - s.add_dependency(%q, ["~> 0.8.1"]) + s.add_dependency(%q, ["~> 0.11.0"]) s.add_dependency(%q, ["~> 1.3.0"]) s.add_dependency(%q, ["~> 0.10.0"]) end diff --git a/lib/geckoboard/push.rb b/lib/geckoboard/push.rb index d2b5600..087bf3b 100644 --- a/lib/geckoboard/push.rb +++ b/lib/geckoboard/push.rb @@ -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 diff --git a/test/geckoboard/push_test.rb b/test/geckoboard/push_test.rb index e68ce56..a2c200d 100644 --- a/test/geckoboard/push_test.rb +++ b/test/geckoboard/push_test.rb @@ -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}')