Sha256: 6fd524600ed93c29945a92b2821aae2a587113dc9d7ae4adc60ebccd1523ff0a

Contents?: true

Size: 1006 Bytes

Versions: 6

Compression:

Stored size: 1006 Bytes

Contents

module Psychic
  class Runner
    module Cold
      class ShellScriptRunner
        include BaseRunner
        EXTENSIONS = ['.sh', '']
        magic_file 'scripts/*'
        register_runner

        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

        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

        def args_for_task(task)
          # HACK: Need a better way to deal with args
          '{{sample_file}}' if task == 'run_sample'
        end

        def active?
          true
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
psychic-runner-0.0.7 lib/psychic/runner/cold/shell_script_runner.rb
psychic-runner-0.0.6 lib/psychic/runner/cold/shell_script_runner.rb
psychic-runner-0.0.5 lib/psychic/runner/cold/shell_script_runner.rb
psychic-runner-0.0.4 lib/psychic/runner/cold/shell_script_runner.rb
psychic-runner-0.0.3 lib/psychic/runner/cold/shell_script_runner.rb
psychic-runner-0.0.2 lib/psychic/runner/cold/shell_script_runner.rb