Class: Puppet::Pops::Lookup::ExplainTreeNode
- Inherits:
-
ExplainNode
- Object
- ExplainNode
- Puppet::Pops::Lookup::ExplainTreeNode
- Defined in:
- lib/puppet/pops/lookup/explainer.rb
Direct Known Subclasses
ExplainDataProvider, ExplainGlobal, ExplainInterpolate, ExplainMerge, ExplainModule, ExplainPath, ExplainScope
Instance Attribute Summary collapse
- #event ⇒ Object readonly
- #key ⇒ Object readonly
- #parent ⇒ Object readonly
- #value ⇒ Object readonly
Instance Method Summary collapse
- #dump_outcome(io, indent) ⇒ Object
- #dump_value(io, indent, value) ⇒ Object
- #found(key, value) ⇒ Object
- #found_in_defaults(key, value) ⇒ Object
- #found_in_overrides(key, value) ⇒ Object
- #increase_indent(indent) ⇒ Object
-
#initialize(parent) ⇒ ExplainTreeNode
constructor
A new instance of ExplainTreeNode.
- #module_not_found ⇒ Object
- #not_found(key) ⇒ Object
- #path_not_found ⇒ Object
- #result(value) ⇒ Object
- #to_hash ⇒ Object
- #type ⇒ Object
Methods inherited from ExplainNode
Constructor Details
#initialize(parent) ⇒ ExplainTreeNode
Returns a new instance of ExplainTreeNode.
33 34 35 36 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 33 def initialize(parent) @parent = parent @event = nil end |
Instance Attribute Details
#event ⇒ Object (readonly)
31 32 33 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 31 def event @event end |
#key ⇒ Object (readonly)
31 32 33 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 31 def key @key end |
#parent ⇒ Object (readonly)
31 32 33 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 31 def parent @parent end |
#value ⇒ Object (readonly)
31 32 33 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 31 def value @value end |
Instance Method Details
#dump_outcome(io, indent) ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 91 def dump_outcome(io, indent) io << indent << 'No such key: "' << @key << "\"\n" if @event == :not_found if [:found, :found_in_overrides, :found_in_defaults].include?(@event) io << indent << 'Found key: "' << @key << '" value: ' dump_value(io, indent, @value) io << ' in overrides' if @event == :found_in_overrides io << ' in defaults' if @event == :found_in_defaults io << "\n" end end |
#dump_value(io, indent, value) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 102 def dump_value(io, indent, value) case value when Hash io << '{' unless value.empty? inner_indent = increase_indent(indent) value.reduce("\n") do |sep, (k, v)| io << sep << inner_indent dump_value(io, inner_indent, k) io << ' => ' dump_value(io, inner_indent, v) ",\n" end io << "\n" << indent end io << '}' when Array io << '[' unless value.empty? inner_indent = increase_indent(indent) value.reduce("\n") do |sep, v| io << sep << inner_indent dump_value(io, inner_indent, v) ",\n" end io << "\n" << indent end io << ']' else io << value.inspect end end |
#found(key, value) ⇒ Object
50 51 52 53 54 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 50 def found(key, value) @key = key @value = value @event = :found end |
#found_in_defaults(key, value) ⇒ Object
44 45 46 47 48 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 44 def found_in_defaults(key, value) @key = key @value = value @event = :found_in_defaults end |
#found_in_overrides(key, value) ⇒ Object
38 39 40 41 42 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 38 def found_in_overrides(key, value) @key = key @value = value @event = :found_in_overrides end |
#increase_indent(indent) ⇒ Object
74 75 76 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 74 def increase_indent(indent) indent + ' ' end |
#module_not_found ⇒ Object
70 71 72 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 70 def module_not_found @event = :module_not_found end |
#not_found(key) ⇒ Object
61 62 63 64 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 61 def not_found(key) @key = key @event = :not_found end |
#path_not_found ⇒ Object
66 67 68 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 66 def path_not_found @event = :path_not_found end |
#result(value) ⇒ Object
56 57 58 59 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 56 def result(value) @value = value @event = :result end |
#to_hash ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 78 def to_hash hash = super hash[:key] = @key unless @key.nil? hash[:value] = @value if [:found, :found_in_defaults, :found_in_overrides, :result].include?(@event) hash[:event] = @event unless @event.nil? hash[:type] = type hash end |