Module: Kernel

Defined in:
lib/nucleon_base.rb,
lib/nucleon_base.rb

Overview


Instance Method Summary collapse

Instance Method Details

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



185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/nucleon_base.rb', line 185

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

#nucleon_locate(command) ⇒ Object



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

def nucleon_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

#nucleon_require(base_dir, name) ⇒ Object




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

def nucleon_require(base_dir, name)
  name = name.to_s
  top_level_file = File.join(base_dir, "#{name}.rb")
  
  require top_level_file if File.exists?(top_level_file) 
   
  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