Sha256: 318dc81ffbe5145be9e821a673fcae7e572da73c2bbd7659d913371ffa37cb2c

Contents?: true

Size: 955 Bytes

Versions: 1

Compression:

Stored size: 955 Bytes

Contents

require 'logger'
require 'clockwork'
require 'pushpop/version'
require 'pushpop/job'
require 'pushpop/step'

module Pushpop
  class << self
    cattr_accessor :logger
    cattr_accessor :jobs

    # for jobs and steps
    def random_name
      (0...8).map { (65 + rand(26)).chr }.join
    end

    self.jobs = []

    def add_job(name=nil, &block)
      self.jobs.push(Job.new(name, &block))
      self.jobs.last
    end

    def run
      self.jobs.map &:run
    end

    def schedule
      self.jobs.map &:schedule
    end

    def load_plugin(name)
      load "#{File.expand_path("../plugins/#{name}", __FILE__)}.rb"
    end
  end
end

# add into main
def job(name=nil, &block)
  Pushpop.add_job(name, &block)
end

Pushpop.logger = lambda {
  logger = Logger.new($stdout)
  if ENV['DEBUG']
    logger.level = Logger::DEBUG
  elsif ENV['RACK_ENV'] == 'test'
    logger.level = Logger::FATAL
  else
    logger.level = Logger::INFO
  end
  logger
}.call

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pushpop-0.1.1 lib/pushpop.rb