Class: RQ::MainHelper

Inherits:
Object
  • Object
show all
Includes:
Logging, Util
Defined in:
lib/rq-0.1.7/mainhelper.rb

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 collapse

Instance Method Summary collapse

Methods included from Logging

append_features

Methods included from Logging::LogMethods

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

Methods included from Util

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

Constructor Details

#initialize(main) ⇒ MainHelper

Returns a new instance of MainHelper.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rq-0.1.7/mainhelper.rb', line 23

def initialize main
#{{{
  @main = main
  @logger = main.logger
  @argv = main.argv
  @env = main.env
  @cmd = main.cmd
  @options = main.options
  @qpath = main.qpath
  @mode = main.mode
  @q = nil 
#}}}
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



16
17
18
# File 'lib/rq-0.1.7/mainhelper.rb', line 16

def argv
  @argv
end

#cmdObject (readonly)

Returns the value of attribute cmd.



18
19
20
# File 'lib/rq-0.1.7/mainhelper.rb', line 18

def cmd
  @cmd
end

#envObject (readonly)

Returns the value of attribute env.



17
18
19
# File 'lib/rq-0.1.7/mainhelper.rb', line 17

def env
  @env
end

#loggerObject (readonly)

Returns the value of attribute logger.



15
16
17
# File 'lib/rq-0.1.7/mainhelper.rb', line 15

def logger
  @logger
end

#mainObject (readonly)

Returns the value of attribute main.



14
15
16
# File 'lib/rq-0.1.7/mainhelper.rb', line 14

def main
  @main
end

#modeObject (readonly)

Returns the value of attribute mode.



21
22
23
# File 'lib/rq-0.1.7/mainhelper.rb', line 21

def mode
  @mode
end

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/rq-0.1.7/mainhelper.rb', line 19

def options
  @options
end

#qObject (readonly)

Returns the value of attribute q.



22
23
24
# File 'lib/rq-0.1.7/mainhelper.rb', line 22

def q
  @q
end

#qpathObject (readonly)

Returns the value of attribute qpath.



20
21
22
# File 'lib/rq-0.1.7/mainhelper.rb', line 20

def qpath
  @qpath
end

Instance Method Details

#set_qObject

}}}



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rq-0.1.7/mainhelper.rb', line 36

def set_q
    #{{{
  raise "q <#{ @qpath }> does not exist" unless test ?d, @qpath
  @q = JobQueue::new @qpath, 'logger' => @logger
  if @options['snapshot']
    ss = "#{ $0 }_#{ Process::pid }_#{ Thread::current.id.abs }_#{ rand Time::now.to_i  }".gsub(%r|/|o,'_')
    qtmp = File::join Dir::tmpdir, ss
    @q = @q.snapshot qtmp, @options['retries']
    at_exit{ FileUtils::rm_rf qtmp }
  end
    #}}}
end