Sha256: 433cb2036c3720e32b74c2cee9856a2c7c9f889859f39d99bda8435001cac450

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

require 'whenever/patches/job_list'

module Whenever
  class WebJobList < JobList
    include Enumerable
    attr_reader :set_variables, :job_types

    delegate :fetch, :each, to: :web_jobs

    def web_jobs
      @web_jobs ||= begin
        @jobs.flat_map do |interval, jobs|
          jobs.map do |job|
            WebJob.new(job, interval)
          end
        end
      end
    end

    def logs
      @logs ||= fetch_logs(@set_variables[:output])
    end

    alias_method :old_job_type, :job_type

    def job_type name, template
      (@job_types ||= {})[name] = template
      old_job_type name, template
    end

    protected

    def fetch_logs path, kind = 'standard'
      case path
      when Hash
        path.map{ |k, v| fetch_logs(v, k) }.inject(:merge)
      when String
        { kind.to_s => Log.new(kind, path) }
      else
        {}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whenever-web-0.0.5 app/models/whenever/web_job_list.rb