Class: RQ::StatusLister

Inherits:
MainHelper show all
Defined in:
lib/rq/statuslister.rb

Overview

the StatusLister class dumps a yaml report on stdout showing how many jobs are in each of the states

  • pending

  • holding

  • running

  • finished

  • dead

Constant Summary

Constants included from Logging

Logging::DIV0, Logging::DIV1, Logging::DIV2, Logging::DIV3, Logging::EOL, Logging::SEC0, Logging::SEC1, Logging::SEC2, Logging::SEC3

Instance Attribute Summary

Attributes inherited from MainHelper

#argv, #cmd, #dot_rq_dir, #env, #fields, #job_stdin, #loops, #main, #mode, #options, #program, #q, #qpath, #quiet, #stdin

Instance Method Summary collapse

Methods inherited from MainHelper

#dumping_yaml_tuples, #field_match, #init_job_stdin!, #initialize, #loadio, #loadyaml, #set_q

Methods included from Logging

append_features

Methods included from Logging::LogMethods

#debug, #error, #fatal, #info, #logerr, #logger, #logger=, #warn

Methods included from Util

#alive?, append_features, #btrace, #columnize, #defval, #emsg, #erreq, #errmsg, #escape, #escape!, #exec, export, #fork, #getopt, #hashify, #hms, #host, #hostname, #klass, #maim, #mcp, #realpath, #stamptime, #system, #timestamp, #tmpnam, #uncache, #which_ruby

Constructor Details

This class inherits a constructor from RQ::MainHelper

Instance Method Details

#parse_exit_code_map(emap = 'ok=42') ⇒ Object

–}}}



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rq/statuslister.rb', line 27

def parse_exit_code_map emap = 'ok=42'
  emap ||= 'ok=42'
  map = {}
  begin
    tokens = emap.strip.gsub(%r/\s+/, ' ').gsub(%r/\s*=\s*/, '=').split
    tokens.each do |token|
      key, *values = token.split %r/[=,]/
      values.map!{|value| Integer value}
      map[key.to_s] = values
    end
  rescue => e
    warn{ e }
    raise "bad map <#{ emap }"
  end
  map
end

#statuslistObject

–{{{



20
21
22
23
24
25
26
# File 'lib/rq/statuslister.rb', line 20

def statuslist 
#--{{{
  set_q
  exit_code_map = parse_exit_code_map @options['exit']
  puts @q.status('exit_code_map' => exit_code_map).to_yaml
#--}}}
end