Module: Antrapol::ToolRack::ProcessUtils

Included in:
ProcessUtilsEngine
Defined in:
lib/toolrack/process_utils.rb

Instance Method Summary collapse

Instance Method Details

#exec(cmd, opts = { }, &block) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/toolrack/process_utils.rb', line 23

def exec(cmd, opts = { }, &block)
  type = opts[:exec_type]
  if not type.nil?
    instance(type, cmd, opts, &block)
  else
    instance(:basic, cmd, opts, &block)
  end
end

#instance(type, cmd, opts = { }, &block) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/toolrack/process_utils.rb', line 32

def instance(type, cmd, opts = { }, &block)
  case type
  when :basic
    Antrapol::ToolRack::Logger.instance.glogger.debug "Basic execution"
    basic_exec(cmd, &block)
  when :system
    Antrapol::ToolRack::Logger.instance.glogger.debug "System execution"
    system_exec(cmd, opts, &block)
  when :popen3
    Antrapol::ToolRack::Logger.instance.glogger.debug "Popen3 execution"
    popen3_exec(cmd, opts, &block)
  else
    Antrapol::ToolRack::Logger.instance.glogger.debug "Basic (fallback) execution"
    # basic
    basic_exec(cmd, &block) 
  end
end