Class: GDash
- Inherits:
-
Object
- Object
- GDash
- Defined in:
- lib/gdash.rb,
lib/gdash/dashboard.rb,
lib/gdash/sinatra_app.rb
Defined Under Namespace
Classes: Dashboard, SinatraApp
Instance Attribute Summary collapse
-
#dash_templates ⇒ Object
readonly
Returns the value of attribute dash_templates.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#graphite_base ⇒ Object
readonly
Returns the value of attribute graphite_base.
-
#graphite_render ⇒ Object
readonly
Returns the value of attribute graphite_render.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#until ⇒ Object
readonly
Returns the value of attribute until.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #dashboard(name, options = {}) ⇒ Object
- #dashboards ⇒ Object
-
#initialize(graphite_base, render_url, dash_templates, options = {}) ⇒ GDash
constructor
A new instance of GDash.
- #list ⇒ Object
Constructor Details
#initialize(graphite_base, render_url, dash_templates, options = {}) ⇒ GDash
Returns a new instance of GDash.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gdash.rb', line 15 def initialize(graphite_base, render_url, dash_templates, ={}) @graphite_base = graphite_base @graphite_render = [@graphite_base, "/render/"].join @dash_templates = dash_templates @height = .delete(:height) @width = .delete(:width) @from = .delete(:from) @until = .delete(:until) raise "Dashboard templates directory #{@dash_templates} does not exist" unless File.directory?(@dash_templates) end |
Instance Attribute Details
#dash_templates ⇒ Object (readonly)
Returns the value of attribute dash_templates.
13 14 15 |
# File 'lib/gdash.rb', line 13 def dash_templates @dash_templates end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
13 14 15 |
# File 'lib/gdash.rb', line 13 def from @from end |
#graphite_base ⇒ Object (readonly)
Returns the value of attribute graphite_base.
13 14 15 |
# File 'lib/gdash.rb', line 13 def graphite_base @graphite_base end |
#graphite_render ⇒ Object (readonly)
Returns the value of attribute graphite_render.
13 14 15 |
# File 'lib/gdash.rb', line 13 def graphite_render @graphite_render end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
13 14 15 |
# File 'lib/gdash.rb', line 13 def height @height end |
#until ⇒ Object (readonly)
Returns the value of attribute until.
13 14 15 |
# File 'lib/gdash.rb', line 13 def until @until end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
13 14 15 |
# File 'lib/gdash.rb', line 13 def width @width end |
Instance Method Details
#dashboard(name, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/gdash.rb', line 27 def dashboard(name, ={}) [:width] ||= @width [:height] ||= @height [:from] ||= @from [:until] ||= @until Dashboard.new(name, dash_templates, ) end |
#dashboards ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gdash.rb', line 40 def dashboards dashboards = [] Dir.entries(dash_templates).each do |dash| begin yaml_file = File.join(dash_templates, dash, "dash.yaml") if File.exist?(yaml_file) dashboards << YAML.load_file(yaml_file).merge({:link => dash}) end rescue Exception => e p e end end dashboards.sort_by{|d| d[:name].to_s} end |
#list ⇒ Object
36 37 38 |
# File 'lib/gdash.rb', line 36 def list dashboards.map {|dash| dash[:link]} end |