Class: Psychic::Runner::Cold::ShellScriptRunner
- Inherits:
-
Object
- Object
- Psychic::Runner::Cold::ShellScriptRunner
- Includes:
- BaseRunner
- Defined in:
- lib/psychic/runner/cold/shell_script_runner.rb
Constant Summary collapse
- EXTENSIONS =
['.sh', '']
Constants included from BaseRunner
BaseRunner::DEFAULT_PARAMS_FILE
Constants included from Shell
Instance Attribute Summary
Attributes included from BaseRunner
#cwd, #env, #hints, #known_tasks
Instance Method Summary collapse
- #[](task_name) ⇒ Object
- #active? ⇒ Boolean
- #args_for_task(task) ⇒ Object
-
#initialize(opts) ⇒ ShellScriptRunner
constructor
A new instance of ShellScriptRunner.
Methods included from BaseRunner
#command_for_task, #dry_run?, #execute, #execute_task, included, #method_missing, #respond_to_missing?
Methods included from Logger
#log_level=, #logger, #new_logger
Methods included from Shell
Constructor Details
#initialize(opts) ⇒ ShellScriptRunner
Returns a new instance of ShellScriptRunner.
10 11 12 13 14 15 |
# File 'lib/psychic/runner/cold/shell_script_runner.rb', line 10 def initialize(opts) super @known_tasks = Dir["#{@cwd}/scripts/*"].map do | script | File.basename(script, File.extname(script)) if EXTENSIONS.include?(File.extname(script)) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Psychic::Runner::BaseRunner
Instance Method Details
#[](task_name) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/psychic/runner/cold/shell_script_runner.rb', line 17 def [](task_name) task = task_name.to_s script = Dir["#{@cwd}/scripts/#{task}{.sh,}"].first if script cmd = Psychic::Util.relativize(script, @cwd) cmd = [cmd, args_for_task(task_name)].compact.join(' ') "./#{cmd}" unless cmd.to_s.start_with? '/' end end |
#active? ⇒ Boolean
32 33 34 |
# File 'lib/psychic/runner/cold/shell_script_runner.rb', line 32 def active? true end |
#args_for_task(task) ⇒ Object
27 28 29 30 |
# File 'lib/psychic/runner/cold/shell_script_runner.rb', line 27 def args_for_task(task) # HACK: Need a better way to deal with args '{{sample_file}}' if task == 'run_sample' end |