Class: RightConf::BaseReporter
- Inherits:
-
Object
- Object
- RightConf::BaseReporter
- Defined in:
- lib/rconf/progress_reporters/base_reporter.rb
Overview
Common base to all progress reporters
Reporters expose the following report methods whose default implementations can be overridden in descendants:
- report_message
-
Standard progress report message
- report_section
-
Title
- report_error
-
Non fatal error
- report_fatal
-
Fatal error, will raise after reporting message
- report_check
-
Report a check being done on system, should be followed by
- report_success
-
Report check success
- report_failure
-
Report check failure
- report_result
-
Report check success or failure depending on argument
Alternatively reporters can override any associated formatting method (:format_message, :format_section, etc.) and/or the :write method used to write the progress report.
Direct Known Subclasses
Instance Method Summary collapse
-
#method_missing(meth, *args) ⇒ Object
Report methods are associated with formatting methods Call the formatting method then call the reporter ‘write’ method Reporters can override any formatting method and/or the write method.
-
#report_result(res) ⇒ Object
Report success or failure.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
Report methods are associated with formatting methods Call the formatting method then call the reporter ‘write’ method Reporters can override any formatting method and/or the write method
Parameters
- meth(Symbol)
-
Reporting method
- args(Array)
-
Arguments
Return
- true
-
Always return true
Raise
- (Exception)
-
If there is no formatting method
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rconf/progress_reporters/base_reporter.rb', line 46 def method_missing(meth, *args) # Shortcut for standard progress report message meth = :report_message if meth == :report if meth.to_s =~ /^report_([a-zA-Z]+)$/ format_method = "format_#{Regexp.last_match[1]}".to_s if self.respond_to?(format_method) text = self.__send__(format_method, *args) write(text) exit 1 if Regexp.last_match[1] == 'fatal' else super(meth, *args) end else super(meth, *args) end end |
Instance Method Details
#report_result(res) ⇒ Object
Report success or failure
Parameters
- res(TrueClass|FalseClass)
-
true for success, false for failure
Return
- true
-
Always return true
70 71 72 |
# File 'lib/rconf/progress_reporters/base_reporter.rb', line 70 def report_result(res) res ? report_success : report_failure end |