atk-ducksboard 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.mdown +64 -0
- data/ducksboard.gemspec +29 -0
- data/lib/ducksboard.rb +16 -0
- data/lib/ducksboard/box.rb +8 -0
- data/lib/ducksboard/counter.rb +4 -0
- data/lib/ducksboard/gauge.rb +4 -0
- data/lib/ducksboard/graph.rb +7 -0
- data/lib/ducksboard/image.rb +42 -0
- data/lib/ducksboard/pin.rb +7 -0
- data/lib/ducksboard/pull.rb +19 -0
- data/lib/ducksboard/timeline.rb +43 -0
- data/lib/ducksboard/widget.rb +50 -0
- metadata +85 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Joseph Hsu
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.mdown
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
## Ducksboard API Ruby wrapper
|
2
|
+
|
3
|
+
### Configuration
|
4
|
+
|
5
|
+
API Key can be set in the environment
|
6
|
+
|
7
|
+
export DUCKSBOARD_API_KEY='YOURKEY'
|
8
|
+
|
9
|
+
or in an initializer
|
10
|
+
|
11
|
+
Ducksboard.api_key = 'YOURKEY'
|
12
|
+
|
13
|
+
### Box
|
14
|
+
|
15
|
+
widget = Ducksboard::Box.new(1234) # Widget numeric id
|
16
|
+
widget.value = 10
|
17
|
+
widget.save
|
18
|
+
|
19
|
+
### Counter
|
20
|
+
|
21
|
+
widget = Ducksboard::Counter.new(1234)
|
22
|
+
widget.value = 10
|
23
|
+
widget.save
|
24
|
+
|
25
|
+
### Image
|
26
|
+
|
27
|
+
widget = Ducksboard::Image.new(1235)
|
28
|
+
widget.source = "https://dashboard.ducksboard.com/static/accounts/img/logo_small.png"
|
29
|
+
# or
|
30
|
+
widget.source = "~/Pictures/logo.png"
|
31
|
+
widget.caption = "Ducksboard logo!"
|
32
|
+
widget.timestamp = 1310649204
|
33
|
+
widget.save
|
34
|
+
|
35
|
+
### Gauge
|
36
|
+
|
37
|
+
widget = Ducksboard::Graph.new(1235)
|
38
|
+
widget.value = 0.93
|
39
|
+
widget.save
|
40
|
+
|
41
|
+
### Graph
|
42
|
+
|
43
|
+
# remember that the graph widgets need atleast 2 points before it displays anything
|
44
|
+
widget = Ducksboard::Graph.new(1236)
|
45
|
+
widget.timestamp = Time.now.to_i
|
46
|
+
widget.value = 198
|
47
|
+
widget.save
|
48
|
+
|
49
|
+
### Pin
|
50
|
+
|
51
|
+
widget = Ducksboard::Pin.new(1234)
|
52
|
+
widget.value = 10
|
53
|
+
widget.save
|
54
|
+
|
55
|
+
### Timeline
|
56
|
+
|
57
|
+
widget = Ducksboard::Timeline.new(1237)
|
58
|
+
widget.title = "A Title"
|
59
|
+
widget.image = "http://url.to.io/some_image.gif"
|
60
|
+
# or
|
61
|
+
widget.image = :edited
|
62
|
+
# any of the following as a string or symbol: orange, red, green, created, edited or deleted
|
63
|
+
widget.content = "text content"
|
64
|
+
widget.link = "http://google.com"
|
data/ducksboard.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'atk-ducksboard'
|
3
|
+
s.version = '0.1.4'
|
4
|
+
s.summary = "API wrapper for ducksboard.com dashboard with pull support"
|
5
|
+
s.description = "Ruby API wrapper for ducksboard realtime dashboard using HTTParty"
|
6
|
+
s.authors = ["Joseph Hsu", "America's Test Kitchen"]
|
7
|
+
s.email = 'jhsu.x1@gmail.com'
|
8
|
+
s.files = `git ls-files`.split("\n")
|
9
|
+
s.homepage = 'http://github.com/Americastestkitchen/ducksboard'
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.required_ruby_version = '>= 1.8.7'
|
12
|
+
|
13
|
+
s.add_runtime_dependency 'httparty', '~> 0.8', '>= 0.8.1'
|
14
|
+
|
15
|
+
s.post_install_message = <<-DESC
|
16
|
+
Quack! (in real-time)"
|
17
|
+
|
18
|
+
===
|
19
|
+
|
20
|
+
Don't forget to set your ENV variable for DUCKSBOARD_API_KEY
|
21
|
+
|
22
|
+
export DUCKSBOARD_API_KEY='YOURKEY'
|
23
|
+
|
24
|
+
or set it in your script
|
25
|
+
|
26
|
+
Ducksboard.api_key = 'YOURKEY'
|
27
|
+
DESC
|
28
|
+
|
29
|
+
end
|
data/lib/ducksboard.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Ducksboard
|
4
|
+
class << self ; attr_accessor :api_key end
|
5
|
+
@api_key = ENV['DUCKSBOARD_API_KEY']
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'ducksboard/widget'
|
9
|
+
require 'ducksboard/box'
|
10
|
+
require 'ducksboard/counter'
|
11
|
+
require 'ducksboard/gauge'
|
12
|
+
require 'ducksboard/graph'
|
13
|
+
require 'ducksboard/image'
|
14
|
+
require 'ducksboard/pin'
|
15
|
+
require 'ducksboard/timeline'
|
16
|
+
require 'ducksboard/pull'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'json'
|
3
|
+
module Ducksboard
|
4
|
+
class Image < Widget
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
super
|
8
|
+
@data[:value] ||={}
|
9
|
+
end
|
10
|
+
|
11
|
+
def source
|
12
|
+
@data[:value][:source]
|
13
|
+
end
|
14
|
+
|
15
|
+
def source=(image_location)
|
16
|
+
source_value = if image_location =~ /^http/
|
17
|
+
image_location
|
18
|
+
else
|
19
|
+
'data:image/png;base64,' +
|
20
|
+
Base64.encode64(File.read(File.expand_path(image_location)))
|
21
|
+
end
|
22
|
+
@data[:value][:source] = source_value
|
23
|
+
end
|
24
|
+
|
25
|
+
def caption
|
26
|
+
@data[:value][:caption]
|
27
|
+
end
|
28
|
+
|
29
|
+
def caption=(text=nil)
|
30
|
+
@data[:value][:caption] = caption.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def timestamp
|
34
|
+
@data[:timestamp]
|
35
|
+
end
|
36
|
+
|
37
|
+
def timestamp=(time)
|
38
|
+
@data[:timestamp] = time
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Ducksboard
|
3
|
+
class Pull
|
4
|
+
include ::HTTParty
|
5
|
+
base_uri "https://pull.ducksboard.com/values" # https://pull.ducksboard.com/values/805/last
|
6
|
+
|
7
|
+
attr_accessor :id
|
8
|
+
|
9
|
+
def initialize(id)
|
10
|
+
@id = id
|
11
|
+
end
|
12
|
+
|
13
|
+
def last
|
14
|
+
auth = {:username => ::Ducksboard.api_key, :password => "ducksboard-gem"}
|
15
|
+
self.class.get("/#{id}/last",
|
16
|
+
:basic_auth => auth)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Ducksboard
|
2
|
+
class Timeline < Widget
|
3
|
+
|
4
|
+
ICONS = {
|
5
|
+
:orange => "https://app.ducksboard.com/static/img/timeline/orange.gif",
|
6
|
+
:red => "https://app.ducksboard.com/static/img/timeline/red.gif",
|
7
|
+
:green => "https://app.ducksboard.com/static/img/timeline/green.gif",
|
8
|
+
:created => "https://app.ducksboard.com/static/img/timeline/created.png",
|
9
|
+
:edited => "https://app.ducksboard.com/static/img/timeline/edited.png",
|
10
|
+
:deleted => "https://app.ducksboard.com/static/img/timeline/deleted.png"
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
@data[:value] ||={}
|
16
|
+
end
|
17
|
+
|
18
|
+
def title; @data[:title] end
|
19
|
+
def image; @data[:image] end
|
20
|
+
def content; @data[:image] end
|
21
|
+
def link; @data[:image] end
|
22
|
+
|
23
|
+
def title=(text)
|
24
|
+
@data[:value][:title] = text
|
25
|
+
end
|
26
|
+
|
27
|
+
def image=(url)
|
28
|
+
@data[:value][:image] = if url =~ /^http/
|
29
|
+
url
|
30
|
+
else
|
31
|
+
ICONS[url.to_sym]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def content=(text)
|
36
|
+
@data[:value][:content] = text
|
37
|
+
end
|
38
|
+
|
39
|
+
def link=(url)
|
40
|
+
@data[:value][:link] = url
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Ducksboard
|
3
|
+
class Widget
|
4
|
+
include ::HTTParty
|
5
|
+
base_uri "https://push.ducksboard.com/values"
|
6
|
+
|
7
|
+
attr_accessor :id, :data, :type
|
8
|
+
|
9
|
+
def initialize(id, data={})
|
10
|
+
@id = id
|
11
|
+
@data = data
|
12
|
+
end
|
13
|
+
|
14
|
+
def value
|
15
|
+
@data[:value]
|
16
|
+
end
|
17
|
+
|
18
|
+
def value=(val)
|
19
|
+
@data[:value] = val
|
20
|
+
end
|
21
|
+
|
22
|
+
def timestamp
|
23
|
+
@data[:timestamp]
|
24
|
+
end
|
25
|
+
|
26
|
+
def timestamp=(time)
|
27
|
+
@data[:timestamp] = time
|
28
|
+
end
|
29
|
+
|
30
|
+
def update(data=nil)
|
31
|
+
@data = data if data
|
32
|
+
auth = {:username => ::Ducksboard.api_key, :password => "ducksboard-gem"}
|
33
|
+
self.class.post('/' + id.to_s,
|
34
|
+
:basic_auth => auth,
|
35
|
+
:body => @data.to_json)
|
36
|
+
end
|
37
|
+
|
38
|
+
def save
|
39
|
+
if valid?
|
40
|
+
update.code.to_i == 200
|
41
|
+
else
|
42
|
+
raise "Invalid Data: #{@data.inspect}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid?
|
47
|
+
true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atk-ducksboard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joseph Hsu
|
9
|
+
- America's Test Kitchen
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-05-04 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.8'
|
23
|
+
- - ! '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.8.1
|
26
|
+
type: :runtime
|
27
|
+
prerelease: false
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.8.1
|
37
|
+
description: Ruby API wrapper for ducksboard realtime dashboard using HTTParty
|
38
|
+
email: jhsu.x1@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE
|
46
|
+
- README.mdown
|
47
|
+
- ducksboard.gemspec
|
48
|
+
- lib/ducksboard.rb
|
49
|
+
- lib/ducksboard/box.rb
|
50
|
+
- lib/ducksboard/counter.rb
|
51
|
+
- lib/ducksboard/gauge.rb
|
52
|
+
- lib/ducksboard/graph.rb
|
53
|
+
- lib/ducksboard/image.rb
|
54
|
+
- lib/ducksboard/pin.rb
|
55
|
+
- lib/ducksboard/pull.rb
|
56
|
+
- lib/ducksboard/timeline.rb
|
57
|
+
- lib/ducksboard/widget.rb
|
58
|
+
homepage: http://github.com/Americastestkitchen/ducksboard
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
post_install_message: ! " Quack! (in real-time)\"\n\n ===\n\n Don't forget to set
|
62
|
+
your ENV variable for DUCKSBOARD_API_KEY\n\n export DUCKSBOARD_API_KEY='YOURKEY'\n\n
|
63
|
+
\ or set it in your script\n\n Ducksboard.api_key = 'YOURKEY'\n"
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.8.7
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.22
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: API wrapper for ducksboard.com dashboard with pull support
|
85
|
+
test_files: []
|