Module: Bashman::ClassMethods

Defined in:
lib/bashman.rb

Overview

make the following functions available in every class

Instance Method Summary collapse

Instance Method Details

#get_config(section) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/bashman.rb', line 24

def get_config(section)
    require 'parseconfig'

    fullconfig = ParseConfig.new(CONFIG)
    config = {}
    config = fullconfig[section] if fullconfig.get_params.include?(section)
    config
end

#which(binary) ⇒ Object



17
18
19
20
21
22
# File 'lib/bashman.rb', line 17

def which(binary)
    ret = ''
    possibles = ENV["PATH"].split(File::PATH_SEPARATOR)
    possibles.map {|p| File.join(p, binary)}.find {|p| ret = p if File.executable?(p)}
    ret
end