Class: Patriot::Command::CompositeCommand

Inherits:
CommandGroup show all
Defined in:
lib/patriot/command/composite.rb

Overview

a command which is composed of multiple sub commands

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

Attributes inherited from CommandGroup

#subcommands

Attributes inherited from Base

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

Instance Method Summary collapse

Methods inherited from CommandGroup

#add_subcommand, #initialize

Methods inherited from Base

#[], #_HH_, #_date_, #_hour_, #_month_, #add_post_processor, #add_subcommand, #build, #command_name, #configure_attr, #initialize, #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

This class inherits a constructor from Patriot::Command::CommandGroup

Instance Method Details

#configureObject

configure this composite command. pull up required/produced products from the sub commands

See Also:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/patriot/command/composite.rb', line 26

def configure
  @name_suffix ||= _date_
  # don't do flatten to handle nested composite commands
  @subcommands.map do |cmd|
    cmd = cmd.clone
    cmd.build(@param).each do |cmd|
      _validate_command(cmd)
      require cmd['requisites']
      produce cmd['products']
      @contained_commands << cmd
    end
  end
  return self
end

#descriptionObject

See Also:



17
18
19
20
21
# File 'lib/patriot/command/composite.rb', line 17

def description
  first_job = @contained_commands.first
  first_job = first_job.description unless first_job.nil?
  return "#{first_job} ... (#{@contained_commands.size} jobs)"
end

#executeObject

execute the contained commands

See Also:



43
44
45
46
47
# File 'lib/patriot/command/composite.rb', line 43

def execute
  @contained_commands.each do |c|
    c.execute
  end
end

#job_idString

Returns the identifier of this composite command.

Returns:

  • (String)

    the identifier of this composite command

See Also:



12
13
14
# File 'lib/patriot/command/composite.rb', line 12

def job_id
  return "#{command_name}_#{@name}_#{@name_suffix}"
end