Sha256: f329b10a18bbe7a1cf7c7d92ae326acca098ee750cf61265478a925e892bf030
Contents?: true
Size: 931 Bytes
Versions: 1
Compression:
Stored size: 931 Bytes
Contents
module LogsViewer class Display def initialize(app) @app = app @lines = LogsViewer::Config.number_lines @log_dir = LogsViewer::Config.log_dir end def call(env = {}) if env["PATH_INFO"]=~/^\/logs/ @data = { list: LogsViewer::Handler.list(@log_dir), lines: [] } if(env["QUERY_STRING"]=~/file/ ) log_name = env["QUERY_STRING"].clone log_name = log_name.gsub(/file=/, '') @data[:lines] = `tail -n "#{@lines}" "#{log_name}"` [200,{"Content-Type"=>"text/html"},[view_generate(@data)]] else [200,{"Content-Type"=>"text/html"},[view_generate(@data)]] end else @app.call(env) end end def view_generate(data) temp = LogsViewer::Handler.file_open("../views/display.html.erb") temp = ERB.new(temp) return temp.result(binding) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logs_viewer-0.1.0 | lib/logs_viewer/display.rb |