1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* compile.c, iseq.c, ruby.c, vm.c, vm_core.h, vm_eval.c: add absolute

path field into rb_iseq_t.  The field contains a string representing
  a path to corresponding source file. or nil when the iseq is created
  from -e, stdin, eval, etc.  This field is used for require_relative.
  [ruby-dev:40004]

* load.c (rb_f_require_relative): add C implementation of
  require_relative.

* prelude.rb (require_relative): get rid of Ruby implementation of
  require_relative.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2010-03-16 17:40:00 +00:00
parent c4fdd64fe0
commit 6ff75042db
10 changed files with 89 additions and 53 deletions

View file

@ -22,17 +22,3 @@ class Thread
}
end
end
module Kernel
module_function
def require_relative(relative_feature)
c = caller.first
e = c.rindex(/:\d+:in /)
file = $`
if /\A\((.*)\)/ =~ file # eval, etc.
raise LoadError, "require_relative is called in #{$1}"
end
absolute_feature = File.join(File.dirname(File.realpath(file)), relative_feature)
require absolute_feature
end
end