Class: Canon::Config::DiffConfig

Inherits:
Object
  • Object
show all
Extended by:
ConfigDSL
Defined in:
lib/canon/config.rb

Overview

Diff configuration for output formatting

Each user-tunable attribute is declared with config_key via the ConfigDSL module. The DSL generates the matching getter/setter pair and registers metadata (type, enum, default) so EnvSchema and TypeConverter can discover it without re-declaring it (lutaml/canon TODO.improve/07 — single source of truth).

Constant Summary collapse

VALID_ENUM_VALUES =

Enum constraint map derived from declared config keys. Kept as a constant for backward compatibility with code that referenced DiffConfig::VALID_ENUM_VALUES directly. Must be assigned AFTER all config_key declarations above so the registry is populated.

enum_values.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigDSL

config_key, config_keys, enum_values, resolve_default, validate_config_value!

Constructor Details

#initialize(format = nil) ⇒ DiffConfig

Returns a new instance of DiffConfig.



311
312
313
314
315
# File 'lib/canon/config.rb', line 311

def initialize(format = nil)
  @format = format
  @resolver = build_resolver(format)
  @pretty_printer = PrettyPrinterConfig.new(@resolver)
end

Instance Attribute Details

#pretty_printerObject (readonly)

Returns the value of attribute pretty_printer.



309
310
311
# File 'lib/canon/config.rb', line 309

def pretty_printer
  @pretty_printer
end

Instance Method Details

#apply_profile_data(data) ⇒ Object



322
323
324
325
326
327
328
329
330
331
# File 'lib/canon/config.rb', line 322

def apply_profile_data(data)
  return unless data

  data.each do |key, value|
    sym_key = key.to_sym
    coerced = coerce_profile_value(sym_key, value)
    self.class.validate_config_value!(sym_key, coerced)
    @resolver.set_profile(sym_key, coerced)
  end
end

#clear_profile!Object



333
334
335
# File 'lib/canon/config.rb', line 333

def clear_profile!
  @resolver.clear_profile!
end

#reset!Object



317
318
319
320
# File 'lib/canon/config.rb', line 317

def reset!
  @resolver = build_resolver(@format)
  @pretty_printer = PrettyPrinterConfig.new(@resolver)
end

#to_hObject

Build diff options



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/canon/config.rb', line 437

def to_h
  {
    diff: mode,
    use_color: use_color,
    context_lines: context_lines,
    grouping_lines: grouping_lines,
    show_diffs: show_diffs,
    verbose_diff: verbose_diff,
    diff_algorithm: algorithm,
    parser: parser,
    show_raw_inputs: show_raw_inputs,
    show_raw_expected: show_raw_expected,
    show_raw_received: show_raw_received,
    show_preprocessed_inputs: show_preprocessed_inputs,
    show_preprocessed_expected: show_preprocessed_expected,
    show_preprocessed_received: show_preprocessed_received,
    show_prettyprint_inputs: show_prettyprint_inputs,
    show_prettyprint_expected: show_prettyprint_expected,
    show_prettyprint_received: show_prettyprint_received,
    show_line_numbered_inputs: show_line_numbered_inputs,
    character_visualization: character_visualization,
    display_format: display_format,
    display_preprocessing: display_preprocessing,
    pretty_printer_indent: pretty_printer.indent,
    pretty_printer_indent_type: pretty_printer.indent_type,
    preserve_whitespace_elements: preserve_whitespace_elements,
    collapse_whitespace_elements: collapse_whitespace_elements,
    strip_whitespace_elements: strip_whitespace_elements,
    pretty_printed_expected: pretty_printed_expected,
    pretty_printed_received: pretty_printed_received,
    compact_semantic_report: compact_semantic_report,
    expand_difference: expand_difference,
    max_file_size: max_file_size,
    max_node_count: max_node_count,
    max_diff_lines: max_diff_lines,
    theme: theme,
  }
end