Top Level Namespace
Defined Under Namespace
Modules: Dashing
Constant Summary collapse
- SCHEDULER =
Rufus::Scheduler.new
Instance Method Summary collapse
- #development? ⇒ Boolean
- #first_dashboard ⇒ Object
- #format_event(body, name = nil) ⇒ Object
- #latest_events ⇒ Object
- #production? ⇒ Boolean
- #require_glob(relative_glob) ⇒ Object
- #send_event(id, body, target = nil) ⇒ Object
- #tilt_html_engines ⇒ Object
Instance Method Details
#development? ⇒ Boolean
13 14 15 |
# File 'lib/dashing/app.rb', line 13 def development? ENV['RACK_ENV'] == 'development' end |
#first_dashboard ⇒ Object
156 157 158 159 160 |
# File 'lib/dashing/app.rb', line 156 def first_dashboard files = Dir[File.join(settings.views, '*')].collect { |f| File.basename(f, '.*') } files -= ['layout'] files.sort.first end |
#format_event(body, name = nil) ⇒ Object
144 145 146 147 148 |
# File 'lib/dashing/app.rb', line 144 def format_event(body, name=nil) str = "" str << "event: #{name}\n" if name str << "data: #{body}\n\n" end |
#latest_events ⇒ Object
150 151 152 153 154 |
# File 'lib/dashing/app.rb', line 150 def latest_events settings.history.inject("") do |str, (id, body)| str << body end end |
#production? ⇒ Boolean
17 18 19 |
# File 'lib/dashing/app.rb', line 17 def production? ENV['RACK_ENV'] == 'production' end |
#require_glob(relative_glob) ⇒ Object
169 170 171 172 173 |
# File 'lib/dashing/app.rb', line 169 def require_glob(relative_glob) Dir[File.join(settings.root, relative_glob)].each do |file| require file end end |
#send_event(id, body, target = nil) ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/dashing/app.rb', line 136 def send_event(id, body, target=nil) body[:id] = id body[:updatedAt] ||= Time.now.to_i event = format_event(body.to_json, target) Sinatra::Application.settings.history[id] = event unless target == 'dashboards' Sinatra::Application.settings.connections.each { |out| out << event } end |
#tilt_html_engines ⇒ Object
162 163 164 165 166 167 |
# File 'lib/dashing/app.rb', line 162 def tilt_html_engines Tilt.mappings.select do |_, engines| default_mime_type = engines.first.default_mime_type default_mime_type.nil? || default_mime_type == 'text/html' end end |