Class: Canon::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/canon/config.rb,
lib/canon/config/env_schema.rb,
lib/canon/config/env_provider.rb,
lib/canon/config/type_converter.rb,
lib/canon/config/override_resolver.rb

Overview

Global configuration for Canon Provides unified configuration across CLI, Ruby API, and RSpec interfaces

Defined Under Namespace

Classes: DiffConfig, EnvProvider, EnvSchema, FormatConfig, MatchConfig, OverrideResolver, TypeConverter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



40
41
42
43
44
45
46
# File 'lib/canon/config.rb', line 40

def initialize
  @xml = FormatConfig.new(:xml)
  @html = FormatConfig.new(:html)
  @json = FormatConfig.new(:json)
  @yaml = FormatConfig.new(:yaml)
  @string = FormatConfig.new(:string)
end

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



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

def html
  @html
end

#jsonObject (readonly)

Returns the value of attribute json.



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

def json
  @json
end

#stringObject (readonly)

Returns the value of attribute string.



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

def string
  @string
end

#xmlObject (readonly)

Returns the value of attribute xml.



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

def xml
  @xml
end

#yamlObject (readonly)

Returns the value of attribute yaml.



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

def yaml
  @yaml
end

Class Method Details

.configure {|instance| ... } ⇒ Object

Yields:



15
16
17
18
# File 'lib/canon/config.rb', line 15

def configure
  yield instance if block_given?
  instance
end

.instanceObject



11
12
13
# File 'lib/canon/config.rb', line 11

def instance
  @instance ||= new
end

.method_missing(method) ⇒ Object

Delegate to instance



25
26
27
28
29
30
31
# File 'lib/canon/config.rb', line 25

def method_missing(method, ...)
  if @instance.respond_to?(method)
    @instance.send(method, ...)
  else
    super
  end
end

.reset!Object



20
21
22
# File 'lib/canon/config.rb', line 20

def reset!
  @instance = new
end

.respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to_missing?(method, include_private = false)
  @instance.respond_to?(method) || super
end

Instance Method Details

#diff_modeObject

Backward compatibility methods for top-level diff configuration These delegate to XML diff config for backward compatibility



58
59
60
# File 'lib/canon/config.rb', line 58

def diff_mode
  @xml.diff.mode
end

#diff_mode=(value) ⇒ Object



62
63
64
# File 'lib/canon/config.rb', line 62

def diff_mode=(value)
  @xml.diff.mode = value
end

#html_match_profileObject



83
84
85
# File 'lib/canon/config.rb', line 83

def html_match_profile
  @html.match.profile
end

#html_match_profile=(value) ⇒ Object



87
88
89
# File 'lib/canon/config.rb', line 87

def html_match_profile=(value)
  @html.match.profile = value
end

#reset!Object



48
49
50
51
52
53
54
# File 'lib/canon/config.rb', line 48

def reset!
  @xml.reset!
  @html.reset!
  @json.reset!
  @yaml.reset!
  @string.reset!
end

#use_colorObject



66
67
68
# File 'lib/canon/config.rb', line 66

def use_color
  @xml.diff.use_color
end

#use_color=(value) ⇒ Object



70
71
72
# File 'lib/canon/config.rb', line 70

def use_color=(value)
  @xml.diff.use_color = value
end

#xml_match_profileObject

Backward compatibility methods for match profile configuration



75
76
77
# File 'lib/canon/config.rb', line 75

def xml_match_profile
  @xml.match.profile
end

#xml_match_profile=(value) ⇒ Object



79
80
81
# File 'lib/canon/config.rb', line 79

def xml_match_profile=(value)
  @xml.match.profile = value
end