class Perforat::Listener

Public Instance Methods

example_failed(notification)
Alias for: example_finished
example_finished(notification) click to toggle source
# File lib/perforat/listener.rb, line 16
def example_finished(notification)
  @output << [
    notification.example.full_description,
    notification.example.execution_result.run_time
  ]
end
Also aliased as: example_passed, example_failed
example_passed(notification)
Alias for: example_finished
start(_) click to toggle source
# File lib/perforat/listener.rb, line 9
def start(_)
  current_time = Time.now.to_i
  FileUtils.mkdir_p(PERFORAT_DIR)
  @output = CSV.open("#{PERFORAT_DIR}/#{current_time}.csv", 'w')
  @output << [current_time]
end
stop(_) click to toggle source
# File lib/perforat/listener.rb, line 23
def stop(_)
  @output.close
  puts
  files = Dir["#{PERFORAT_DIR}/*.csv"].sort_by(&File.method(:mtime))
  remove_old_files(files)
  contents = files.last(2).map { |file| CSV.read(file) }
  ResultsProcessor.new(contents: contents).call
end

Private Instance Methods

remove_old_files(files) click to toggle source
# File lib/perforat/listener.rb, line 37
def remove_old_files(files)
  keep_files = Perforat.settings.fetch(:keep_files)
  (files - files.last(keep_files)).each(&File.method(:delete))
end