class FuzzBert::Handler::FileOutput
Public Class Methods
new(dir=nil)
click to toggle source
# File lib/fuzzbert/error_handler.rb, line 21 def initialize(dir=nil) @dir = dir if @dir && !@dir.end_with?("/") @dir << "/" end end
Public Instance Methods
handle(error_data)
click to toggle source
# File lib/fuzzbert/error_handler.rb, line 28 def handle(error_data) id = error_data[:id] data = error_data[:data] status = error_data[:status] pid = error_data[:pid] crashed = status.termsig prefix = crashed ? "crash" : "bug" filename = "#{dir_prefix}#{prefix}#{pid}" while File.exists?(filename) filename << ('a'..'z').to_a.sample end File.open(filename, "wb") { |f| f.print(data) } puts "#{id} failed. Data was saved as #{filename}." info(error_data) end
Private Instance Methods
dir_prefix()
click to toggle source
# File lib/fuzzbert/error_handler.rb, line 49 def dir_prefix return "./" unless @dir @dir end