Module: GemHadar::Warn
- Includes:
- Term::ANSIColor
- Included in:
- GemHadar, SimpleCov, SimpleCov::ContextFormatter
- Defined in:
- lib/gem_hadar/warn.rb
Overview
A module that provides warning functionality with colored output.
This module enhances the standard warn method to display warning messages in orange color, making them more visible in terminal outputs. It is designed to be included in classes that need consistent warning message formatting throughout the application.
Instance Method Summary collapse
-
#fail(*msgs) ⇒ void
The fail method formats and displays failure messages using red colored output.
-
#warn(*msgs) ⇒ Object
The warn method displays warning messages using orange colored output.
Instance Method Details
#fail(*msgs) ⇒ void
This method returns an undefined value.
The fail method formats and displays failure messages using red colored output.
This method takes an array of message objects, applies red color formatting to string representations of the messages, and then passes them to the superclass’s fail method for display. The uplevel: 1 option ensures that the failure message originates from the caller’s context rather than from within this method itself.
48 49 50 51 52 53 |
# File 'lib/gem_hadar/warn.rb', line 48 def fail(*msgs) msgs.map! do |a| a.respond_to?(:to_str) ? color(196) { a.to_str } : a end super(*msgs) end |
#warn(*msgs) ⇒ Object
The warn method displays warning messages using orange colored output.
This method takes an array of message strings, applies orange color formatting to each message, and then passes them to the superclass’s warn method for display. The uplevel: 1 option ensures that the warning originates from the caller’s context rather than from within this method itself.
30 31 32 33 34 35 |
# File 'lib/gem_hadar/warn.rb', line 30 def warn(*msgs) msgs.map! do |a| a.respond_to?(:to_str) ? color(208) { a.to_str } : a end super(*msgs, uplevel: 1) end |