class Inspec::Profile

def load_libraries

def load_libraries
  return @runner_context if @libraries_loaded
  locked_dependencies.dep_list.each_with_index do |(_name, dep), index|
    d = dep.profile
    # this will force a dependent profile load so we are only going to add
    # this metadata if the parent profile is supported.
    if @supports_platform && !d.supports_platform?
      # since ruby 1.9 hashes are ordered so we can just use index values here
      # TODO: NO! this is a violation of encapsulation to an extreme
      if metadata.dependencies[index]
        metadata.dependencies[index][:status] = "skipped"
        msg = "Skipping profile: '#{d.name}' on unsupported platform: '#{d.backend.platform.name}/#{d.backend.platform.release}'."
        metadata.dependencies[index][:status_message] = msg
        metadata.dependencies[index][:skip_message] = msg # Repeat as skip_message for backward compatibility
      end
      next
    elsif metadata.dependencies[index]
      # Currently wrapper profiles will load all dependencies, and then we
      # load them again when we dive down. This needs to be re-done.
      metadata.dependencies[index][:status] = "loaded"
    end
    # rubocop:disable Layout/ExtraSpacing
    c = d.load_libraries                           # !!!RECURSE!!!
    @runner_context.add_resources(c)
  end
  # TODO: why?!? we own both sides of this code
  libs = libraries.map(&:reverse)
  @runner_context.load_libraries(libs)
  @libraries_loaded = true
  @runner_context
end