Class: Canon::Config::EnvSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/canon/config/env_schema.rb

Overview

Schema definition for configuration attributes Defines attribute types and ENV variable mappings

Constant Summary collapse

ATTRIBUTE_TYPES =
{
  # DiffConfig attributes
  mode: :symbol,
  use_color: :boolean,
  context_lines: :integer,
  grouping_lines: :integer,
  show_diffs: :symbol,
  verbose_diff: :boolean,
  algorithm: :symbol,
  show_raw_inputs: :boolean,
  show_preprocessed_inputs: :boolean,
  show_line_numbered_inputs: :boolean,

  # MatchConfig attributes
  profile: :symbol,

  # FormatConfig attributes
  preprocessing: :string,

  # Size limits to prevent hangs on large files
  max_file_size: :integer,
  max_node_count: :integer,
  max_diff_lines: :integer,
}.freeze

Class Method Summary collapse

Class Method Details

.all_diff_attributesObject



46
47
48
49
50
# File 'lib/canon/config/env_schema.rb', line 46

def all_diff_attributes
  %i[mode use_color context_lines grouping_lines show_diffs
     verbose_diff algorithm show_raw_inputs show_preprocessed_inputs
     show_line_numbered_inputs max_file_size max_node_count max_diff_lines]
end

.all_format_attributesObject



56
57
58
# File 'lib/canon/config/env_schema.rb', line 56

def all_format_attributes
  %i[preprocessing]
end

.all_match_attributesObject



52
53
54
# File 'lib/canon/config/env_schema.rb', line 52

def all_match_attributes
  %i[profile]
end

.env_key(format, config_type, attribute) ⇒ Object



38
39
40
# File 'lib/canon/config/env_schema.rb', line 38

def env_key(format, config_type, attribute)
  "CANON_#{format.to_s.upcase}_#{config_type.to_s.upcase}_#{attribute.to_s.upcase}"
end

.global_env_key(attribute) ⇒ Object



42
43
44
# File 'lib/canon/config/env_schema.rb', line 42

def global_env_key(attribute)
  "CANON_#{attribute.to_s.upcase}"
end

.type_for(attribute) ⇒ Object



34
35
36
# File 'lib/canon/config/env_schema.rb', line 34

def type_for(attribute)
  ATTRIBUTE_TYPES[attribute.to_sym]
end