Class: Psychic::Runner::Factories::ShellScriptTaskFactory
- Inherits:
-
MagicTaskFactory
- Object
- MagicTaskFactory
- Psychic::Runner::Factories::ShellScriptTaskFactory
- Includes:
- BaseRunner
- Defined in:
- lib/psychic/runner/factories/shell_script_factories.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, #tasks
Attributes inherited from MagicTaskFactory
#cwd, #env, #hints, #known_tasks, #tasks
Instance Method Summary collapse
- #active? ⇒ Boolean
- #args_for_task(task) ⇒ Object
-
#initialize(opts) ⇒ ShellScriptTaskFactory
constructor
A new instance of ShellScriptTaskFactory.
- #task_for(task_name) ⇒ Object
Methods included from BaseRunner
#build_task, #dry_run?, #execute, #execute_task, included, #known_task?
Methods included from Logger
#log_level=, #logger, #new_logger
Methods included from Shell
Methods inherited from MagicTaskFactory
#build_task, #known_task?, known_tasks, magic_env_var, magic_env_vars, magic_file, magic_file_patterns, register_task_factory, task, tasks
Constructor Details
#initialize(opts) ⇒ ShellScriptTaskFactory
Returns a new instance of ShellScriptTaskFactory.
10 11 12 13 14 15 |
# File 'lib/psychic/runner/factories/shell_script_factories.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 |
Instance Method Details
#active? ⇒ Boolean
32 33 34 |
# File 'lib/psychic/runner/factories/shell_script_factories.rb', line 32 def active? true end |
#args_for_task(task) ⇒ Object
27 28 29 30 |
# File 'lib/psychic/runner/factories/shell_script_factories.rb', line 27 def args_for_task(task) # HACK: Need a better way to deal with args '{{sample_file}}' if task == 'run_sample' end |
#task_for(task_name) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/psychic/runner/factories/shell_script_factories.rb', line 17 def task_for(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 |