Class: PuppetDebugger::InputResponders::Vars
Constant Summary
collapse
- COMMAND_WORDS =
%w(vars ls)
- SUMMARY =
'List all the variables in the current scopes.'
- COMMAND_GROUP =
:scope
Instance Attribute Summary
#debugger
Instance Method Summary
collapse
command_completion, command_group, command_words, details, execute, #modules_paths, #puppet_debugger_lib_dir, summary
Instance Method Details
#find_resources(resources, filter = []) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/plugins/puppet-debugger/input_responders/vars.rb', line 38
def find_resources(resources, filter = [])
filter_string = filter.join(' ').downcase
resources.find_all do |resource|
resource.name.to_s.downcase.include?(filter_string) || resource.type.to_s.downcase.include?(filter_string)
end
end
|
#parameters_to_h(resource) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/plugins/puppet-debugger/input_responders/vars.rb', line 30
def parameters_to_h(resource)
resource.parameters.each_with_object({}) do | param, params |
name = param.first.to_s
params[name] = param.last.value
params
end
end
|
#resource_parameters(resources, filter = []) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/plugins/puppet-debugger/input_responders/vars.rb', line 22
def resource_parameters(resources, filter = [])
find_resources(resources, filter).each_with_object({}) do | resource, acc|
name = "#{resource.type}[#{resource.name}]"
acc[name] = parameters_to_h(resource)
acc
end
end
|
#run(args = []) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/plugins/puppet-debugger/input_responders/vars.rb', line 9
def run(args = [])
filter = args
unless filter.empty?
parameters = resource_parameters(debugger.scope.catalog.resources, filter)
return parameters.ai(sort_keys: true, indent: -1)
end
variables = debugger.scope.to_hash.delete_if { |key, _value| debugger.node.facts.values.key?(key) }
variables['facts'] = 'removed by the puppet-debugger' if variables.key?('facts')
output = 'Facts were removed for easier viewing'.ai + "\n"
output += variables.ai(sort_keys: true, indent: -1)
end
|