Module: OneshotCov

Defined in:
lib/oneshot_cov.rb,
lib/oneshot_cov/railtie.rb,
lib/oneshot_cov/version.rb,
lib/oneshot_cov/reporter.rb,
lib/oneshot_cov/middleware.rb,
lib/oneshot_cov/logger/replace_logger.rb,
lib/oneshot_cov/logger/each_file_logger.rb,
lib/oneshot_cov/logger/line_by_line_logger.rb

Defined Under Namespace

Modules: Logger Classes: Middleware, OneshotLog, Railtie, Reporter

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.configure(target_path: Rails.root, logger: nil, emit_term: nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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) ⇒ Object



22
23
24
# File 'lib/oneshot_cov.rb', line 22

def emit(force_emit: false)
  @reporter.emit(force_emit)
end

.startObject



13
14
15
16
17
18
19
20
# 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