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)
- 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]
-
a list of core data types.
-
-
#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.
42 43 44 45 46 47 48 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 42 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]
Returns - a list of core data types.
35 36 37 38 39 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 35 def core_datatypes loaders.implementation_registry .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.
24 25 26 27 28 29 30 31 32 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 24 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) next if m =~ /type|alias/ # can't figure out the best way to filter type and alias out m[1] if m && m[1] =~ /::/ end.uniq.compact end |
#find_datatypes(datatypes, filter = []) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 15 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
9 10 11 12 13 |
# File 'lib/plugins/puppet-debugger/input_responders/datatypes.rb', line 9 def run(args = []) filter = args datatypes = find_datatypes(all_data_types.sort, filter) datatypes.ai end |