Module: Kernel

Defined in:
lib/loaders/kernel_dir.rb,
lib/loaders/kernel_require.rb

Instance Method Summary collapse

Instance Method Details

#__DIR_REL__(called_from = nil) ⇒ Object Also known as: __DIR__



2
3
4
5
# File 'lib/loaders/kernel_dir.rb', line 2

def __DIR_REL__(called_from = nil)
  parsed_line = Callsite.parse(called_from || caller.first)
  parsed_line && File.expand_path(File.dirname(parsed_line.filename))
end

#require_all(req) ⇒ Object



2
3
4
# File 'lib/loaders/kernel_require.rb', line 2

def require_all(req)
  $LOAD_PATH.find_all_files(req, ".rb") { |file| require file }
end

#require_next(req) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/loaders/kernel_require.rb', line 6

def require_next(req)
  found, current = false, File.expand_path(caller.first[/(.*)(:\d+)/,1])
  $LOAD_PATH.find_all_files(req, ".rb") do |file|
    if found
      $LOADED_FEATURES << req
      return require(file)
    else
      found = current == file
    end
  end
  require req
end

#require_relative(path) ⇒ Object



12
13
14
# File 'lib/loaders/kernel_dir.rb', line 12

def require_relative(path)
  require File.join(__DIR_REL__(caller.first), path)
end