sinatra-geckoboard 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/README.md +46 -0
- data/lib/sinatra/geckoboard.rb +47 -0
- metadata +81 -0
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Sinatra Geckoboard
|
2
|
+
|
3
|
+
**Work in progress**
|
4
|
+
|
5
|
+
A little [Sinatra](http://www.sinatrarb.com/) extension to expose data nicely to [Geckoboard](http://www.geckoboard.com/).
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
Install with git. No gem available yet.
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require 'sinatra/base'
|
15
|
+
require 'sinatra/geckoboard'
|
16
|
+
|
17
|
+
class App < Sinatra::Base
|
18
|
+
register Sinatra::Geckoboard
|
19
|
+
|
20
|
+
get 'pie_graph' do
|
21
|
+
pie_chart [ { "label" => "Chuck Norris",
|
22
|
+
"value" => 3,
|
23
|
+
"colour" => "#ff9900" },
|
24
|
+
{ "label" => "Bruce Lee",
|
25
|
+
"value" => 0,
|
26
|
+
"colour" => "#ef9900" }
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
get 'line_chart' do
|
31
|
+
line_chart [1, 3], ["value1", "value2"], ["top1", "top2"], "#ff9900"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Licence
|
37
|
+
|
38
|
+
MIT License
|
39
|
+
|
40
|
+
Copyright (C) 2011 by af83
|
41
|
+
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
43
|
+
|
44
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
45
|
+
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Sinatra
|
2
|
+
module Geckoboard
|
3
|
+
|
4
|
+
module Helpers
|
5
|
+
# Render a line chart widget
|
6
|
+
# Set content type as json
|
7
|
+
# http://support.geckoboard.com/entries/274940-custom-chart-widget-type-definitions
|
8
|
+
#
|
9
|
+
# @param [Array] values
|
10
|
+
# @param [Array] axisx
|
11
|
+
# @param [Array] axisy
|
12
|
+
# @param [String] colour
|
13
|
+
# @return [String] the line chart as json string
|
14
|
+
def line_chart(values=[], axisx=[], axisy=[], colour="")
|
15
|
+
render_widget ({
|
16
|
+
"item" => values,
|
17
|
+
"settings" => {
|
18
|
+
"axisx" => axisx,
|
19
|
+
"axisy" => axisy,
|
20
|
+
"colour" => colour
|
21
|
+
}
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
# Render a pie chart widget
|
26
|
+
# Set content type as json
|
27
|
+
# http://support.geckoboard.com/entries/274940-custom-chart-widget-type-definitions
|
28
|
+
#
|
29
|
+
# @param [Array] values array of hash with: value, label and colour keys
|
30
|
+
def pie_chart(values=[])
|
31
|
+
render_widget({
|
32
|
+
"item" => values
|
33
|
+
})
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
def render_widget(widget)
|
38
|
+
content_type :json
|
39
|
+
widget.to_json
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.registered(app)
|
44
|
+
app.helpers Helpers
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-geckoboard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- François de Metz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-11 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sinatra
|
16
|
+
requirement: &7984960 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *7984960
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &7984560 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *7984560
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &7984100 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *7984100
|
47
|
+
description: A little Sinatra extension to expose data nicely to Geckoboard.
|
48
|
+
email: francois.de.metz@af83.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files:
|
52
|
+
- README.md
|
53
|
+
files:
|
54
|
+
- README.md
|
55
|
+
- Gemfile
|
56
|
+
- lib/sinatra/geckoboard.rb
|
57
|
+
homepage:
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.6
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: A little Sinatra extension to expose data nicely to Geckoboard.
|
81
|
+
test_files: []
|