Class: Puppetfactory::Plugins::Logs

Inherits:
Puppetfactory::Plugins show all
Defined in:
lib/puppetfactory/plugins/logs.rb

Instance Attribute Summary

Attributes inherited from Puppetfactory::Plugins

#weight

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Logs

Returns a new instance of Logs.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppetfactory/plugins/logs.rb', line 5

def initialize(options)
  super(options)
  return unless options[:puppetfactory]

  @logfile = options[:logfile]
  server   = options[:puppetfactory]

  # Add a web route to the puppetfactory server. Must happen in the initializer
  server.get '/logs' do
    protected!
    erb :logs
  end

  server.get '/logs/data' do
    protected!
    plugin(:Logs, :data)
  end
end

Instance Method Details

#dataObject



31
32
33
# File 'lib/puppetfactory/plugins/logs.rb', line 31

def data
  File.read(@logfile) rescue "Cannot read logfile #{@logfile}"
end

#tabs(privileged = false) ⇒ Object



24
25
26
27
28
29
# File 'lib/puppetfactory/plugins/logs.rb', line 24

def tabs(privileged = false)
  return unless privileged # only show this tab to admin users

  # url path => display title
  { 'logs' => 'Logs' }
end