Class: PuppetDebugger::InputResponders::Stacktrace

Inherits:
PuppetDebugger::InputResponderPlugin show all
Defined in:
lib/plugins/puppet-debugger/input_responders/stacktrace.rb

Constant Summary collapse

COMMAND_WORDS =
%w[stacktrace].freeze
SUMMARY =
'Show the stacktrace for how we got here'
COMMAND_GROUP =
:tools

Instance Attribute Summary

Attributes inherited from PuppetDebugger::InputResponderPlugin

#debugger

Instance Method Summary collapse

Methods inherited from PuppetDebugger::InputResponderPlugin

command_completion, command_group, command_words, details, execute, #modules_paths, #puppet_debugger_lib_dir, summary

Instance Method Details

#run(_args = []) ⇒ Array

Returns - returns a array of pp files that are involved in the stacktrace.

Returns:

  • (Array)
    • returns a array of pp files that are involved in the stacktrace



12
13
14
15
# File 'lib/plugins/puppet-debugger/input_responders/stacktrace.rb', line 12

def run(_args = [])
  s = stacktrace
  s.empty? ? 'stacktrace not available'.warning : s.ai
end

#stacktraceArray

[

"/nwops/puppetlabs-peadm/spec/fixtures/modules/peadm/plans/status.pp:23",
"/nwops/puppetlabs-peadm/spec/fixtures/modules/peadm/plans/status.pp:20"

]

Returns:

  • (Array)
    • an array of files with line numbers



23
24
25
26
27
28
# File 'lib/plugins/puppet-debugger/input_responders/stacktrace.rb', line 23

def stacktrace
  stack = Puppet::Pops::PuppetStack.stacktrace.find_all { |line| !line.include?('unknown') }
  stack.each_with_object([]) do |item, acc|
    acc << item.join(':')
  end
end