Method: Inspec::ProfileContext#load_libraries

Defined in:
lib/inspec/profile_context.rb

#load_libraries(libs) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/inspec/profile_context.rb', line 107

def load_libraries(libs)
  lib_prefix = 'libraries' + File::SEPARATOR
  autoloads = []

  libs.each do |content, source, line|
    path = source
    if source.start_with?(lib_prefix)
      path = source.sub(lib_prefix, '')
      autoloads.push(path) if File.dirname(path) == '.'
    end

    @require_loader.add(path, content, source, line)
  end

  # load all files directly that are flat inside the libraries folder
  autoloads.each do |path|
    next unless path.end_with?('.rb')
    load_library_file(*@require_loader.load(path)) unless @require_loader.loaded?(path)
  end
  reload_dsl
end