module DangerUndercover::CLI

module for undercover-report

Public Class Methods

run(args = nil) click to toggle source

Runs the undercover command with provided arguments and writes the output to a file @return [String]

# File lib/undercover/cli.rb, line 13
def run(args = nil)
  undercover_output = `undercover #{args&.join(' ')}`

  File.write(output_file, undercover_output)

  undercover_output
end

Private Class Methods

create_directory!() click to toggle source

Creates directory if doesn’t exists @return [String]

# File lib/undercover/cli.rb, line 35
def create_directory!
  return if Dir.exist?(output_directory)

  FileUtils.mkdir_p(output_directory)
end
output_directory() click to toggle source

Output directory @return [String]

# File lib/undercover/cli.rb, line 44
def output_directory
  File.join(Dir.getwd, 'coverage')
end
output_file() click to toggle source

Returns the file to write report to @return [String]

# File lib/undercover/cli.rb, line 26
def output_file
  create_directory!

  File.join(output_directory, 'undercover.txt')
end