* prelude.rb (require_relative): defined as a module function of

Kernel.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-10-16 13:23:15 +00:00
Родитель 78fea69776
Коммит 02689d147d
2 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Fri Oct 16 22:20:25 2009 Tanaka Akira <akr@fsij.org>
* prelude.rb (require_relative): defined as a module function of
Kernel.
Fri Oct 16 20:18:28 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (Delegator#method_missing): remove backtrace

Просмотреть файл

@ -23,13 +23,16 @@ class Thread
end
end
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}"
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.expand_path(File.join(File.dirname(file), relative_feature))
require absolute_feature
end
absolute_feature = File.expand_path(File.join(File.dirname(file), relative_feature))
require absolute_feature
end