Sha256: 5fb4d9c5d3840484fef91963631a27d77226bff7bbaefbbe7d24efdf8c444fa6

Contents?: true

Size: 777 Bytes

Versions: 1

Compression:

Stored size: 777 Bytes

Contents

# encoding: UTF-8

module MultiScheduler
  VERSION = '0.1.0'

  def schedule options = {}
    scheduler(options).start
  end

  def unschedule id
    scheduler({ identifier: id }).stop
  end

  def scheduler options = {}
    case RbConfig::CONFIG['host_os']
    when /darwin/i
      Launchd.new options
    else
      Whenever.new options
    end
  end

  class Scheduler
    
    def initialize options = {}

      @identifier = options[:id]
      raise ":id is required" unless @identifier

      @command_arguments = options[:args] || []
      @command = options[:command] || @command_arguments.shift
      raise ":command is required" unless @command
    end
  end
end

Dir[File.join File.dirname(__FILE__), File.basename(__FILE__, '.*'), '*.rb'].each{ |lib| require lib }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_scheduler-0.1.0 lib/multi_scheduler.rb