module BundlerDefinitionHack

Public Instance Methods

require_relative(string) click to toggle source
Calls superclass method
# File lib/rubygems_executable_plugin.rb, line 7
def require_relative(string)
  this_path, target_path = caller_locations(0, 2).map(&:absolute_path)

  # replace file path with `..` so we get to system root
  relative_path = this_path.gsub(%r"/[^/]+", "/..").sub(%r"^/", "")
  # remove file name from target file path - base of relative_require
  absolute_path = target_path.sub(%r"/[^/]+$", "/")
  # relative path from this file to the target file via system root
  relative_string = "#{relative_path}#{absolute_path}#{string}"

  # call the real relative_require
  result = super(relative_string)

  if string == "lockfile_generator"
    Bundler::LockfileGenerator.prepend(BundledWithout)
  end
  result
end