Module: Kernel

Defined in:
lib/awsbase/require_relative.rb

Instance Method Summary collapse

Instance Method Details

#require_relative(path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/awsbase/require_relative.rb', line 7

def require_relative(path)
  desired_path = File.expand_path('../' + path.to_str, caller[0])
  shortest = desired_path
  $:.each do |path|
    path += '/'
    if desired_path.index(path) == 0
      candidate = desired_path.sub(path, '')
      shortest = candidate if candidate.size < shortest.size
    end
  end
  require shortest
end