ducksboard 0.1.3 → 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/README.mdown +25 -5
- data/ducksboard.gemspec +1 -1
- data/lib/ducksboard.rb +1 -0
- data/lib/ducksboard/leaderboard.rb +20 -0
- data/lib/ducksboard/widget.rb +32 -2
- metadata +14 -5
data/.gitignore
CHANGED
data/README.mdown
CHANGED
@@ -12,13 +12,13 @@ or in an initializer
|
|
12
12
|
|
13
13
|
### Box
|
14
14
|
|
15
|
-
widget =
|
15
|
+
widget = Ducksboard::Box.new(1234) # Widget numeric id
|
16
16
|
widget.value = 10
|
17
17
|
widget.save
|
18
18
|
|
19
19
|
### Counter
|
20
20
|
|
21
|
-
widget =
|
21
|
+
widget = Ducksboard::Counter.new(1234)
|
22
22
|
widget.value = 10
|
23
23
|
widget.save
|
24
24
|
|
@@ -34,7 +34,7 @@ or in an initializer
|
|
34
34
|
|
35
35
|
### Gauge
|
36
36
|
|
37
|
-
widget =
|
37
|
+
widget = Ducksboard::Gauge.new(1235)
|
38
38
|
widget.value = 0.93
|
39
39
|
widget.save
|
40
40
|
|
@@ -48,13 +48,13 @@ or in an initializer
|
|
48
48
|
|
49
49
|
### Pin
|
50
50
|
|
51
|
-
widget =
|
51
|
+
widget = Ducksboard::Pin.new(1234)
|
52
52
|
widget.value = 10
|
53
53
|
widget.save
|
54
54
|
|
55
55
|
### Timeline
|
56
56
|
|
57
|
-
widget =
|
57
|
+
widget = Ducksboard::Timeline.new(1237)
|
58
58
|
widget.title = "A Title"
|
59
59
|
widget.image = "http://url.to.io/some_image.gif"
|
60
60
|
# or
|
@@ -62,3 +62,23 @@ or in an initializer
|
|
62
62
|
# any of the following as a string or symbol: orange, red, green, created, edited or deleted
|
63
63
|
widget.content = "text content"
|
64
64
|
widget.link = "http://google.com"
|
65
|
+
|
66
|
+
### Leaderboard
|
67
|
+
|
68
|
+
widget1 = Ducksboard::Leaderboard.new(56803)
|
69
|
+
widget1.linha = [{"name" => 'Titulo 1', "values" => [12,13,14]},
|
70
|
+
{"name" => 'Titulo 2', "values" => [12,13,142]},
|
71
|
+
]
|
72
|
+
widget1.save
|
73
|
+
|
74
|
+
### Pull API
|
75
|
+
|
76
|
+
# You can use the HTTP Pull API to retrieve historical data from any widget.
|
77
|
+
# It will be returned in a map as per the API (http://dev.ducksboard.com/apidoc/pull-api-http)
|
78
|
+
|
79
|
+
widget = Ducksboard::Gauge.new(1235)
|
80
|
+
data = widget.since(300)['data']
|
81
|
+
# or
|
82
|
+
data = widget.last_values(15)
|
83
|
+
# or
|
84
|
+
data = widget.timespan(:daily, "Europe/London")
|
data/ducksboard.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'ducksboard'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.4'
|
4
4
|
s.summary = "API wrapper for ducksboard.com dashboard"
|
5
5
|
s.description = "Ruby API wrapper for ducksboard realtime dashboard using HTTParty"
|
6
6
|
s.authors = ["Joseph Hsu"]
|
data/lib/ducksboard.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'json'
|
3
|
+
module Ducksboard
|
4
|
+
class Leaderboard < Widget
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
super
|
8
|
+
@data[:value] ||={}
|
9
|
+
end
|
10
|
+
|
11
|
+
def linha
|
12
|
+
@data[:value][:board]
|
13
|
+
end
|
14
|
+
|
15
|
+
def linha=(linhaa)
|
16
|
+
@data[:value][:board] = linhaa
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/ducksboard/widget.rb
CHANGED
@@ -2,7 +2,6 @@ require 'json'
|
|
2
2
|
module Ducksboard
|
3
3
|
class Widget
|
4
4
|
include ::HTTParty
|
5
|
-
base_uri "https://push.ducksboard.com/values"
|
6
5
|
|
7
6
|
attr_accessor :id, :data, :type
|
8
7
|
|
@@ -29,7 +28,6 @@ module Ducksboard
|
|
29
28
|
|
30
29
|
def update(data=nil)
|
31
30
|
@data = data if data
|
32
|
-
auth = {:username => ::Ducksboard.api_key, :password => "ducksboard-gem"}
|
33
31
|
self.class.post('/' + id.to_s,
|
34
32
|
:basic_auth => auth,
|
35
33
|
:body => @data.to_json)
|
@@ -46,5 +44,37 @@ module Ducksboard
|
|
46
44
|
def valid?
|
47
45
|
true
|
48
46
|
end
|
47
|
+
|
48
|
+
def last_values(number_of_values=3)
|
49
|
+
pull("last?count=#{number_of_values}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def since(seconds_ago=3600)
|
53
|
+
pull("since?seconds=#{seconds_ago.to_i}")
|
54
|
+
end
|
55
|
+
|
56
|
+
def timespan(timespan=:monthly, timezone="UTC")
|
57
|
+
pull("timespan?timespan=#{timespan.to_s}&timezone=#{timezone}")
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
PUSH_URI = "https://push.ducksboard.com/values"
|
63
|
+
PULL_URI = "https://pull.ducksboard.com/values"
|
64
|
+
|
65
|
+
def auth()
|
66
|
+
{:username => ::Ducksboard.api_key, :password => "ducksboard-gem"}
|
67
|
+
end
|
68
|
+
|
69
|
+
def pull(service_uri)
|
70
|
+
response = self.class.get("#{PULL_URI}/#{@id.to_s}/#{service_uri}",
|
71
|
+
:basic_auth => auth)
|
72
|
+
|
73
|
+
if response.code.to_i == 200
|
74
|
+
JSON.parse(response.body)
|
75
|
+
else
|
76
|
+
raise "Unexpected response code: #{response.code}; body: #{response.body}"
|
77
|
+
end
|
78
|
+
end
|
49
79
|
end
|
50
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ducksboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -24,7 +24,15 @@ dependencies:
|
|
24
24
|
version: 0.8.1
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.8'
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.8.1
|
28
36
|
description: Ruby API wrapper for ducksboard realtime dashboard using HTTParty
|
29
37
|
email: jhsu.x1@gmail.com
|
30
38
|
executables: []
|
@@ -42,6 +50,7 @@ files:
|
|
42
50
|
- lib/ducksboard/gauge.rb
|
43
51
|
- lib/ducksboard/graph.rb
|
44
52
|
- lib/ducksboard/image.rb
|
53
|
+
- lib/ducksboard/leaderboard.rb
|
45
54
|
- lib/ducksboard/pin.rb
|
46
55
|
- lib/ducksboard/timeline.rb
|
47
56
|
- lib/ducksboard/widget.rb
|
@@ -68,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
77
|
version: '0'
|
69
78
|
requirements: []
|
70
79
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.8.
|
80
|
+
rubygems_version: 1.8.24
|
72
81
|
signing_key:
|
73
82
|
specification_version: 3
|
74
83
|
summary: API wrapper for ducksboard.com dashboard
|