class RSpec::SummaryLog::BaseLogger

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/rspec/summary_log/base_logger.rb, line 13
def initialize(*args)
  super

  @output ||= args[1] || args[0] # rspec 1 has output as second argument

  if String === @output # a path ?
    FileUtils.mkdir_p(File.dirname(@output))
    File.open(@output, 'w'){} # overwrite previous results
    @output = File.open(@output, 'a')
  elsif File === @output # close and restart in append mode
    @output.close
    @output = File.open(@output.path, 'a')
  end
end

Public Instance Methods

close(*args) click to toggle source

stolen from Rspec

# File lib/rspec/summary_log/base_logger.rb, line 29
def close(*args)
  @output.close  if (IO === @output) & (@output != $stdout)
end

Protected Instance Methods

example_rerun_argument(example) click to toggle source

From Rspec v3.3 rerun_argument becomes to be deprecated

# File lib/rspec/summary_log/base_logger.rb, line 50
def example_rerun_argument(example)
  if example.respond_to?(:location_rerun_argument)
    example.location_rerun_argument
  elsif example.respond_to?(:rerun_argument)
    example.rerun_argument
  else
    example.location
  end
end
lock_output() { || ... } click to toggle source

do not let multiple processes get in each others way

# File lib/rspec/summary_log/base_logger.rb, line 36
def lock_output
  if File === @output
    begin
      @output.flock File::LOCK_EX
      yield
    ensure
      @output.flock File::LOCK_UN
    end
  else
    yield
  end
end