Class: SimpleCovMcp::OptionParsers::EnvOptionsParser
- Inherits:
-
Object
- Object
- SimpleCovMcp::OptionParsers::EnvOptionsParser
- Defined in:
- lib/simplecov_mcp/option_parsers/env_options_parser.rb
Constant Summary collapse
- ENV_VAR =
'SIMPLECOV_MCP_OPTS'
Instance Method Summary collapse
-
#initialize(env_var: ENV_VAR) ⇒ EnvOptionsParser
constructor
A new instance of EnvOptionsParser.
- #parse_env_opts ⇒ Object
- #pre_scan_error_mode(argv, error_mode_normalizer: method(:normalize_error_mode)) ⇒ Object
Constructor Details
#initialize(env_var: ENV_VAR) ⇒ EnvOptionsParser
Returns a new instance of EnvOptionsParser.
11 12 13 |
# File 'lib/simplecov_mcp/option_parsers/env_options_parser.rb', line 11 def initialize(env_var: ENV_VAR) @env_var = env_var end |
Instance Method Details
#parse_env_opts ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/simplecov_mcp/option_parsers/env_options_parser.rb', line 15 def parse_env_opts opts_string = ENV[@env_var] return [] unless opts_string && !opts_string.empty? begin Shellwords.split(opts_string) rescue ArgumentError => e raise SimpleCovMcp::ConfigurationError, "Invalid #{@env_var} format: #{e.}" end end |
#pre_scan_error_mode(argv, error_mode_normalizer: method(:normalize_error_mode)) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simplecov_mcp/option_parsers/env_options_parser.rb', line 26 def pre_scan_error_mode(argv, error_mode_normalizer: method(:normalize_error_mode)) # Quick scan for --error-mode to ensure early errors are logged correctly argv.each_with_index do |arg, i| if arg == '--error-mode' && argv[i + 1] return error_mode_normalizer.call(argv[i + 1]) elsif arg.start_with?('--error-mode=') value = arg.split('=', 2)[1] return nil if value.to_s.empty? return error_mode_normalizer.call(value) if value end end nil rescue # Ignore errors during pre-scan; they'll be caught during actual parsing nil end |