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: 1 addition & 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
* map

== SYNOPSIS:

Expand Down
7 changes: 7 additions & 0 deletions lib/geckoboard/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 8 additions & 3 deletions test/geckoboard/push_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}')
Expand Down