Module: CLIUtils::Messenging
- Includes:
- PrettyIO
- Defined in:
- lib/cliutils/messenging.rb
Overview
CLIMessenger Module
Outputs color-coordinated messages to a CLI
======================================================
Class Method Summary (collapse)
-
+ (Object) included(k)
Methods ==================================================== —————————————————- included method.
Instance Method Summary (collapse)
-
- (Object) default_instance
—————————————————- default_instance method.
-
- (Object) messenger
—————————————————- messenger method.
Methods included from PrettyIO
#color_chart, #debug, #error, #info, #info_block, #log, #prompt, #section, #section_block, #success, #warn, wrap, wrap_at, wrap_limit
Class Method Details
+ (Object) included(k)
Methods
====================================================
----------------------------------------------------
included method
Hook called when this module gets mixed in; extends
the includer with the methods defined here.
@param k The includer
@return Void
----------------------------------------------------
20 21 22 |
# File 'lib/cliutils/messenging.rb', line 20 def self.included(k) k.extend(self) end |
Instance Method Details
- (Object) default_instance
default_instance method
Returns a default instance of LoggerDelegator that
delegates to STDOUT only.
@return LoggerDelegator
----------------------------------------------------
31 32 33 34 35 36 37 38 |
# File 'lib/cliutils/messenging.rb', line 31 def default_instance stdout_logger = Logger.new(STDOUT) stdout_logger.formatter = proc do |severity, datetime, progname, msg| send(severity.downcase, msg) end LoggerDelegator.new(stdout_logger) end |
- (Object) messenger
messenger method
Singleton method to return (or initialize, if needed)
a LoggerDelegator.
@return LoggerDelegator
----------------------------------------------------
47 48 49 |
# File 'lib/cliutils/messenging.rb', line 47 def messenger @messenger ||= default_instance end |