Module: HelperClasses::System

Extended by:
DPuts, System
Includes:
DPuts
Included in:
System
Defined in:
lib/helperclasses/system.rb

Instance Attribute Summary

Attributes included from DPuts

#log_file, #mutex, #show_time, #silent, #terminal_width

Instance Method Summary collapse

Methods included from DPuts

ddputs, dp, dputs, dputs_func, dputs_getcaller, dputs_out, dputs_unfunc, log_msg

Instance Method Details

#exists?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/helperclasses/system.rb', line 20

def exists?(cmd)
  dputs(3) { "Exist command --#{cmd}--?" }
  run_bool("which #{cmd} > /dev/null 2>&1")
end

#rescue_all(msg = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/helperclasses/system.rb', line 25

def rescue_all(msg = nil)
  begin
    yield
  rescue Exception => e
    msg and dputs(0) { msg }
    dputs(0) { "#{e.inspect}" }
    dputs(0) { "#{e.to_s}" }
    e.backtrace.each { |l| dputs(0) { l } }
  end
end

#run_bool(cmd) ⇒ Object



15
16
17
18
# File 'lib/helperclasses/system.rb', line 15

def run_bool(cmd)
  dputs(3) { "Running command --#{cmd}--" }
  Kernel.system("#{cmd} > /dev/null 2>&1")
end

#run_str(cmd) ⇒ Object



10
11
12
13
# File 'lib/helperclasses/system.rb', line 10

def run_str(cmd)
  dputs(3) { "Running command --#{cmd}--" }
  %x[ #{cmd} ]
end