Sha256: 17236e679e5ac8d1aef5559f39bfff6c95c4d82a5a41f9b7a74f2a94eaa0dda1

Contents?: true

Size: 970 Bytes

Versions: 4

Compression:

Stored size: 970 Bytes

Contents

require "redis" unless defined? Redis

require "scripterator/version"
require "scripterator/configuration"
require "scripterator/runner"

module Scripterator
  class << self
    def configure
      yield config
    end

    def config
      @config ||= Scripterator::Configuration.new
    end

    def run(description, &block)
      options = {}.tap do |o|
        o[:start_id]         = ENV['START'].try(:to_i)
        o[:end_id]           = ENV['END'].try(:to_i)
        o[:batch_size]       = ENV['BATCH_SIZE'].try(:to_i)
        o[:id_list]          = ENV['ID_LIST'].try(:split, ',')
        o[:redis_expiration] = ENV['REDIS_EXPIRATION'].try(:to_i) || config.redis_expiration
      end

      Runner.new(description, &block).run(options)
    end

    %w(already_run_for? checked_ids failed_ids).each do |runner_method|
      define_method(runner_method) do |description, *args|
        Runner.new(description).send(runner_method, *args)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scripterator-1.4.0 lib/scripterator.rb
scripterator-1.4.0.beta1 lib/scripterator.rb
scripterator-1.3.2 lib/scripterator.rb
scripterator-1.3.1 lib/scripterator.rb