Module: JobManager

Defined in:
lib/jobmanager/version.rb,
lib/jobmanager/util.rb,
lib/jobmanager/system.rb,
lib/jobmanager/teestream.rb,
lib/jobmanager/application.rb,
lib/jobmanager/applicationconfig.rb,
lib/jobmanager/applicationlogger.rb,
lib/jobmanager/timestampedstream.rb,
lib/jobmanager/openonfirstwritefile.rb,
lib/jobmanager/applicationoptionparser.rb

Overview

:nodoc:

Defined Under Namespace

Modules: System, VERSION Classes: Application, ApplicationConfig, ApplicationFileLogger, ApplicationIOLogger, ApplicationLogger, ApplicationOptionParser, ApplicationSyslogLogger, OpenOnFirstWriteFile, TeeStream, TimestampedStream

Class Method Summary collapse

Class Method Details

.disable_warnings(&block) ⇒ Object

Description:

Helper method to temporarily disable warnings for the invocation of the block.

Parameters:

block

The block to be invoked.



13
14
15
16
17
18
19
20
21
22
# File 'lib/jobmanager/util.rb', line 13

def self.disable_warnings(&block)
  save = $-w
  $-w = false
  
  begin
    block.call
  ensure
    $-w = save
  end
end

.exec_or_raise(command, options = {}) ⇒ Object

Description:

Execute the given command. Raise an error on failure.

Parameters:

command

The command to be executed.

options

The following list of options is allowed.

verbose

Print the command as well as the output of the executed command.

Returns:

The command’s output.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/jobmanager/util.rb', line 37

def self.exec_or_raise(command, options = {})
  if options[:verbose] then print "#{command}\n" end
  
  result = %x[ #{command} ]
  
  if options[:verbose] then 
    result.split("\n").each { |line| print "+  #{line}\n" }
  end
  
  if ($CHILD_STATUS != 0)
    raise "+ Command (#{command}) Failed! Exit Status: #{$CHILD_STATUS.inspect}"
  end
  
  return result
end