Module: Kernel

Defined in:
lib/coral_core.rb

Overview


Global namespace

Instance Method Summary collapse

Instance Method Details

#coral_locate(command) ⇒ Object




30
31
32
33
34
35
36
37
38
39
40
# File 'lib/coral_core.rb', line 30

def coral_locate(command)
  command = command.to_s
  exts    = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    exts.each do |ext|
      exe = File.join(path, "#{command}#{ext}")
      return exe if File.executable?(exe)
    end
  end
  return nil
end

#coral_require(base_dir, name) ⇒ Object




44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/coral_core.rb', line 44

def coral_require(base_dir, name)
  name = name.to_s
  
  require File.join(base_dir, "#{name}.rb")  
  directory = File.join(base_dir, name)
    
  if File.directory?(directory)
    Dir.glob(File.join(directory, '**', '*.rb')).each do |sub_file|
      require sub_file
    end
  end  
end

#dbg(data, label = '') ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/coral_core.rb', line 15

def dbg(data, label = '')
  # Invocations of this function should NOT be committed to the project
  require 'pp'
  
  puts '>>----------------------'
  unless label.empty?
    puts label
    puts '---'
  end
  pp data
  puts '<<'
end