summaryrefslogtreecommitdiff
path: root/prelude.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-12 14:50:18 (GMT)
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-12 14:50:18 (GMT)
commit6b36f117f2c35474aa2e63ef56edba338e124d9d (patch)
tree5a604310307481c29938f9bc58d75315d57ffd81 /prelude.rb
parent7b4a171158fffbb984378a094e7195072b0a5b05 (diff)
* prelude.rb (require_relative): move require_relative from
lib/require_relative.rb. [ruby-core:16356] * lib/require_relative.rb: removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'prelude.rb')
-rw-r--r--prelude.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/prelude.rb b/prelude.rb
index a38a578..fdf401b 100644
--- a/prelude.rb
+++ b/prelude.rb
@@ -23,3 +23,13 @@ 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}"
+ end
+ absolute_feature = File.expand_path(File.join(File.dirname(file), relative_feature))
+ require absolute_feature
+end