Sha256: b847d0d8743e8e7ad27a05930b2133ae530c52d98c94c6e057da5dd3cac808ca

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

module Patriot
  module Command 
    # define a group of jobs
    class CommandGroup < Base
      declare_command_name :command_group
      declare_command_name :job_group
      attr_accessor :subcommands

      # @see Patriot::Command::Base#initialize
      def initialize(config)
        super
        @subcommands = []
      end

      # add a command to this group
      # @param cmd [Patriot::Command::Base] a command to be added to this group
      def add_subcommand(cmd)
        @subcommands << cmd
      end

      # configure thie group.
      # pass the required/produced products and parameters to the commands in this group
      # @see Patriot::Command::Base#configure
      # @return [Array<Patriot::Command::Base>] a list of commands in this group
      def configure
        return @subcommands.map{|cmd|
          cmd.require @requisites
          cmd.produce @products
          cmd.post_processors = @post_processors + (cmd.post_processors || []) unless @post_processors.nil?
          cmd.build(@param)
        }.flatten
      end

      # execute each command in this group
      # @see Patriot::Command::Base#execute
      def execute
        @subcommands.each do |k,v|
          v.execute
        end
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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