Sha256: ae512695543e965eeb7cd728581a72254744a0a99d6dc38c0dec502a1fe3cdc0

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

# 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 new progress report section
    #
    # === Parameters
    # section(String):: Section title
    #
    # === Return
    # text(String):: Formatted text
    def format_section(section)
      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)
      text = super(check)
    end

    # Format check success
    #
    # === Return
    # text(String):: Formatted text
    def format_success
      text = super.blue
    end

    # Format check failure
    #
    # === Return
    # text(String):: Formatted text
    def format_failure
      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


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rconf-0.5.1 lib/rconf/progress_reporters/stdout_reporter.rb
rconf-0.5.0 lib/rconf/progress_reporters/stdout_reporter.rb