# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide. # # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use, # reproduction, modification, or disclosure of this program is # strictly prohibited. Any use of this program by an authorized # licensee is strictly subject to the terms and conditions, # including confidentiality obligations, set forth in the applicable # License Agreement between RightScale.com, Inc. and # the licensee $stdout.sync = true module RightConf # STDOUT progress reporter, logs progress to console class StdoutReporter < BaseReporter # Print given text to STDOUT # # === Parameters # text(String):: Text to be printed # # === Return # true:: Always return true def write(text) $stdout.print(text) true end # Format standard message # # === Parameters # message(String):: Message # # === Return # text(String):: Formatted text def format_message(msg) text = @in_check ? "\n" : '' text += super(msg) @in_check = false text end # Format new progress report section # # === Parameters # section(String):: Section title # # === Return # text(String):: Formatted text def format_section(section) @in_check = false text = super(section).green end # Format check, should be followed by +report_success+ or +report_failure+ # # === Parameters # check(String):: Check title # # === Return # text(String):: Formatted text def format_check(check) @in_check = true text = super(check) end # Format check success # # === Return # text(String):: Formatted text def format_success @in_check = false text = super.blue end # Format check failure # # === Return # text(String):: Formatted text def format_failure @in_check = false text = super.red end # Format fatal error and raise exception to stop execution # # === Return # text(String):: Formatted text def format_fatal(error) text = super.split("\n") text[0] = text[0].red.bold text[1] = text[1].red.bold if text.size > 1 text.join("\n") + "\n" end end end