Sha256: c4e8414fefd621005969674c607bb39d90725233779a9662d6bd3dc02138cb1d
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) module Bastard LogRoot = nil end Clarity::GrepRenderer.module_eval do require 'bastard/renderers/mail_file_log_renderer' def renderer @renderer ||= MailFileLogRenderer.new end end Clarity::Server.module_eval do def sanitize_file_location(path) parts = path.split('/') file = parts.pop parts.map! { |part| part.gsub('.', '') } parts << file parts.join('/') end def process_http_request_with_fetch return process_http_request_without_fetch unless path == '/fetch' return respond_with(404, "<h1>Not Found</h1>") if params.empty? || (params['path'] || '').empty? log_files.each do |base| file = File.join(Bastard::LogRoot, base.split('/').first, sanitize_file_location(params['path'])) STDERR.puts "Checking file: #{file}\n" if File.exists?(file) STDERR.puts "Transmitting file: #{file}\n" return respond_with(200, File.read(file), :content_type => "text/plain") end end return respond_with(404, "<h1>Not Found</h1>") end alias :process_http_request_without_fetch :process_http_request alias :process_http_request :process_http_request_with_fetch end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bastard-0.0.4 | lib/bastard.rb |