Class: OneshotCov::Logger::ReplaceLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/oneshot_cov/logger/replace_logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_path) ⇒ ReplaceLogger

Returns a new instance of ReplaceLogger.



6
7
8
# File 'lib/oneshot_cov/logger/replace_logger.rb', line 6

def initialize(log_path)
  @log_path = log_path
end

Instance Method Details

#post(new_logs) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/oneshot_cov/logger/replace_logger.rb', line 10

def post(new_logs)
  current_coverage = fetch

  new_logs.each do |new_log|
    key = "#{new_log.path}"

    logged_lines = current_coverage.fetch(key, [])
    current_coverage[key] = logged_lines | new_log.lines
  end
  save(current_coverage)
end