Class: ParallelTests::RSpec::LoggerBase
- Inherits:
-
LoggerBaseBase
- Object
- ParallelTests::RSpec::LoggerBase
- Defined in:
- lib/sim/logger_base.rb
Direct Known Subclasses
Constant Summary collapse
- RSPEC_1 =
do not test for Spec, this will trigger deprecation warning in rspec 2
!defined?(RSpec::Core::Formatters::BaseTextFormatter) # do not test for Spec, this will trigger deprecation warning in rspec 2
Instance Method Summary collapse
-
#close ⇒ Object
stolen from Rspec.
-
#initialize(*args) ⇒ LoggerBase
constructor
A new instance of LoggerBase.
-
#lock_output ⇒ Object
do not let multiple processes get in each others way.
- #lock_output_begin ⇒ Object
- #lock_output_end ⇒ Object
Constructor Details
#initialize(*args) ⇒ LoggerBase
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sim/logger_base.rb', line 19 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 ⇒ Object
stolen from Rspec
35 36 37 |
# File 'lib/sim/logger_base.rb', line 35 def close @output.close if (IO === @output) & (@output != $stdout) end |
#lock_output ⇒ Object
do not let multiple processes get in each others way
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sim/logger_base.rb', line 40 def lock_output if File === @output begin @output.flock File::LOCK_EX yield ensure @output.flock File::LOCK_UN end else yield end end |
#lock_output_begin ⇒ Object
53 54 55 56 57 |
# File 'lib/sim/logger_base.rb', line 53 def lock_output_begin if File === @output @output.flock File::LOCK_EX end end |
#lock_output_end ⇒ Object
59 60 61 62 63 |
# File 'lib/sim/logger_base.rb', line 59 def lock_output_end if File === @output @output.flock File::LOCK_UN end end |