Class: RQ::MainHelper
- Inherits:
-
Object
- Object
- RQ::MainHelper
- Defined in:
- lib/rq-0.1.7/mainhelper.rb
Direct Known Subclasses
Backer, Configurator, Creator, Deleter, Executor, Feeder, Lister, Locker, Querier, Snapshotter, StatusLister, Submitter, Updater
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
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#main ⇒ Object
readonly
Returns the value of attribute main.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#q ⇒ Object
readonly
Returns the value of attribute q.
-
#qpath ⇒ Object
readonly
Returns the value of attribute qpath.
Instance Method Summary collapse
-
#initialize(main) ⇒ MainHelper
constructor
A new instance of MainHelper.
-
#set_q ⇒ Object
}}}.
Methods included from Logging
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. @qpath = main.qpath @mode = main.mode @q = nil #}}} end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
16 17 18 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 16 def argv @argv end |
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
18 19 20 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 18 def cmd @cmd end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
17 18 19 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 17 def env @env end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
15 16 17 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 15 def logger @logger end |
#main ⇒ Object (readonly)
Returns the value of attribute main.
14 15 16 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 14 def main @main end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
21 22 23 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 21 def mode @mode end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 19 def @options end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
22 23 24 |
# File 'lib/rq-0.1.7/mainhelper.rb', line 22 def q @q end |
#qpath ⇒ Object (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_q ⇒ Object
}}}
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 |