module OneshotCov

Constants

OneshotLog
VERSION

Public Instance Methods

configure(target_path: Rails.root, logger: nil, emit_term: nil) click to toggle source
# File lib/oneshot_cov.rb, line 26
def configure(target_path: Rails.root, logger: nil, emit_term: nil)
  if logger.nil?
    raise ArgumentError.new("Specifying logger in `OneshotCov.configure` is mandatory`")
  end

  target_path_by_pathname =
    if target_path.is_a? Pathname
      target_path
    else
      Pathname.new(target_path)
    end
  @reporter = OneshotCov::Reporter.new(
    target_path: target_path_by_pathname.cleanpath.to_s + "/",
    logger: logger,
    emit_term: emit_term,
  )
end
emit(force_emit: false) click to toggle source
# File lib/oneshot_cov.rb, line 22
def emit(force_emit: false)
  @reporter.emit(force_emit)
end
start() click to toggle source
# File lib/oneshot_cov.rb, line 13
def start
  Coverage.start(oneshot_lines: true)

  # To handle execution with exit immediatly
  at_exit do
    OneshotCov.emit(force_emit: true)
  end
end