Module: Kernel

Defined in:
lib/wordpress-client.rb

Instance Method Summary collapse

Instance Method Details

#require_relative(relative_path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/wordpress-client.rb', line 3

def require_relative(relative_path)
  desired_path = File.expand_path('../' + relative_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