Module: SimpleCovMcp::OptionNormalizers
- Defined in:
- lib/simplecov_mcp/option_normalizers.rb
Overview
Shared normalization logic for CLI options. Provides both strict (raise on invalid) and lenient (default on invalid) modes.
Constant Summary collapse
- SORT_ORDER_MAP =
{ 'a' => :ascending, 'ascending' => :ascending, 'd' => :descending, 'descending' => :descending }.freeze
- SOURCE_MODE_MAP =
{ 'f' => :full, 'full' => :full, 'u' => :uncovered, 'uncovered' => :uncovered }.freeze
- STALENESS_MAP =
{ 'o' => :off, 'off' => :off, 'e' => :error, 'error' => :error }.freeze
- ERROR_MODE_MAP =
{ 'off' => :off, 'o' => :off, 'log' => :log, 'l' => :log, 'debug' => :debug, 'd' => :debug }.freeze
- FORMAT_MAP =
{ 't' => :table, 'table' => :table, 'j' => :json, 'json' => :json, 'J' => :pretty_json, 'pretty_json' => :pretty_json, 'pretty-json' => :pretty_json, 'y' => :yaml, 'yaml' => :yaml, 'a' => :awesome_print, 'awesome_print' => :awesome_print, 'ap' => :awesome_print }.freeze
Class Method Summary collapse
-
.normalize_error_mode(value, strict: true, default: :log) ⇒ Symbol
Normalize error mode value.
-
.normalize_format(value, strict: true) ⇒ Symbol?
Normalize format value.
- .normalize_sort_order(value, strict: true) ⇒ Object
-
.normalize_source_mode(value, strict: true) ⇒ Symbol?
Normalize source mode value.
-
.normalize_staleness(value, strict: true) ⇒ Symbol?
Normalize stale mode value.
Class Method Details
.normalize_error_mode(value, strict: true, default: :log) ⇒ Symbol
Normalize error mode value.
92 93 94 95 96 97 98 |
# File 'lib/simplecov_mcp/option_normalizers.rb', line 92 module_function def normalize_error_mode(value, strict: true, default: :log) normalized = ERROR_MODE_MAP[value.to_s.downcase] return normalized if normalized raise OptionParser::InvalidArgument, "invalid argument: #{value}" if strict default end |
.normalize_format(value, strict: true) ⇒ Symbol?
Normalize format value.
105 106 107 108 109 110 111 |
# File 'lib/simplecov_mcp/option_normalizers.rb', line 105 module_function def normalize_format(value, strict: true) normalized = FORMAT_MAP[value.to_s.downcase] return normalized if normalized raise OptionParser::InvalidArgument, "invalid argument: #{value}" if strict nil end |
.normalize_sort_order(value, strict: true) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/simplecov_mcp/option_normalizers.rb', line 52 module_function def normalize_sort_order(value, strict: true) normalized = SORT_ORDER_MAP[value.to_s.downcase] return normalized if normalized raise OptionParser::InvalidArgument, "invalid argument: #{value}" if strict nil end |
.normalize_source_mode(value, strict: true) ⇒ Symbol?
Normalize source mode value.
65 66 67 68 69 70 71 |
# File 'lib/simplecov_mcp/option_normalizers.rb', line 65 module_function def normalize_source_mode(value, strict: true) normalized = SOURCE_MODE_MAP[value.to_s.downcase] return normalized if normalized raise OptionParser::InvalidArgument, "invalid argument: #{value}" if strict nil end |
.normalize_staleness(value, strict: true) ⇒ Symbol?
Normalize stale mode value.
78 79 80 81 82 83 84 |
# File 'lib/simplecov_mcp/option_normalizers.rb', line 78 module_function def normalize_staleness(value, strict: true) normalized = STALENESS_MAP[value.to_s.downcase] return normalized if normalized raise OptionParser::InvalidArgument, "invalid argument: #{value}" if strict nil end |