# Copyright (C) 2011-2012 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 module RightConf # Provide progress report methods used by configurators module ProgressReporter # Create list of reporters upon inclusion # Also setup forwarders # # === Parameters # base(Object):: Object including this module def self.included(base) @@reporters ||= [] [ :report_section, :report, :report_check, :report_success, :report_failure, :report_error, :report_fatal, :report_result ].each do |meth| meta_def(meth) { |*args| @@reporters.each { |r| r.__send__(meth, *args) } } end end # Print progress reports to stdout, default behavior # # === Return # true:: Always return true def self.report_to_stdout @@reporters ||= [] @@reporters << StdoutReporter.new true end # Save progress reports to given file # # === Parameters # path(String):: Path to file where progress reports should be saved # # === Return # true:: Always return true def self.report_to_file(path) @@reporters ||= [] @@reporters << FileReporter.new(path) true end protected # Define method programmatically (a.k.a. meta-programming a.k.a use-sparingly) # # === Parameters # name(String):: Method name # blk(Proc):: Method implementation # # === Return # true:: Always return true def self.meta_def(name, &blk) self.instance_eval { define_method(name, &blk) } true end end end # Load all progress reporters Dir[File.join(File.dirname(__FILE__), 'progress_reporters', '*.rb')].sort.each { |r| require r }