Class: Psychic::Runner
- Inherits:
-
Object
- Object
- Psychic::Runner
- Includes:
- BaseRunner, SampleRunner
- Defined in:
- lib/psychic/task.rb,
lib/psychic/runner.rb,
lib/psychic/runner/cli.rb,
lib/psychic/runner/version.rb,
lib/psychic/runner/base_runner.rb,
lib/psychic/runner/code_helper.rb,
lib/psychic/runner/code_sample.rb,
lib/psychic/runner/sample_finder.rb,
lib/psychic/runner/sample_runner.rb,
lib/psychic/runner/magic_task_factory.rb,
lib/psychic/runner/hot_read_task_factory.rb,
lib/psychic/runner/task_factory_registry.rb,
lib/psychic/runner/factories/ruby_factories.rb,
lib/psychic/runner/factories/shell_script_factories.rb
Defined Under Namespace
Modules: BaseRunner, CodeHelper, Factories, SampleRunner Classes: CLI, CodeSample, HotReadTaskFactory, MagicTaskFactory, RunnerCLI, SampleFinder, Task, TaskFactoryRegistry, TaskNotImplementedError
Constant Summary collapse
- VERSION =
'0.0.8'
Constants included from BaseRunner
BaseRunner::DEFAULT_PARAMS_FILE
Constants included from Shell
Instance Attribute Summary collapse
-
#hot_read_task_factory ⇒ Object
readonly
Returns the value of attribute hot_read_task_factory.
-
#runners ⇒ Object
readonly
Returns the value of attribute runners.
-
#sample_factories ⇒ Object
readonly
Returns the value of attribute sample_factories.
-
#task_factories ⇒ Object
readonly
Returns the value of attribute task_factories.
Attributes included from BaseRunner
#cwd, #env, #hints, #known_tasks, #tasks
Instance Method Summary collapse
-
#initialize(opts = { cwd: Dir.pwd }) ⇒ Runner
constructor
rubocop:disable Metrics/MethodLength.
- #known_samples ⇒ Object
- #task_for(task_name) ⇒ Object
Methods included from SampleRunner
#find_sample, #interactive?, #process_parameters, #run_sample, #templated?
Methods included from BaseRunner
#active?, #build_task, #dry_run?, #execute, #execute_task, included, #known_task?
Methods included from Logger
#log_level=, #logger, #new_logger
Methods included from Shell
Constructor Details
#initialize(opts = { cwd: Dir.pwd }) ⇒ Runner
rubocop:disable Metrics/MethodLength
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/psychic/runner.rb', line 30 def initialize(opts = { cwd: Dir.pwd }) # rubocop:disable Metrics/MethodLength # TODO: Will reduce method length after further splitting Runner vs TaskFactory fail 'cwd is required' unless opts[:cwd] # must be a string on windows... opts[:cwd] = Pathname(opts[:cwd]).to_s @opts = opts init_attr(:cwd) { Dir.pwd } init_hints init_attr(:logger) { new_logger } init_attr(:env) { ENV.to_hash } init_attrs :cli, :interactive, :parameter_mode, :restore_mode, :dry_run @shell_opts = select_shell_opts @parameters = load_parameters(opts[:parameters]) # super @hot_read_task_factory = HotReadTaskFactory.new(opts) @sample_finder = SampleFinder.new(opts[:cwd], @hot_read_task_factory.hints['samples']) @task_factories = TaskFactoryRegistry.active_task_factories(opts) @runners = [@hot_read_task_factory, @task_factories].flatten @known_tasks = @runners.flat_map(&:known_tasks).uniq end |
Instance Attribute Details
#hot_read_task_factory ⇒ Object (readonly)
Returns the value of attribute hot_read_task_factory.
28 29 30 |
# File 'lib/psychic/runner.rb', line 28 def hot_read_task_factory @hot_read_task_factory end |
#runners ⇒ Object (readonly)
Returns the value of attribute runners.
28 29 30 |
# File 'lib/psychic/runner.rb', line 28 def runners @runners end |
#sample_factories ⇒ Object (readonly)
Returns the value of attribute sample_factories.
28 29 30 |
# File 'lib/psychic/runner.rb', line 28 def sample_factories @sample_factories end |
#task_factories ⇒ Object (readonly)
Returns the value of attribute task_factories.
28 29 30 |
# File 'lib/psychic/runner.rb', line 28 def task_factories @task_factories end |
Instance Method Details
#known_samples ⇒ Object
51 52 53 |
# File 'lib/psychic/runner.rb', line 51 def known_samples @sample_finder.known_samples end |
#task_for(task_name) ⇒ Object
55 56 57 58 59 |
# File 'lib/psychic/runner.rb', line 55 def task_for(task_name) runner = runners.find { |r| r.known_task?(task_name) } return nil unless runner runner.task_for(task_name) end |