Module: PuppetDebugger::Support::Functions
- Included in:
- PuppetDebugger::Support
- Defined in:
- lib/puppet-debugger/support/functions.rb
Instance Method Summary collapse
- #data_type_files ⇒ Object
-
#function_files ⇒ Object
returns a array of function files which is only required when displaying the function map, puppet will load each function on demand in the future we may want to utilize the puppet loaders to find these things.
-
#function_map ⇒ Object
returns a map of functions.
-
#lib_dirs(module_dirs = modules_paths) ⇒ Object
gather all the lib dirs.
-
#load_lib_dirs(module_dirs = modules_paths) ⇒ Object
load all the lib dirs so puppet can find the functions at this time, this function is not being used.
-
#mod_finder ⇒ Object
returns either the module name or puppet version.
Instance Method Details
#data_type_files ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puppet-debugger/support/functions.rb', line 21 def data_type_files search_dirs = lib_dirs.map do |lib_dir| [File.join(lib_dir, 'puppet', 'functions', '**', '*.rb'), File.join(lib_dir, 'functions', '**', '*.rb'), File.join(lib_dir, 'puppet', 'parser', 'functions', '*.rb')] end # add puppet lib directories search_dirs << [File.join(puppet_lib_dir, 'puppet', 'functions', '**', '*.rb'), File.join(puppet_lib_dir, 'puppet', 'parser', 'functions', '*.rb')] Dir.glob(search_dirs.flatten) end |
#function_files ⇒ Object
returns a array of function files which is only required when displaying the function map, puppet will load each function on demand in the future we may want to utilize the puppet loaders to find these things
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/puppet-debugger/support/functions.rb', line 9 def function_files search_dirs = lib_dirs.map do |lib_dir| [File.join(lib_dir, 'puppet', 'functions', '**', '*.rb'), File.join(lib_dir, 'functions', '**', '*.rb'), File.join(lib_dir, 'puppet', 'parser', 'functions', '*.rb')] end # add puppet lib directories search_dirs << [File.join(puppet_lib_dir, 'puppet', 'functions', '**', '*.rb'), File.join(puppet_lib_dir, 'puppet', 'parser', 'functions', '*.rb')] Dir.glob(search_dirs.flatten) end |
#function_map ⇒ Object
returns a map of functions
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/puppet-debugger/support/functions.rb', line 39 def function_map unless @functions do_initialize @functions = {} function_files.each do |file| obj = {} name = File.basename(file, '.rb') obj[:name] = name # return the last matched in cases where rbenv might be involved obj[:parent] = file.scan(mod_finder).flatten.last @functions["#{obj[:parent]}::#{name}"] = obj end end @functions end |
#lib_dirs(module_dirs = modules_paths) ⇒ Object
gather all the lib dirs
56 57 58 59 60 61 |
# File 'lib/puppet-debugger/support/functions.rb', line 56 def lib_dirs(module_dirs = modules_paths) dirs = module_dirs.map do |mod_dir| Dir["#{mod_dir}/*/lib"].entries end.flatten dirs + [puppet_repl_lib_dir] end |
#load_lib_dirs(module_dirs = modules_paths) ⇒ Object
load all the lib dirs so puppet can find the functions at this time, this function is not being used
65 66 67 68 69 |
# File 'lib/puppet-debugger/support/functions.rb', line 65 def load_lib_dirs(module_dirs = modules_paths) lib_dirs(module_dirs).each do |lib| $LOAD_PATH << lib end end |
#mod_finder ⇒ Object
returns either the module name or puppet version
34 35 36 |
# File 'lib/puppet-debugger/support/functions.rb', line 34 def mod_finder @mod_finder ||= Regexp.new('\/([\w\-\.]+)\/lib') end |