Class: SimpleCov::Formatter::AIFormatter::Configuration

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/simplecov-ai/configuration.rb

Overview

Encapsulates all global tuning parameters that dictate the execution size, structure, and output verbosity of the AST-driven Markdown report generator. Each attribute is validated on assignment so misconfiguration fails immediately at the point of the invalid write rather than deep inside coverage processing at exit.

Constant Summary collapse

DEFAULT_REPORT_FILENAME =

File name of the report inside SimpleCov's coverage directory when no report_path is set

T.let('ai_report.md', String)
DEFAULT_REPORT_PATH =

Default output path of the report: DEFAULT_REPORT_FILENAME under SimpleCov's default coverage_dir (a custom coverage_dir is honoured at format time)

T.let("coverage/#{DEFAULT_REPORT_FILENAME}", String)
DEFAULT_MAX_FILE_SIZE_KB =

Default maximum size of the output file in kilobytes

T.let(50, Integer)
DEFAULT_MAX_SNIPPET_LINES =

Default maximum number of lines for a single snippet

T.let(5, Integer)
DEFAULT_OUTPUT_TO_CONSOLE =

Default flag for outputting to console

T.let(false, T::Boolean)
DEFAULT_GRANULARITY =

Default granularity level of the report

T.let(:fine, Symbol)
DEFAULT_INCLUDE_BYPASSES =

Default flag for including bypassed regions in the report

T.let(true, T::Boolean)
VALID_GRANULARITIES =

The set of granularity levels the report generator understands.

T.let(i[fine coarse].freeze, T::Array[Symbol])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



63
64
65
66
67
68
69
70
# File 'lib/simplecov-ai/configuration.rb', line 63

def initialize
  @report_path = T.let(nil, T.nilable(String))
  @max_file_size_kb = T.let(DEFAULT_MAX_FILE_SIZE_KB, Integer)
  @max_snippet_lines = T.let(DEFAULT_MAX_SNIPPET_LINES, Integer)
  @output_to_console = T.let(DEFAULT_OUTPUT_TO_CONSOLE, T::Boolean)
  @granularity = T.let(DEFAULT_GRANULARITY, Symbol)
  @include_bypasses = T.let(DEFAULT_INCLUDE_BYPASSES, T::Boolean)
end

Instance Attribute Details

#granularityObject

Returns the value of attribute granularity.



54
55
56
# File 'lib/simplecov-ai/configuration.rb', line 54

def granularity
  @granularity
end

#include_bypassesObject

Returns the value of attribute include_bypasses.



60
61
62
# File 'lib/simplecov-ai/configuration.rb', line 60

def include_bypasses
  @include_bypasses
end

#max_file_size_kbObject

Returns the value of attribute max_file_size_kb.



36
37
38
# File 'lib/simplecov-ai/configuration.rb', line 36

def max_file_size_kb
  @max_file_size_kb
end

#max_snippet_linesObject

Returns the value of attribute max_snippet_lines.



42
43
44
# File 'lib/simplecov-ai/configuration.rb', line 42

def max_snippet_lines
  @max_snippet_lines
end

#output_to_consoleObject

Returns the value of attribute output_to_console.



48
49
50
# File 'lib/simplecov-ai/configuration.rb', line 48

def output_to_console
  @output_to_console
end

Instance Method Details

#report_pathObject



78
79
80
# File 'lib/simplecov-ai/configuration.rb', line 78

def report_path
  @report_path || DEFAULT_REPORT_PATH
end

#report_path=(value) ⇒ Object

Raises:



96
97
98
99
100
101
# File 'lib/simplecov-ai/configuration.rb', line 96

def report_path=(value)
  raise ArgumentError, 'report_path must not contain a NUL byte' if value.include?("\0")
  raise ArgumentError, 'report_path must not be blank' if value.strip.empty?

  @report_path = value
end

#report_path_configured?Boolean

Returns:



85
86
87
# File 'lib/simplecov-ai/configuration.rb', line 85

def report_path_configured?
  !@report_path.nil?
end