Class: Simmer::Suite::PdiOutputWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/simmer/suite/pdi_output_writer.rb

Overview

Captures PDI output from multiple specifications to a single file.

Constant Summary collapse

PDI_OUT_FILE =

:nodoc:

'pdi_out.txt'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results_dir) ⇒ PdiOutputWriter

Returns a new instance of PdiOutputWriter.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
# File 'lib/simmer/suite/pdi_output_writer.rb', line 18

def initialize(results_dir)
  raise ArgumentError, 'results_dir is required' unless results_dir

  results_dir = Util::FileSystem.setup_directory(results_dir)
  @out = File.new(File.join(results_dir, PDI_OUT_FILE), 'w')

  freeze
end

Instance Attribute Details

#results_dirObject (readonly)

Returns the value of attribute results_dir.



16
17
18
# File 'lib/simmer/suite/pdi_output_writer.rb', line 16

def results_dir
  @results_dir
end

Instance Method Details

#closeObject



44
45
46
# File 'lib/simmer/suite/pdi_output_writer.rb', line 44

def close
  out.close
end

#demarcate_spec(runner_id, spec_name) ⇒ Object



27
28
29
30
31
32
# File 'lib/simmer/suite/pdi_output_writer.rb', line 27

def demarcate_spec(runner_id, spec_name)
  out.puts(LINE_OF_HYPHENS)
  out.puts("Name: #{spec_name}")
  out.puts("Runner ID: #{runner_id}")
  out.puts(LINE_OF_HYPHENS)
end

#finish_specObject



40
41
42
# File 'lib/simmer/suite/pdi_output_writer.rb', line 40

def finish_spec
  out.puts
end

#write(contents) ⇒ Object



34
35
36
37
38
# File 'lib/simmer/suite/pdi_output_writer.rb', line 34

def write(contents)
  bytes_written = out.write(contents)
  out.flush
  bytes_written
end