diff --git a/README.rdoc b/README.rdoc index 5b74bef..f0478de 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 +* map == SYNOPSIS: diff --git a/lib/geckoboard/push.rb b/lib/geckoboard/push.rb index d2b5600..ffeed65 100644 --- a/lib/geckoboard/push.rb +++ b/lib/geckoboard/push.rb @@ -93,5 +93,12 @@ def funnel(items, reverse = false, hide_percentage = false) opts[:percentage] = "hide" if hide_percentage self.push(opts) end + + # Items should be an array of hashes. These are passed verabit to the Map API + # check http://docs.geckoboard.com/custom-widgets/map.html for possible + # examples + def map(items) + self.push(:points => { :point => items}) + end end end diff --git a/test/geckoboard/push_test.rb b/test/geckoboard/push_test.rb index e68ce56..12032b9 100644 --- a/test/geckoboard/push_test.rb +++ b/test/geckoboard/push_test.rb @@ -42,12 +42,12 @@ def test_text def test_rag expect_http_request({"api_key" => "12345", "data" => {"item" => [{"value" => 1}, {"value" => 2}, {"value" => 3}]}}.to_json) - assert_equal true, @push.rag(1,2,3) + assert_equal true, @push.rag(1, 2, 3) end def test_line - expect_http_request({"api_key" => "12345", "data" => {"item" => [1,2,3], "settings" => {"axisx" => "x axis", "axisy" => "y axis", "colour" => "ff9900"}}}.to_json) - assert_equal true, @push.line([1,2,3], "ff9900", "x axis", "y axis") + expect_http_request({"api_key" => "12345", "data" => {"item" => [1, 2, 3], "settings" => {"axisx" => "x axis", "axisy" => "y axis", "colour" => "ff9900"}}}.to_json) + assert_equal true, @push.line([1, 2, 3], "ff9900", "x axis", "y axis") end def test_pie @@ -65,6 +65,11 @@ def test_funnel assert_equal true, @push.funnel([{:label => "Test1", :value => 5}, {:label => "Test2", :value => 10}], true, true) end + def test_map + expect_http_request({"api_key" => "12345", "data" => {"points" => {"point" => [{ "city" => { "city_name" => "London", "country_code" => "GB"}}]}}}.to_json) + assert_equal true, @push.map(["city" => { "city_name" => "London", "country_code" => "GB" }]) + end + def expect_http_request(json) response = Net::HTTPOK.new("1.1", 200, "OK") response.instance_variable_set(:@body, '{"success":true}')