module OverseerHelper

Helper methods for the Overseer Sinatra server

Public Instance Methods

frontpage() click to toggle source
# File lib/robot_sweatshop/overseer.rb, line 15
def frontpage
  context = {
    jobs: job_list,
    logs: log_list,
    api_url: configatron.api_url
  }
  template = File.read "#{__dir__}/templates/index.html.eruby"
  eruby = Erubis::Eruby.new template
  eruby.result context
end
job_list() click to toggle source
# File lib/robot_sweatshop/overseer.rb, line 10
def job_list
  job_path = File.expand_path "#{configatron.job_path}"
  Dir.glob("#{job_path}/*.yaml").map { |path| File.basename path, '.yaml' }
end
log_list() click to toggle source
# File lib/robot_sweatshop/overseer.rb, line 5
def log_list
  log_path = File.expand_path "#{configatron.logfile_path}"
  Dir.glob("#{log_path}/*.log").map { |path| File.basename path, '.log' }
end
log_page_for(process) click to toggle source
# File lib/robot_sweatshop/overseer.rb, line 26
def log_page_for(process)
  context = {
    process: process,
    raw_log: File.read("#{configatron.logfile_path}/#{process}.log")
  }
  template = File.read "#{__dir__}/templates/log.html.eruby"
  eruby = Erubis::Eruby.new template
  eruby.result context
end