Class: Patriot::Command::CommandGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/patriot/command/command_group.rb

Overview

define a group of jobs

Direct Known Subclasses

CompositeCommand

Constant Summary

Constants included from Util::Config

Util::Config::ADMIN_USER_KEY, Util::Config::DEFAULT_CONFIG, Util::Config::DEFAULT_PLUGIN_DIR, Util::Config::INFO_SERVER_PORT_KEY, Util::Config::PASSWORD_KEY, Util::Config::PLUGIN_DIR_KEY, Util::Config::PLUGIN_INIT_SCRIPT, Util::Config::PLUGIN_KEY, Util::Config::PLUGIN_LIB_DIR, Util::Config::USERNAME_KEY, Util::Config::WORKER_HOST_KEY, Util::Config::WORKER_USER_KEY

Instance Attribute Summary collapse

Attributes inherited from Base

#config, #parser, #post_processors, #start_datetime, #target_datetime, #test_mode

Instance Method Summary collapse

Methods inherited from Base

#[], #_HH_, #_date_, #_hour_, #_month_, #add_post_processor, #build, #command_name, #configure_attr, #description, #job_id, #param, #produce, #require, #skip, #start_date_time, #suspend, #to_job, #validate_command_attrs

Methods included from CommandMacro

#add_dsl_function, #command_attr, #command_attrs, #declare_command_name, #private_command_attr, #serde_attrs, #validate_attr, #validate_existence, #validation_logics, #volatile_attr, #volatile_attrs

Methods included from Util::Logger

#create_logger

Methods included from Util::Config

#load_config, #load_plugins

Methods included from Util::DateUtil

#date_add, #date_add_year, #date_format, #date_sub, #date_sub_year, #date_to_month, #days_of_month, #days_of_month_until, #days_of_week, #hours, #month_add, #month_sub, #to_date_obj, #to_end_of_last_month, #to_end_of_month, #to_month, #to_start_of_month

Methods included from Util::Param

#eval_attr, #eval_string_attr

Methods included from Parser

#batch_macro, #import_erb_config, #load_macro, #new_command, #parse

Constructor Details

#initialize(config) ⇒ CommandGroup

Returns a new instance of CommandGroup.

See Also:



10
11
12
13
# File 'lib/patriot/command/command_group.rb', line 10

def initialize(config)
  super
  @subcommands = []
end

Instance Attribute Details

#subcommandsObject

Returns the value of attribute subcommands.



7
8
9
# File 'lib/patriot/command/command_group.rb', line 7

def subcommands
  @subcommands
end

Instance Method Details

#add_subcommand(cmd) ⇒ Object

add a command to this group

Parameters:



17
18
19
# File 'lib/patriot/command/command_group.rb', line 17

def add_subcommand(cmd)
  @subcommands << cmd
end

#configureArray<Patriot::Command::Base>

configure thie group. pass the required/produced products and parameters to the commands in this group

Returns:

See Also:



25
26
27
28
29
30
31
32
# File 'lib/patriot/command/command_group.rb', line 25

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

#executeObject

execute each command in this group

See Also:



36
37
38
39
40
# File 'lib/patriot/command/command_group.rb', line 36

def execute
  @subcommands.each do |k,v|
    v.execute
  end
end