Module: BioDSL::StatusHelper

Included in:
Pipeline
Defined in:
lib/BioDSL/helpers/status_helper.rb

Overview

Namespace with methods to record and manipulate cammand status.

Instance Method Summary collapse

Instance Method Details

#status_init(status, args) ⇒ Object

Given a list of symbols initialize all as status hash keys with the value 0.

Parameters:

  • status (Hash)

    Status hash.

  • args (Array)

    List of symbols.



39
40
41
42
# File 'lib/BioDSL/helpers/status_helper.rb', line 39

def status_init(status, args)
  args.each { |arg| status[arg] = 0 }
  @status = status
end

#status_progress(commands, &block) ⇒ Object

Track the status progress of a running command in a seperate thread and output the status at speficied intervals.

Parameters:

  • commands (Array)

    List of commands whos status should be output.

  • block (Proc)

    Track the command in the given block.

Raises:

  • (RunTimeError)

    If no block is given.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/BioDSL/helpers/status_helper.rb', line 51

def status_progress(commands, &block)
  fail 'No block given' unless block

  thread = Thread.new do
    print "\e[H\e[2J"   # Console code to clear screen

    loop do
      progress_print(commands)

      sleep BioDSL::Config::STATUS_PROGRESS_INTERVAL
    end
  end

  block.call

  thread.terminate

  progress_print(commands)
end