Class: CovLoupe::AppConfig
- Inherits:
-
Struct
- Object
- Struct
- CovLoupe::AppConfig
- Defined in:
- lib/cov_loupe/config/app_config.rb
Overview
Configuration container for application options.
Populated by ConfigParser from CLI arguments or constructed directly for MCP mode. Provides convenience methods (model_options, formatter_options) that extract the relevant subset of config for initializing CoverageModel and SourceFormatter.
Mutable by design: callers may adjust fields during setup before handing the config object off to CLI or MCP entry points.
All enum values are stored as symbols (:table, :json, :descending, etc.) for consistent comparison throughout the codebase.
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#error_mode ⇒ Object
Returns the value of attribute error_mode.
-
#format ⇒ Object
Returns the value of attribute format.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#output_chars ⇒ Object
Returns the value of attribute output_chars.
-
#raise_on_stale ⇒ Object
Returns the value of attribute raise_on_stale.
-
#resultset ⇒ Object
Returns the value of attribute resultset.
-
#root ⇒ Object
Returns the value of attribute root.
-
#sort_order ⇒ Object
Returns the value of attribute sort_order.
-
#source_context ⇒ Object
Returns the value of attribute source_context.
-
#source_mode ⇒ Object
Returns the value of attribute source_mode.
-
#tracked_globs ⇒ Object
Returns the value of attribute tracked_globs.
Class Method Summary collapse
-
.validate_log_file!(value) ⇒ Object
Shared validation for any log target value.
Instance Method Summary collapse
-
#formatter_options ⇒ Object
Convenience method for SourceFormatter initialization.
-
#initialize(root: '.', resultset: nil, format: :table, sort_order: :descending, source_mode: nil, source_context: 2, color: $stdout.tty?, error_mode: :log, raise_on_stale: false, tracked_globs: nil, log_file: nil, mode: :cli, output_chars: :default) ⇒ AppConfig
constructor
Set sensible defaults - ALL SYMBOLS FOR ENUMS.
-
#model_options ⇒ Object
Convenience method for CoverageModel initialization.
-
#validate! ⇒ Object
Validate configuration after all options have been merged.
Constructor Details
#initialize(root: '.', resultset: nil, format: :table, sort_order: :descending, source_mode: nil, source_context: 2, color: $stdout.tty?, error_mode: :log, raise_on_stale: false, tracked_globs: nil, log_file: nil, mode: :cli, output_chars: :default) ⇒ AppConfig
Set sensible defaults - ALL SYMBOLS FOR ENUMS
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cov_loupe/config/app_config.rb', line 33 def initialize( root: '.', resultset: nil, format: :table, sort_order: :descending, source_mode: nil, source_context: 2, color: $stdout.tty?, error_mode: :log, raise_on_stale: false, tracked_globs: nil, log_file: nil, mode: :cli, output_chars: :default ) # Default to empty array (show all files in resultset and don't look for files lacking coverage data) # Users should set COV_LOUPE_OPTS to match SimpleCov track_files patterns tracked_globs = [] if tracked_globs.nil? super end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def color @color end |
#error_mode ⇒ Object
Returns the value of attribute error_mode
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def error_mode @error_mode end |
#format ⇒ Object
Returns the value of attribute format
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def format @format end |
#log_file ⇒ Object
Returns the value of attribute log_file
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def log_file @log_file end |
#mode ⇒ Object
Returns the value of attribute mode
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def mode @mode end |
#output_chars ⇒ Object
Returns the value of attribute output_chars
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def output_chars @output_chars end |
#raise_on_stale ⇒ Object
Returns the value of attribute raise_on_stale
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def raise_on_stale @raise_on_stale end |
#resultset ⇒ Object
Returns the value of attribute resultset
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def resultset @resultset end |
#root ⇒ Object
Returns the value of attribute root
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def root @root end |
#sort_order ⇒ Object
Returns the value of attribute sort_order
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def sort_order @sort_order end |
#source_context ⇒ Object
Returns the value of attribute source_context
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def source_context @source_context end |
#source_mode ⇒ Object
Returns the value of attribute source_mode
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def source_mode @source_mode end |
#tracked_globs ⇒ Object
Returns the value of attribute tracked_globs
17 18 19 |
# File 'lib/cov_loupe/config/app_config.rb', line 17 def tracked_globs @tracked_globs end |
Class Method Details
.validate_log_file!(value) ⇒ Object
Shared validation for any log target value.
80 81 82 83 84 85 86 |
# File 'lib/cov_loupe/config/app_config.rb', line 80 def self.validate_log_file!(value) return unless value.to_s.strip.downcase == 'stdout' raise ConfigurationError, 'Logging to stdout is not permitted because it corrupts command output. ' \ "Use 'stderr', a file path, or ':off' to disable logging." end |
Instance Method Details
#formatter_options ⇒ Object
Convenience method for SourceFormatter initialization
65 66 67 68 69 70 |
# File 'lib/cov_loupe/config/app_config.rb', line 65 def { color_enabled: color, output_chars: output_chars, } end |
#model_options ⇒ Object
Convenience method for CoverageModel initialization
55 56 57 58 59 60 61 62 |
# File 'lib/cov_loupe/config/app_config.rb', line 55 def { root: root, resultset: resultset, raise_on_stale: raise_on_stale, tracked_globs: tracked_globs, } end |
#validate! ⇒ Object
Validate configuration after all options have been merged. Raises ConfigurationError for values that are unconditionally invalid.
74 75 76 77 |
# File 'lib/cov_loupe/config/app_config.rb', line 74 def validate! self.class.validate_log_file!(log_file) self end |