Class: Guard::Sass::Formatter
- Inherits:
-
Object
- Object
- Guard::Sass::Formatter
- Defined in:
- lib/guard/sass/formatter.rb
Overview
The formatter handles providing output to the user.
Instance Method Summary collapse
-
#error(msg, opts = {}) ⇒ Object
Show an error message and notification.
-
#initialize(opts = {}) ⇒ Formatter
constructor
A new instance of Formatter.
-
#notify(msg, opts = {}) ⇒ Object
Show a system notification.
-
#success(msg, opts = {}) ⇒ Object
Show a success message and notification if successes are being shown.
Constructor Details
#initialize(opts = {}) ⇒ Formatter
Returns a new instance of Formatter.
10 11 12 |
# File 'lib/guard/sass/formatter.rb', line 10 def initialize(opts={}) @hide_success = opts.fetch(:hide_success, false) end |
Instance Method Details
#error(msg, opts = {}) ⇒ Object
Show an error message and notification.
33 34 35 36 |
# File 'lib/guard/sass/formatter.rb', line 33 def error(msg, opts={}) ::Guard::UI.error("[Sass] #{msg}", opts) notify(opts[:notification], :image => :failed) end |
#notify(msg, opts = {}) ⇒ Object
Show a system notification.
42 43 44 |
# File 'lib/guard/sass/formatter.rb', line 42 def notify(msg, opts={}) ::Guard::Notifier.notify(msg, ({:title => "Guard::Sass"}).merge(opts)) end |
#success(msg, opts = {}) ⇒ Object
Show a success message and notification if successes are being shown.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/guard/sass/formatter.rb', line 18 def success(msg, opts={}) unless @hide_success benchmark = nil if time = opts.delete(:time) benchmark = "[\e[33m%2.2fs\e[0m] " % time end ::Guard::UI.info("\t\e[1;37mSass\e[0m %s%s" % [benchmark, msg], opts) notify(opts[:notification], :image => :success) end end |