class MissCleo::TestsToFilesMapLogger

Attributes

file_name[R]
logs[RW]

Public Class Methods

new(file_name) click to toggle source
# File lib/miss_cleo/tests_to_files_map_logger.rb, line 4
def initialize(file_name)
  @logs = []
  @file_name = file_name
end

Public Instance Methods

add_to_log(test_file_and_line, lines_run_before, lines_run_after, templates) click to toggle source
# File lib/miss_cleo/tests_to_files_map_logger.rb, line 9
def add_to_log(test_file_and_line, lines_run_before, lines_run_after, templates)
  logs << [ test_file_and_line, {
    before: filter(lines_run_before),
    after: filter(lines_run_after),
    templates: templates
  }]
end
export_logs() click to toggle source
# File lib/miss_cleo/tests_to_files_map_logger.rb, line 17
def export_logs
  if File.exists?(file_name)
    file = JSON.parse(File.read(file_name))
    @logs += file
  end
  File.open(file_name, 'w') { |f| f.write JSON.dump @logs }
end

Private Instance Methods

filter(lines_run) click to toggle source
# File lib/miss_cleo/tests_to_files_map_logger.rb, line 30
def filter(lines_run)
  MissCleo::CoverageFilter.filter_and_trim(lines_run)
end