Class: Simmer::Suite::ResulstWriter

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

Overview

Understands how to write a SessionResult instance to disk.

Constant Summary collapse

DATA_FILE =
'data.yaml'

Instance Method Summary collapse

Constructor Details

#initialize(session_result, results_dir) ⇒ ResulstWriter

Pass in dir here:

Raises:

  • (ArgumentError)


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

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

  @session_result = session_result
  @results_directory = Util::FileSystem.setup_directory(results_dir)

  freeze
end

Instance Method Details

#write!Object



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

def write!
  dir = Util::FileSystem.setup_directory(results_directory)

  IO.write(data_path(dir), session_result.to_h.to_yaml)

  self
end