Class: Puppet::Pops::Lookup::ExplainLocation

Inherits:
ExplainTreeNode show all
Defined in:
lib/puppet/pops/lookup/explainer.rb

Instance Attribute Summary

Attributes inherited from ExplainTreeNode

#event, #key, #parent, #value

Instance Method Summary collapse

Methods inherited from ExplainTreeNode

#dump_outcome, #dump_value, #found, #found_in_defaults, #found_in_overrides, #increase_indent, #location_not_found, #not_found, #result, #to_s

Methods inherited from ExplainNode

#branches, #dump_texts, #explain, #inspect, #text, #to_s

Constructor Details

#initialize(parent, location) ⇒ ExplainLocation

Returns a new instance of ExplainLocation.



371
372
373
374
# File 'lib/puppet/pops/lookup/explainer.rb', line 371

def initialize(parent, location)
  super(parent)
  @location = location
end

Instance Method Details

#dump_on(io, indent, first_indent) ⇒ Object



376
377
378
379
380
381
382
383
384
385
# File 'lib/puppet/pops/lookup/explainer.rb', line 376

def dump_on(io, indent, first_indent)
  location = @location.location
  type_name = type == :path ? 'Path' : 'URI'
  io << indent << type_name << ' "' << location.to_s << "\"\n"
  indent = increase_indent(indent)
  io << indent << 'Original ' << type_name.downcase << ': "' << @location.original_location << "\"\n"
  branches.each {|b| b.dump_on(io, indent, indent)}
  io << indent << type_name << " not found\n" if @event == :location_not_found
  dump_outcome(io, indent)
end

#to_hashObject



387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/puppet/pops/lookup/explainer.rb', line 387

def to_hash
  hash = super
  location = @location.location
  if type == :path
    hash[:original_path] = @location.original_location
    hash[:path] = location.to_s
  else
    hash[:original_uri] = @location.original_location
    hash[:uri] = location.to_s
  end
  hash
end

#typeObject



400
401
402
# File 'lib/puppet/pops/lookup/explainer.rb', line 400

def type
  @location.location.is_a?(Pathname) ? :path : :uri
end