Sha256: e7aecd2ad6ef857d2c7b9c53ac79e6a83f4c987bce247ad5caa09954425be25f

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

module Patriot
  module Command
    # a command which executes shell scripts
    #
    # == Example pbc
    #   sh {
    #     name "test"
    #     commands "echo '#{_date_}' > /tmp/test.out"
    #   }
    class ShCommand < Patriot::Command::Base
      include Patriot::Util::System

      declare_command_name :sh

      command_attr :connector => '&&'
      # @!attribute [w] commands
      #   [String, Array] commands to execute
      command_attr :commands do |cmd, a, v|
        cmd.commands = v.is_a?(Array)? v : [v]
      end
      # @!attribute [w] name
      #   [String] string to be a part of job id
      #   @see Patriot::Command::ShCommand#job_id
      # @!attribute [w] name_suffix
      #   [String] suffix string to be a part of job id
      #   @see Patriot::Command::ShCommand#job_id
      command_attr :name, :name_suffix
      validate_existence :name 

      # @see Patriot::Command::Base#job_id
      def job_id  
        return "#{command_name}_#{@name}_#{@name_suffix}"
      end

      # @see Patriot::Command::Base#configure
      def configure
        @name_suffix ||= _date_
        return self
      end

      # @see Patriot::Command::Base#description
      def description
        return @commands.join(@connector)
      end

      # @see Patriot::Command::Base#execute
      def execute
        @logger.info "start shell command "
        @commands.each do |c|
          execute_command(c)
        end
        @logger.info "end shell command "
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
patriot-workflow-scheduler-0.8.8 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.7 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.6 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.5 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.4 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.3 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.2 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.1 lib/patriot/command/sh_command.rb
patriot-workflow-scheduler-0.8.0 lib/patriot/command/sh_command.rb