Sha256: 6317ca77f0a2c45b93d9bda8014126a8c23100996e762f1e1f26a326fc92969f

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

unless defined? $__rq_mainhelper__
  module RQ 
#{{{
    LIBDIR = File::dirname(File::expand_path(__FILE__)) + File::SEPARATOR unless
      defined? LIBDIR

    require LIBDIR + 'util'
    require LIBDIR + 'logging'

    class  MainHelper
#{{{
      include Util
      include Logging
      attr :main
      attr :logger
      attr :argv
      attr :env
      attr :cmd
      attr :options
      attr :qpath
      attr :mode
      attr :q
      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
      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
#}}}
    end # class MainHelper
#}}}
  end # module RQ
$__rq_mainhelper__ = __FILE__ 
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rq-0.1.7 lib/rq-0.1.7/mainhelper.rb