Indent logging output on nested tasks
This commit is contained in:
parent
2d4e04b2e5
commit
85ee79ab88
@ -13,3 +13,8 @@ Feature: nested tasks
|
|||||||
Scenario: applies nested tasks
|
Scenario: applies nested tasks
|
||||||
When I successfully execute the recipe
|
When I successfully execute the recipe
|
||||||
Then the output must match /\AOK/
|
Then the output must match /\AOK/
|
||||||
|
|
||||||
|
Scenario: indents logging from nested tasks
|
||||||
|
When I successfully execute the recipe with option -v
|
||||||
|
Then the output must match /^ Task:.+/
|
||||||
|
And the output must match /^ action:.+/
|
||||||
|
@ -14,21 +14,29 @@ module Producer
|
|||||||
tasks.each { |t| process_task t }
|
tasks.each { |t| process_task t }
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_task(task)
|
def process_task(task, indent_level = 0)
|
||||||
if task.condition_met?
|
if task.condition_met?
|
||||||
@env.log "Task: `#{task}' applying..."
|
log "Task: `#{task}' applying...", indent_level
|
||||||
task.actions.each do |e|
|
task.actions.each do |e|
|
||||||
case e
|
case e
|
||||||
when Task then process_task e
|
when Task then process_task e, indent_level + 2
|
||||||
else
|
else
|
||||||
@env.log " action: #{e}"
|
log " action: #{e}", indent_level
|
||||||
e.apply unless @env.dry_run?
|
e.apply unless @env.dry_run?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@env.log "Task: `#{task}' skipped"
|
log "Task: `#{task}' skipped", indent_level
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def log(message, indent_level)
|
||||||
|
message = [' ' * indent_level, message].join
|
||||||
|
@env.log message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user