Class: Discharger::SetupRunner::Commands::CustomCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Discharger::SetupRunner::Commands::CustomCommand
show all
- Defined in:
- lib/discharger/setup_runner/commands/custom_command.rb
Instance Attribute Summary collapse
Attributes inherited from BaseCommand
#app_root, #config, #logger
Instance Method Summary
collapse
Constructor Details
#initialize(config, app_root, logger, step_config) ⇒ CustomCommand
Returns a new instance of CustomCommand.
11
12
13
14
|
# File 'lib/discharger/setup_runner/commands/custom_command.rb', line 11
def initialize(config, app_root, logger, step_config)
super(config, app_root, logger)
@step_config = step_config
end
|
Instance Attribute Details
#step_config ⇒ Object
Returns the value of attribute step_config.
9
10
11
|
# File 'lib/discharger/setup_runner/commands/custom_command.rb', line 9
def step_config
@step_config
end
|
Instance Method Details
#can_execute? ⇒ Boolean
31
32
33
|
# File 'lib/discharger/setup_runner/commands/custom_command.rb', line 31
def can_execute?
step_config["command"].present?
end
|
#description ⇒ Object
35
36
37
|
# File 'lib/discharger/setup_runner/commands/custom_command.rb', line 35
def description
step_config["description"] || "Custom command: #{step_config["command"]}"
end
|
#execute ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/discharger/setup_runner/commands/custom_command.rb', line 16
def execute
command = step_config["command"]
description = step_config["description"] || command
condition = step_config["condition"]
if condition && !ConditionEvaluator.evaluate(condition)
log "Skipping #{description} (condition not met)"
return
end
log "Running: #{description}"
system!(command)
end
|