Class: PuppetDebugger::InputResponders::Types

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

Constant Summary collapse

COMMAND_WORDS =
%w(types)
SUMMARY =
'List all the types available in the environment.'
COMMAND_GROUP =
:environment

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 = []) ⇒ Object

if a error occurs we we run the types function again

Returns:

    • returns a list of types available to the environment



11
12
13
# File 'lib/plugins/puppet-debugger/input_responders/types.rb', line 11

def run(args = [])
  types
end

#typesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/plugins/puppet-debugger/input_responders/types.rb', line 15

def types
  loaded_types = []
  begin
    # this loads all the types, if already loaded the file is skipped
    Puppet::Type.loadall
    Puppet::Type.eachtype do |t|
      next if t.name == :component
      loaded_types << t.name.to_s
    end
    loaded_types.ai
  rescue Puppet::Error => e
    puts e.message.red
    Puppet.info(e.message)
    # prevent more than two calls and recursive loop
    return if caller_locations(1, 10).find_all { |f| f.label == 'types' }.count > 2
    types
  end
end