Object
# File lib/bcat.rb, line 41 def assemble @format = @reader.sniff if @format.nil? @filter = @reader @filter = TeeFilter.new(@filter) if @config[:tee] @filter = TextFilter.new(@filter) if @format == 'text' @filter = ANSI.new(@filter) if @format == 'text' || @config[:ansi] end
# File lib/bcat.rb, line 36 def call(env) notice "#{env['REQUEST_METHOD']} #{env['PATH_INFO'].inspect}" [200, {"Content-Type" => "text/html;charset=utf-8"}, self] end
# File lib/bcat.rb, line 102 def close notice "closing with interrupt" raise Interrupt end
# File lib/bcat.rb, line 79 def content_for_head(inject='') [ "\n" * 1000, "<!DOCTYPE html>", "<html>", "<head>", "<!-- bcat was here -->", "<title>#{self[:title] || 'bcat'}</title>", inject.to_s, "</head>" ].join("\n") end
# File lib/bcat.rb, line 50 def each assemble head_parser = Bcat::HeadParser.new @filter.each do |buf| if head_parser.nil? yield buf elsif head_parser.feed(buf) yield content_for_head(inject=head_parser.head) yield head_parser.body head_parser = nil end end if head_parser yield content_for_head(inject=head_parser.head) + head_parser.body end yield foot rescue Errno::EINVAL # socket was closed notice "browser client went away" rescue => boom notice "boom: #{boom.class}: #{boom.to_s}" raise end
# File lib/bcat.rb, line 96 def escape_js(string) string = string.gsub(/['\\]/) { |char| "\\#{char}" } string.gsub!(/\n/, '\n') string end
# File lib/bcat.rb, line 107 def notice(message) return if !@config[:debug] warn "#{File.basename($0)}: #{message}" end
Generated with the Darkfish Rdoc Generator 2.