Class: RSpec::SummaryLog::BaseLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/summary_log/base_logger.rb

Direct Known Subclasses

FailedLogger, SummaryLogger

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ BaseLogger

Returns a new instance of BaseLogger.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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

Instance Method Details

#close(*args) ⇒ Object

stolen from Rspec



29
30
31
# File 'lib/rspec/summary_log/base_logger.rb', line 29

def close(*args)
  @output.close  if (IO === @output) & (@output != $stdout)
end