Class: SuperDiff::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/super_diff/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/super_diff/configuration.rb', line 22

def initialize(options = {})
  @actual_color = :yellow
  @border_color = :blue
  @color_enabled = color_enabled_by_default?
  @diff_elision_enabled = false
  @diff_elision_maximum = 0
  @elision_marker_color = :cyan
  @expected_color = :magenta
  @extra_diff_formatter_classes = [].freeze
  @extra_differ_classes = [].freeze
  @extra_inspection_tree_builder_classes = [].freeze
  @extra_operation_tree_builder_classes = [].freeze
  @extra_operation_tree_classes = [].freeze
  @header_color = :white
  @key_enabled = true

  merge!(options)
end

Instance Attribute Details

#actual_colorObject

Returns the value of attribute actual_color.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def actual_color
  @actual_color
end

#border_colorObject

Returns the value of attribute border_color.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def border_color
  @border_color
end

#color_enabledObject

Returns the value of attribute color_enabled.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def color_enabled
  @color_enabled
end

#diff_elision_enabledObject

Returns the value of attribute diff_elision_enabled.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def diff_elision_enabled
  @diff_elision_enabled
end

#diff_elision_maximumObject

Returns the value of attribute diff_elision_maximum.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def diff_elision_maximum
  @diff_elision_maximum
end

#elision_marker_colorObject

Returns the value of attribute elision_marker_color.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def elision_marker_color
  @elision_marker_color
end

#expected_colorObject

Returns the value of attribute expected_color.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def expected_color
  @expected_color
end

#extra_diff_formatter_classesObject (readonly)

Returns the value of attribute extra_diff_formatter_classes.



3
4
5
# File 'lib/super_diff/configuration.rb', line 3

def extra_diff_formatter_classes
  @extra_diff_formatter_classes
end

#extra_differ_classesObject (readonly)

Returns the value of attribute extra_differ_classes.



3
4
5
# File 'lib/super_diff/configuration.rb', line 3

def extra_differ_classes
  @extra_differ_classes
end

#extra_inspection_tree_builder_classesObject (readonly)

Returns the value of attribute extra_inspection_tree_builder_classes.



3
4
5
# File 'lib/super_diff/configuration.rb', line 3

def extra_inspection_tree_builder_classes
  @extra_inspection_tree_builder_classes
end

#extra_operation_tree_builder_classesObject (readonly)

Returns the value of attribute extra_operation_tree_builder_classes.



3
4
5
# File 'lib/super_diff/configuration.rb', line 3

def extra_operation_tree_builder_classes
  @extra_operation_tree_builder_classes
end

#extra_operation_tree_classesObject (readonly)

Returns the value of attribute extra_operation_tree_classes.



3
4
5
# File 'lib/super_diff/configuration.rb', line 3

def extra_operation_tree_classes
  @extra_operation_tree_classes
end

#header_colorObject

Returns the value of attribute header_color.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def header_color
  @header_color
end

#key_enabledObject

Returns the value of attribute key_enabled.



10
11
12
# File 'lib/super_diff/configuration.rb', line 10

def key_enabled
  @key_enabled
end

Instance Method Details

#add_extra_diff_formatter_classes(*classes) ⇒ Object Also known as: add_extra_diff_formatter_class



81
82
83
84
# File 'lib/super_diff/configuration.rb', line 81

def add_extra_diff_formatter_classes(*classes)
  @extra_diff_formatter_classes =
    (@extra_diff_formatter_classes + classes).freeze
end

#add_extra_differ_classes(*classes) ⇒ Object Also known as: add_extra_differ_class



90
91
92
# File 'lib/super_diff/configuration.rb', line 90

def add_extra_differ_classes(*classes)
  @extra_differ_classes = (@extra_differ_classes + classes).freeze
end

#add_extra_inspection_tree_builder_classes(*classes) ⇒ Object Also known as: add_extra_inspection_tree_builder_class



95
96
97
98
# File 'lib/super_diff/configuration.rb', line 95

def add_extra_inspection_tree_builder_classes(*classes)
  @extra_inspection_tree_builder_classes =
    (@extra_inspection_tree_builder_classes + classes).freeze
end

#add_extra_operation_tree_builder_classes(*classes) ⇒ Object Also known as: add_extra_operation_tree_builder_class



104
105
106
107
# File 'lib/super_diff/configuration.rb', line 104

def add_extra_operation_tree_builder_classes(*classes)
  @extra_operation_tree_builder_classes =
    (@extra_operation_tree_builder_classes + classes).freeze
end

#add_extra_operation_tree_classes(*classes) ⇒ Object Also known as: add_extra_operation_tree_class



113
114
115
116
# File 'lib/super_diff/configuration.rb', line 113

def add_extra_operation_tree_classes(*classes)
  @extra_operation_tree_classes =
    (@extra_operation_tree_classes + classes).freeze
end

#color_enabled?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/super_diff/configuration.rb', line 52

def color_enabled?
  @color_enabled
end

#diff_elision_enabled?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/super_diff/configuration.rb', line 56

def diff_elision_enabled?
  @diff_elision_enabled
end

#initialize_dup(original) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/super_diff/configuration.rb', line 41

def initialize_dup(original)
  super
  @extra_differ_classes = original.extra_differ_classes.dup.freeze
  @extra_operation_tree_builder_classes =
    original.extra_operation_tree_builder_classes.dup.freeze
  @extra_operation_tree_classes =
    original.extra_operation_tree_classes.dup.freeze
  @extra_inspection_tree_builder_classes =
    original.extra_inspection_tree_builder_classes.dup.freeze
end

#key_enabled?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/super_diff/configuration.rb', line 60

def key_enabled?
  @key_enabled
end

#merge!(configuration_or_options) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/super_diff/configuration.rb', line 64

def merge!(configuration_or_options)
  options =
    if configuration_or_options.is_a?(self.class)
      configuration_or_options.to_h
    else
      configuration_or_options
    end

  options.each { |key, value| instance_variable_set("@#{key}", value) }

  updated
end

#to_hObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/super_diff/configuration.rb', line 122

def to_h
  {
    actual_color: actual_color,
    border_color: border_color,
    color_enabled: color_enabled?,
    diff_elision_enabled: diff_elision_enabled?,
    diff_elision_maximum: diff_elision_maximum,
    elision_marker_color: elision_marker_color,
    expected_color: expected_color,
    extra_diff_formatter_classes: extra_diff_formatter_classes.dup,
    extra_differ_classes: extra_differ_classes.dup,
    extra_inspection_tree_builder_classes:
      extra_inspection_tree_builder_classes.dup,
    extra_operation_tree_builder_classes:
      extra_operation_tree_builder_classes.dup,
    extra_operation_tree_classes: extra_operation_tree_classes.dup,
    header_color: header_color,
    key_enabled: key_enabled?
  }
end

#updatedObject



77
78
79
# File 'lib/super_diff/configuration.rb', line 77

def updated
  SuperDiff::Csi.color_enabled = color_enabled?
end