Sha256: aec9b078f683e51ef3c9a49c51418e801169bb3281e02a1e7b20eb6a8c8e8633
Contents?: true
Size: 837 Bytes
Versions: 2
Compression:
Stored size: 837 Bytes
Contents
# This sorts out the issues of require'ing files in Ruby # 1) on one line, you specify all the paths you need # 2) Relative paths will be relative to the file you are in, absolute paths also supported # 3) Paths will be expanded # 4) Paths will only be added if they don't already exist # module ::Kernel def require_paths(*aArgs) caller_dir = File.dirname(File.expand_path(caller.first.sub(/:[0-9]+.*/,''))) aArgs.each do |aPath| aPath = File.expand_path(aPath,caller_dir) $LOAD_PATH << aPath unless $LOAD_PATH.include?(aPath) end end def require_paths_first(*aArgs) caller_dir = File.dirname(File.expand_path(caller.first.sub(/:[0-9]+.*/,''))) paths = [] aArgs.each do |aPath| aPath = File.expand_path(aPath,caller_dir) paths << aPath end paths.each do |p| $LOAD_PATH.insert(0,p) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
buzzware-buzzcore-0.2.2 | lib/buzzcore/require_paths.rb |
buzzware-buzzcore-0.2.3 | lib/buzzcore/require_paths.rb |