Module: Kernel
- Defined in:
- lib/sane/pp.rb,
lib/sane/sane_random.rb,
lib/sane/require_relative.rb
Overview
taken from oldrcrs.rubypal.com/rcr/show/309
Constant Summary collapse
- OriginalDir =
try to accomodate for later Directory changes…
File.(Dir.pwd)
Class Method Summary collapse
Instance Method Summary collapse
-
#__DIR__ ⇒ Object
BASE_DIR = Dir.getwd.
- #pp(*objs) ⇒ Object
Class Method Details
.require_relative(relative_feature) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sane/require_relative.rb', line 7 def require_relative(relative_feature) c = caller.first # could be spec.sane.rb:127 # or e:/abc.rb:127 e = c.rindex(/:\d+/) file = $` if /\A\((.*)\)/ =~ file # eval, etc. raise LoadError, "require_relative is called in #{$1}" end absolute_feature = File.(File.join(File.dirname(file), relative_feature)) begin require absolute_feature rescue LoadError => e # hacky kludge in case they've changed dirs... begin require File.(File.join(OriginalDir,File.dirname(file), relative_feature)) rescue LoadError => ignore_me raise e # don't mask... end end end |
Instance Method Details
#__DIR__ ⇒ Object
BASE_DIR = Dir.getwd
63 64 65 66 |
# File 'lib/sane/sane_random.rb', line 63 def __DIR__ dir = (/^(.+)?:\d+/ =~ caller[0]) ? File.(File.dirname($1), Dir.pwd) : nil dir end |
#pp(*objs) ⇒ Object
5 6 7 8 |
# File 'lib/sane/pp.rb', line 5 def pp(*objs) require('pp') pp(*objs) # use the new method end |