Class: RQ::IOViewer
- Inherits:
-
MainHelper
- Object
- MainHelper
- RQ::IOViewer
- Defined in:
- lib/rq/ioviewer.rb
Overview
the IOViewer class spawns an external editor command to view the stdin/stdout/stderr of a jid(s)
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
-
#ioview ⇒ Object
–{{{.
Methods inherited from MainHelper
#dumping_yaml_tuples, #field_match, #init_job_stdin!, #initialize, #loadio, #loadyaml, #set_q
Methods included from Logging
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
#ioview ⇒ Object
–{{{
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rq/ioviewer.rb', line 15 def ioview #--{{{ @infile = @options['infile'] debug{ "infile <#{ @infile }>" } jobs = [] if @infile open(@infile) do |f| debug{ "reading jobs from <#{ @infile }>" } loadio f, @infile, jobs end end if stdin? debug{ "reading jobs from <stdin>" } loadio stdin, 'stdin', jobs end jobs.each{|job| @argv << Integer(job['jid'])} editor = @options['editor'] || ENV['RQ_EDITOR'] || ENV['RQ_IOVIEW'] || 'vim -R -o' @argv.each do |jid| jid = Integer jid ios = %w( stdin stdout stderr ).map{|d| File.join @qpath, d, jid.to_s} command = "#{ editor } #{ ios.join ' ' }" system(command) #or error{ "command <#{ command }> failed with <#{ $? }>" } end self #--}}} end |