gecko-pusher 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +19 -0
- data/LICENSE +22 -0
- data/README.md +81 -0
- data/Rakefile +2 -0
- data/gecko-pusher.gemspec +26 -0
- data/lib/gecko-pusher.rb +41 -0
- data/lib/gecko-pusher/channel.rb +1 -0
- data/lib/gecko-pusher/channel/base.rb +28 -0
- data/lib/gecko-pusher/channel/line_chart.rb +17 -0
- data/lib/gecko-pusher/channel/rag.rb +35 -0
- data/lib/gecko-pusher/channel/text.rb +46 -0
- data/lib/gecko-pusher/version.rb +5 -0
- data/spec/lib/gecko-pusher/channel/line_chart_spec.rb +24 -0
- data/spec/lib/gecko-pusher/channel/rag_spec.rb +42 -0
- data/spec/lib/gecko-pusher/channel/text_spec.rb +99 -0
- data/spec/lib/gecko-pusher/channel_spec.rb +6 -0
- data/spec/lib/gecko-pusher/version_spec.rb +5 -0
- data/spec/lib/gecko_pusher_spec.rb +37 -0
- data/spec/spec_helper.rb +24 -0
- metadata +193 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2 do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
# Capybara request specs
|
17
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
18
|
+
end
|
19
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Steven Mohapi-Banks
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Gecko::Pusher
|
2
|
+
|
3
|
+
Provides a simple library to send updates to GeckoBoard via its push API
|
4
|
+
|
5
|
+
PLEASE NOTE: at present this README is a spec - the library does not implement all these features yet.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'gecko-pusher'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install gecko-pusher
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Configure your API key
|
24
|
+
|
25
|
+
Gecko::Pusher.api_key = <your api key>
|
26
|
+
|
27
|
+
or set the following environment variable - Gecko::Pusher will pick it up
|
28
|
+
|
29
|
+
GECKO_PUSHER_APIKEY = <your api key>
|
30
|
+
|
31
|
+
### Setting up a channel
|
32
|
+
|
33
|
+
channel = Gecko::Pusher.channel(:text, "<your widget key>")
|
34
|
+
|
35
|
+
First parameter options:
|
36
|
+
|
37
|
+
:text
|
38
|
+
:map
|
39
|
+
:number
|
40
|
+
:rag
|
41
|
+
:rag_col
|
42
|
+
:line_chart
|
43
|
+
:pie_chart
|
44
|
+
:gecko_meter
|
45
|
+
:funnel
|
46
|
+
:bullet
|
47
|
+
|
48
|
+
Creating a channel with an missing or invalid type will cause an ArgumentError to be raised.
|
49
|
+
|
50
|
+
### Text
|
51
|
+
|
52
|
+
Creating a channel returns an object that makes it easy to send messages to Geckoboard without having to manually create the JSON. Rather, the push method will parse your args in (hopefully) a manner that makes sense. So, text widgets (when you use the :text option) will understand the following:
|
53
|
+
|
54
|
+
channel.push("Message") // Single plain message
|
55
|
+
channel.push(Gecko::Pusher::TEXT_ALERT, "Message") // Single alert message
|
56
|
+
channel.push("One", "Two", "Three") // Multiple plain messages
|
57
|
+
channel.push(Gecko::Pusher::TEXT_ALERT, "One", "Two", "Three") // Muliple alert messages
|
58
|
+
channel.push(
|
59
|
+
[ Gecko::Pusher::TEXT_ALERT, "One", "Two" ],
|
60
|
+
[ Gecko::Pusher::TEXT_INFO, "Three", "Four" ],
|
61
|
+
[ "Five", "Six"]
|
62
|
+
) // Multiple different message types, one type per array (default: Gecko::Pusher::TEXT_PLAIN)
|
63
|
+
|
64
|
+
### RAG widgets
|
65
|
+
|
66
|
+
channel.push(100, 200, 300) // Pushes RAG values with no description
|
67
|
+
channel.push(100, "desc", 222, "desc", 300 "desc") // Push RAG values with descriptions
|
68
|
+
channel.push(:green, 100) // Just push a green value
|
69
|
+
channel.push(:green, 100, "Description") // Push a green value with a description
|
70
|
+
|
71
|
+
### Line charts
|
72
|
+
|
73
|
+
channel.push(1,2,3,4,5)
|
74
|
+
|
75
|
+
## Contributing
|
76
|
+
|
77
|
+
1. Fork it
|
78
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
79
|
+
3. Commit your changes with specs to ensure resilience to regressions (`git commit -am 'Added some feature'`)
|
80
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
81
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/gecko-pusher/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Steven Mohapi-Banks"]
|
6
|
+
gem.email = ["steven.mohapibanks@gmail.com"]
|
7
|
+
gem.description = %q{Provides a simple library to send updates to Geckoboard via its push API.}
|
8
|
+
gem.summary = %q{Provides a simple library to send updates to Geckoboard via its push API.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "gecko-pusher"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Gecko::Pusher::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "activesupport", "~> 3.2.6"
|
19
|
+
gem.add_dependency "httpclient", "~> 2.2.5"
|
20
|
+
gem.add_dependency "faraday", "~> 0.8.1"
|
21
|
+
|
22
|
+
gem.add_development_dependency "rspec", "~> 2.10"
|
23
|
+
gem.add_development_dependency "webmock", "~> 1.8.7"
|
24
|
+
gem.add_development_dependency "guard-rspec", "~> 1.0"
|
25
|
+
gem.add_development_dependency "rake", "~> 0.9.2.2"
|
26
|
+
end
|
data/lib/gecko-pusher.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
require 'gecko-pusher/channel'
|
5
|
+
require 'gecko-pusher/version'
|
6
|
+
|
7
|
+
module Gecko
|
8
|
+
module Pusher
|
9
|
+
|
10
|
+
CHANNEL_TYPES = [
|
11
|
+
:text, :map, :number, :rag, :rag_col, :line_chart,
|
12
|
+
:pie_chart, :gecko_meter, :funnel, :bullet
|
13
|
+
]
|
14
|
+
|
15
|
+
TEXT_NONE = 0
|
16
|
+
TEXT_ALERT = 1
|
17
|
+
TEXT_INFO = 2
|
18
|
+
TEXT_TYPES = [TEXT_NONE, TEXT_ALERT, TEXT_INFO]
|
19
|
+
|
20
|
+
class NotInitializedError < StandardError
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
attr_accessor :api_key
|
25
|
+
|
26
|
+
def channel(widget_type, widget_key)
|
27
|
+
raise NotInitializedError if api_key.nil?
|
28
|
+
raise ArgumentError.new("widget_key cannot be nil") if widget_key.nil?
|
29
|
+
raise ArgumentError unless CHANNEL_TYPES.include?(widget_type)
|
30
|
+
|
31
|
+
"Gecko::Pusher::Channel::#{widget_type.to_s.camelize}".constantize.new(widget_key)
|
32
|
+
end
|
33
|
+
|
34
|
+
def connection
|
35
|
+
@connection ||= Faraday.new(:url => "https://push.geckoboard.com") do |builder|
|
36
|
+
builder.adapter :net_http
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
%w{base text rag line_chart}.each {|f| require "gecko-pusher/channel/#{f}"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Gecko
|
4
|
+
module Pusher
|
5
|
+
module Channel
|
6
|
+
class Base
|
7
|
+
|
8
|
+
def initialize(widget_key)
|
9
|
+
@widget_key = widget_key
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def _push(data)
|
15
|
+
payload = {
|
16
|
+
api_key: Gecko::Pusher.api_key,
|
17
|
+
data: data
|
18
|
+
}
|
19
|
+
Gecko::Pusher.connection.post do |req|
|
20
|
+
req.url "/v1/send/#{@widget_key}"
|
21
|
+
req.body = payload.to_json
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Gecko
|
2
|
+
module Pusher
|
3
|
+
module Channel
|
4
|
+
class Rag < Base
|
5
|
+
|
6
|
+
def push(*args)
|
7
|
+
data = if is_basic_rag?(*args)
|
8
|
+
{ item: [ { value: args[0] }, { value: args[1] }, { value: args[2] } ] }
|
9
|
+
elsif is_basic_rag_with_descriptions?(*args)
|
10
|
+
{ item: [ { value: args[0], text: args[1] },
|
11
|
+
{ value: args[2], text: args[3]},
|
12
|
+
{ value: args[4], text: args[5]} ] }
|
13
|
+
end
|
14
|
+
_push(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def is_basic_rag?(*args)
|
20
|
+
args.length == 3 && args.all? {|arg| arg.is_a? Integer}
|
21
|
+
end
|
22
|
+
|
23
|
+
def is_basic_rag_with_descriptions?(*args)
|
24
|
+
args.length == 6 &&
|
25
|
+
args[0].is_a?(Integer) &&
|
26
|
+
args[2].is_a?(Integer) &&
|
27
|
+
args[4].is_a?(Integer) &&
|
28
|
+
args[1].is_a?(String) &&
|
29
|
+
args[3].is_a?(String) &&
|
30
|
+
args[5].is_a?(String)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Gecko
|
2
|
+
module Pusher
|
3
|
+
module Channel
|
4
|
+
class Text < Base
|
5
|
+
|
6
|
+
def push(*args)
|
7
|
+
return if args.empty?
|
8
|
+
data = { item: extract_items(*args) }
|
9
|
+
_push(data)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def extract_items(*args)
|
15
|
+
message_groups = multiple_types?(*args) ? args : [args]
|
16
|
+
items = []
|
17
|
+
message_groups.each do |message_group|
|
18
|
+
message_type, messages = extract_message_type_and_messages(*message_group)
|
19
|
+
messages.each {|msg|
|
20
|
+
items << {text: msg, type: message_type}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
items
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract_message_type_and_messages(*args)
|
27
|
+
text_type = args.first.is_a?(Integer) ? args.shift : Gecko::Pusher::TEXT_NONE
|
28
|
+
args.delete_if {|arg| arg.is_a? Integer}
|
29
|
+
[text_type, args]
|
30
|
+
end
|
31
|
+
|
32
|
+
def multiple_types?(*args)
|
33
|
+
unless args.select {|arg| arg.is_a? Array }.empty?
|
34
|
+
raise_argument_error_if_arguments_contain_non_array(*args)
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
def raise_argument_error_if_arguments_contain_non_array(*args)
|
41
|
+
raise ArgumentError.new("Must call with a single message type or an array of message types.\nArgs: #{args.inspect.to_s}") unless args.reject {|arg| arg.is_a? Array }.empty?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gecko::Pusher::Channel::LineChart do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
WebMock.reset!
|
7
|
+
Gecko::Pusher.api_key = API_KEY
|
8
|
+
@channel = Gecko::Pusher.channel(:line_chart, WIDGET_KEY)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should initiate a line chart channel" do
|
12
|
+
@channel.should be_a(Gecko::Pusher::Channel::LineChart)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should push a basic array of values" do
|
16
|
+
data = {
|
17
|
+
item: [ 1,2,3,4,5 ]
|
18
|
+
}
|
19
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
20
|
+
@channel.push(1,2,3,4,5)
|
21
|
+
stub.should have_been_requested
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gecko::Pusher::Channel::Rag do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
WebMock.reset!
|
7
|
+
Gecko::Pusher.api_key = API_KEY
|
8
|
+
@channel = Gecko::Pusher.channel(:rag, WIDGET_KEY)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should initiate a RAG channel" do
|
12
|
+
@channel.should be_a(Gecko::Pusher::Channel::Rag)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should push RAG values" do
|
16
|
+
data = {
|
17
|
+
item: [
|
18
|
+
{ value: 100 },
|
19
|
+
{ value: 200 },
|
20
|
+
{ value: 300 }
|
21
|
+
]
|
22
|
+
}
|
23
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
24
|
+
@channel.push(100, 200, 300)
|
25
|
+
stub.should have_been_requested
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should push RAG values and descriptions" do
|
29
|
+
data = {
|
30
|
+
item: [
|
31
|
+
{ value: 100, text: "red description" },
|
32
|
+
{ value: 200, text: "amber description" },
|
33
|
+
{ value: 300, text: "green description" }
|
34
|
+
]
|
35
|
+
}
|
36
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
37
|
+
@channel.push(100, "red description",
|
38
|
+
200, "amber description",
|
39
|
+
300, "green description")
|
40
|
+
stub.should have_been_requested
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gecko::Pusher::Channel::Text do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
WebMock.reset!
|
7
|
+
Gecko::Pusher.api_key = API_KEY
|
8
|
+
@channel = Gecko::Pusher.channel(:text, WIDGET_KEY)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should initiate a Text channel" do
|
12
|
+
@channel.should be_a(Gecko::Pusher::Channel::Text)
|
13
|
+
end
|
14
|
+
it "should not push at all if no message is sent" do
|
15
|
+
stub = stub_gecko_post(WIDGET_KEY, {})
|
16
|
+
@channel.push()
|
17
|
+
stub.should_not have_been_requested
|
18
|
+
end
|
19
|
+
it "should push a single plain message" do
|
20
|
+
data = {
|
21
|
+
item: [
|
22
|
+
{ text: "Message", type: 0 }
|
23
|
+
]
|
24
|
+
}
|
25
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
26
|
+
@channel.push("Message")
|
27
|
+
stub.should have_been_requested
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should push a single ALERT message" do
|
31
|
+
data = {
|
32
|
+
item: [
|
33
|
+
{ text: "Message", type: 1 }
|
34
|
+
]
|
35
|
+
}
|
36
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
37
|
+
@channel.push(Gecko::Pusher::TEXT_ALERT, "Message")
|
38
|
+
stub.should have_been_requested
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should push multiple plain messages" do
|
42
|
+
data = {
|
43
|
+
item: [
|
44
|
+
{ text: "Message 1", type: 0 },
|
45
|
+
{ text: "Message 2", type: 0 },
|
46
|
+
{ text: "Message 3", type: 0 }
|
47
|
+
]
|
48
|
+
}
|
49
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
50
|
+
@channel.push("Message 1", "Message 2", "Message 3")
|
51
|
+
stub.should have_been_requested
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should push multiple ALERT messages" do
|
55
|
+
data = {
|
56
|
+
item: [
|
57
|
+
{ text: "Message 1", type: 1 },
|
58
|
+
{ text: "Message 2", type: 1 },
|
59
|
+
{ text: "Message 3", type: 1 }
|
60
|
+
]
|
61
|
+
}
|
62
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
63
|
+
@channel.push(Gecko::Pusher::TEXT_ALERT, "Message 1", "Message 2", "Message 3")
|
64
|
+
stub.should have_been_requested
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should silently ignore unecessary message types in arguments" do
|
68
|
+
data = {
|
69
|
+
item: [
|
70
|
+
{ text: "Message 1", type: 1 },
|
71
|
+
{ text: "Message 2", type: 1 },
|
72
|
+
{ text: "Message 3", type: 1 }
|
73
|
+
]
|
74
|
+
}
|
75
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
76
|
+
@channel.push(Gecko::Pusher::TEXT_ALERT, "Message 1", "Message 2", Gecko::Pusher::TEXT_INFO, "Message 3")
|
77
|
+
stub.should have_been_requested
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should push a combination of many message types" do
|
81
|
+
data = {
|
82
|
+
item: [
|
83
|
+
{ text: "Message 1", type: 0 },
|
84
|
+
{ text: "Message 2", type: 0 },
|
85
|
+
{ text: "Message 3", type: 1 },
|
86
|
+
{ text: "Message 4", type: 1 },
|
87
|
+
{ text: "Message 5", type: 2 },
|
88
|
+
{ text: "Message 6", type: 2 }
|
89
|
+
]
|
90
|
+
}
|
91
|
+
stub = stub_gecko_post(WIDGET_KEY, data)
|
92
|
+
@channel.push(
|
93
|
+
["Message 1", "Message 2"],
|
94
|
+
[Gecko::Pusher::TEXT_ALERT, "Message 3", "Message 4"],
|
95
|
+
[Gecko::Pusher::TEXT_INFO, "Message 5", "Message 6"]
|
96
|
+
)
|
97
|
+
stub.should have_been_requested
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gecko::Pusher do
|
4
|
+
|
5
|
+
describe "Creating a channel" do
|
6
|
+
context "without setting an API key" do
|
7
|
+
before(:each) do
|
8
|
+
Gecko::Pusher.api_key = nil
|
9
|
+
end
|
10
|
+
it "should raise a Gecko::Pusher::NotInitializedError" do
|
11
|
+
expect {
|
12
|
+
Gecko::Pusher.channel(:text, "widget_key")
|
13
|
+
}.should raise_error(Gecko::Pusher::NotInitializedError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
context "after setting an API key" do
|
17
|
+
before(:each) do
|
18
|
+
Gecko::Pusher.api_key = "ABC123"
|
19
|
+
end
|
20
|
+
context "without an invalid widget key" do
|
21
|
+
it "should raise an ArgumentError" do
|
22
|
+
expect {
|
23
|
+
Gecko::Pusher.channel(:text, nil)
|
24
|
+
}.should raise_error(ArgumentError)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
context "with an invalid type" do
|
28
|
+
it "should raise an ArgumentError" do
|
29
|
+
expect {
|
30
|
+
Gecko::Pusher.channel(:invalid_type, "abc123")
|
31
|
+
}.should raise_error(ArgumentError)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'gecko-pusher'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
|
+
config.run_all_when_everything_filtered = true
|
8
|
+
config.filter_run :focus
|
9
|
+
end
|
10
|
+
|
11
|
+
API_KEY = "187249817294871"
|
12
|
+
WIDGET_KEY = "rag_widget"
|
13
|
+
|
14
|
+
def stub_gecko_post(widget_key, data)
|
15
|
+
url = "https://push.geckoboard.com/v1/send/#{widget_key}"
|
16
|
+
stub_request(:post, url).
|
17
|
+
with(
|
18
|
+
:body => {
|
19
|
+
api_key: API_KEY,
|
20
|
+
data: data
|
21
|
+
}.to_json,
|
22
|
+
:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
23
|
+
to_return(:status => 200, :body => "", :headers => {})
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gecko-pusher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Steven Mohapi-Banks
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: httpclient
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.2.5
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.2.5
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: faraday
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.1
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.1
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.10'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.10'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: webmock
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.8.7
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.8.7
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: guard-rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rake
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.9.2.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.9.2.2
|
126
|
+
description: Provides a simple library to send updates to Geckoboard via its push
|
127
|
+
API.
|
128
|
+
email:
|
129
|
+
- steven.mohapibanks@gmail.com
|
130
|
+
executables: []
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- .gitignore
|
135
|
+
- .rspec
|
136
|
+
- Gemfile
|
137
|
+
- Guardfile
|
138
|
+
- LICENSE
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- gecko-pusher.gemspec
|
142
|
+
- lib/gecko-pusher.rb
|
143
|
+
- lib/gecko-pusher/channel.rb
|
144
|
+
- lib/gecko-pusher/channel/base.rb
|
145
|
+
- lib/gecko-pusher/channel/line_chart.rb
|
146
|
+
- lib/gecko-pusher/channel/rag.rb
|
147
|
+
- lib/gecko-pusher/channel/text.rb
|
148
|
+
- lib/gecko-pusher/version.rb
|
149
|
+
- spec/lib/gecko-pusher/channel/line_chart_spec.rb
|
150
|
+
- spec/lib/gecko-pusher/channel/rag_spec.rb
|
151
|
+
- spec/lib/gecko-pusher/channel/text_spec.rb
|
152
|
+
- spec/lib/gecko-pusher/channel_spec.rb
|
153
|
+
- spec/lib/gecko-pusher/version_spec.rb
|
154
|
+
- spec/lib/gecko_pusher_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
homepage: ''
|
157
|
+
licenses: []
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
hash: 2628149161098194948
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
segments:
|
178
|
+
- 0
|
179
|
+
hash: 2628149161098194948
|
180
|
+
requirements: []
|
181
|
+
rubyforge_project:
|
182
|
+
rubygems_version: 1.8.23
|
183
|
+
signing_key:
|
184
|
+
specification_version: 3
|
185
|
+
summary: Provides a simple library to send updates to Geckoboard via its push API.
|
186
|
+
test_files:
|
187
|
+
- spec/lib/gecko-pusher/channel/line_chart_spec.rb
|
188
|
+
- spec/lib/gecko-pusher/channel/rag_spec.rb
|
189
|
+
- spec/lib/gecko-pusher/channel/text_spec.rb
|
190
|
+
- spec/lib/gecko-pusher/channel_spec.rb
|
191
|
+
- spec/lib/gecko-pusher/version_spec.rb
|
192
|
+
- spec/lib/gecko_pusher_spec.rb
|
193
|
+
- spec/spec_helper.rb
|