Class: PuppetDebugger::InputResponders::Datatypes
- Inherits:
-
PuppetDebugger::InputResponderPlugin
- Object
- PuppetDebugger::InputResponderPlugin
- PuppetDebugger::InputResponders::Datatypes
- Defined in:
- lib/plugins/puppet-debugger/input_responders/datatypes.rb
Constant Summary collapse
- COMMAND_WORDS =
%w[datatypes].freeze
- SUMMARY =
'List all the datatypes available in the environment.'
- COMMAND_GROUP =
:environment
Instance Attribute Summary
Attributes inherited from PuppetDebugger::InputResponderPlugin
Instance Method Summary collapse
-
#all_data_types ⇒ Array[String]
-
combined list of core data types and environment data types.
-
-
#core_datatypes ⇒ Array[String]
loaders.instance_variable_get(:@loaders_by_name) [:func_4x, :func_4xpp, :func_3x, :datatype, :type_pp, :resource_type_pp, :plan, :task].
-
#environment_data_types ⇒ Array[String]
-
returns a list of all the custom data types found in all the modules in the environment.
-
- #find_datatypes(datatypes, filter = []) ⇒ Object
- #run(args = []) ⇒ Object
Methods inherited from PuppetDebugger::InputResponderPlugin
command_completion, command_group, command_words, details, execute, #modules_paths, #puppet_debugger_lib_dir, summary
Instance Method Details
#all_data_types ⇒ Array[String]
Returns - combined list of core data types and environment data types.
50 51 52 53 54 55 56 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 50 def all_data_types unless loaders.respond_to?(:implementation_registry) Puppet.info("Data Types Not Available in Puppet: #{Puppet.version}") return [] end core_datatypes + environment_data_types end |
#core_datatypes ⇒ Array[String]
loaders.instance_variable_get(:@loaders_by_name) [:func_4x, :func_4xpp, :func_3x, :datatype, :type_pp, :resource_type_pp, :plan, :task]
43 44 45 46 47 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 43 def core_datatypes loaders.implementation_registry.instance_variable_get(:@parent) .instance_variable_get(:@implementations_per_type_name) .keys.find_all { |t| t !~ /::/ } end |
#environment_data_types ⇒ Array[String]
Returns - returns a list of all the custom data types found in all the modules in the environment.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 27 def environment_data_types globs = debugger.puppet_environment.instance_variable_get(:@modulepath).map { |m| File.join(m, '**', 'types', '**', '*.pp') } files = globs.map { |g| Dir.glob(g) }.flatten files.map do |f| m = File.read(f).match(/type\s([a-z\d\:_]+)/i) if m next if m[1] =~ /type|alias/ # can't figure out the best way to filter type and alias out m[1] if m[1] =~ /::/ end end.uniq.compact end |
#find_datatypes(datatypes, filter = []) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 17 def find_datatypes(datatypes, filter = []) return datatypes if filter.nil? || filter.empty? filter_string = filter.join(' ').downcase datatypes.find_all do |datatype| datatype.downcase.include?(filter_string) end end |
#run(args = []) ⇒ Object
11 12 13 14 15 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 11 def run(args = []) filter = args datatypes = find_datatypes(all_data_types.sort, filter) datatypes.ai end |