Module: BuildpackSupport::DirectoryFinder

Included in:
BuildpackVersion, Cache::DownloadCache, Component::BaseDroplet, ConfigurationUtils
Defined in:
lib/buildpack_support/directory_finder.rb

Overview

A module encapsulating all of the code for the directory finding utilities

Instance Method Summary collapse

Instance Method Details

#load_path_peer(name) ⇒ Pathname

Finds a directory that is a peer of the $LOAD_PATH

Parameters:

  • name (String)

    the name of the peer directory

Returns:

  • (Pathname)

    the path to the found directory if it exists, otherwise a path to the current working directory



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/buildpack_support/directory_finder.rb', line 28

def load_path_peer(name)
  directory = Pathname.new('.nil')

  $LOAD_PATH.each do |path|
    candidate = Pathname.new(path) + '..' + name

    next unless candidate.exist?

    directory = candidate
    break
  end

  directory
end