Sha256: 145069b5b1ee373febe65ac574a46052cb68990ba7c24035162f5e3285011298

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require 'psychic/runner/version'

autoload :YAML, 'yaml'

module Psychic
  autoload :Util,   'psychic/util'
  autoload :Logger, 'psychic/logger'
  autoload :Shell,  'psychic/shell'
  class Runner
    autoload :BaseRunner, 'psychic/runner/base_runner'
    autoload :SampleRunner, 'psychic/runner/sample_runner'
    autoload :HotRunner, 'psychic/runner/hot_runner'
    autoload :CompoundRunner, 'psychic/runner/compound_runner'
    autoload :ColdRunnerRegistry, 'psychic/runner/cold_runner_registry'
    class TaskNotImplementedError < NotImplementedError; end
    ColdRunnerRegistry.autoload_runners!

    include BaseRunner
    include SampleRunner
    attr_reader :runners, :hot_runner, :cold_runners

    def initialize(opts = { cwd: Dir.pwd })
      fail 'cwd is required' unless opts[:cwd]
      opts[:cwd] = Pathname(opts[:cwd]).to_s # must be a string on windows...
      super
      @hot_runner = HotRunner.new(opts)
      @cold_runners = ColdRunnerRegistry.active_runners(opts)
      @runners = [@hot_runner, @cold_runners].flatten
      @known_tasks = @runners.map(&:known_tasks).uniq
    end

    def [](task_name)
      runner = runners.find { |r| r.command_for_task(task_name) }
      return nil unless runner
      runner[task_name]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
psychic-runner-0.0.7 lib/psychic/runner.rb
psychic-runner-0.0.6 lib/psychic/runner.rb