module RequireRelative

Constants

VERSION

Public Class Methods

abs_file() click to toggle source
# File lib/require_relative.rb, line 8
def abs_file
  if defined?(RubyVM::ThreadFrame)
    RubyVM::ThreadFrame.current.prev.source_container[1]
  elsif defined?(Rubinius) && "1.8.7" == RUBY_VERSION
    scope = Rubinius::StaticScope.of_sender
    script = scope.current_script
    if script
      script.data_path
    else
      nil
    end
  else
    file = caller.first.split(/:\d/,2).first
    if /\A\((.*)\)/ =~ file # eval, etc.
      nil
    end
    File.expand_path(file)
  end
end

Private Instance Methods

abs_file() click to toggle source
# File lib/require_relative.rb, line 8
def abs_file
  if defined?(RubyVM::ThreadFrame)
    RubyVM::ThreadFrame.current.prev.source_container[1]
  elsif defined?(Rubinius) && "1.8.7" == RUBY_VERSION
    scope = Rubinius::StaticScope.of_sender
    script = scope.current_script
    if script
      script.data_path
    else
      nil
    end
  else
    file = caller.first.split(/:\d/,2).first
    if /\A\((.*)\)/ =~ file # eval, etc.
      nil
    end
    File.expand_path(file)
  end
end