Class: Hiptest::FileWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/hiptest-publisher/file_writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(reporter) ⇒ FileWriter

Returns a new instance of FileWriter.



5
6
7
# File 'lib/hiptest-publisher/file_writer.rb', line 5

def initialize(reporter)
  @reporter = reporter
end

Instance Method Details

#write_to_file(path, message) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hiptest-publisher/file_writer.rb', line 9

def write_to_file(path, message)
  @reporter.with_status_message "#{message}: #{path}" do
    mkdirs_for(path)
    content = yield

    File.open(path, 'w') do |file|
      file.write(content)
    end
  end
rescue => err
  @reporter.dump_error(err)
end