Skip to content
Browse files

Adds ability to override the color of 'pending' notifications to emacs

  • Loading branch information...
1 parent 767a79b commit 3de3c840c0d5e369547ec4324326807340ad4c25 @d1 committed
Showing with 17 additions and 8 deletions.
  1. +4 −8 lib/guard/notifiers/emacs.rb
  2. +13 −0 spec/guard/notifiers/emacs_spec.rb
View
12 lib/guard/notifiers/emacs.rb
@@ -42,6 +42,7 @@ def available?(silent = false)
# @param [Hash] options additional notification library options
# @option options [String] success the color to use for success notifications (default is 'ForestGreen')
# @option options [String] failed the color to use for failure notifications (default is 'Firebrick')
+ # @option options [String] pending the color to use for pending notifications
# @option options [String] default the default color to use (default is 'Black')
# @option options [String] client the client to use for notification (default is 'emacsclient')
# @option options [String, Integer] priority specify an int or named key (default is 0)
@@ -59,18 +60,13 @@ def notify(type, title, message, image, options = { })
# @param [Hash] options aditional notification options
# @option options [String] success the color to use for success notifications (default is 'ForestGreen')
# @option options [String] failed the color to use for failure notifications (default is 'Firebrick')
+ # @option options [String] pending the color to use for pending notifications
# @option options [String] default the default color to use (default is 'Black')
# @return [String] the name of the emacs color
#
def emacs_color(type, options = {})
- case type
- when 'success'
- options[:success] || DEFAULTS[:success]
- when 'failed'
- options[:failed] || DEFAULTS[:failed]
- else
- options[:default] || DEFAULTS[:default]
- end
+ default = options[:default] || DEFAULTS[:default]
+ options.fetch(type.to_sym, default)
end
end
end
View
13 spec/guard/notifiers/emacs_spec.rb
@@ -35,5 +35,18 @@ def self.show(options) end
subject.notify('success', 'any title', 'any message', 'any image', options)
end
end
+
+ context 'when a color option is specified for "pending" notifications' do
+ let(:options) { {:pending => 'Yellow'} }
+
+ it 'should set modeline color to the specified color using emacsclient' do
+ subject.should_receive(:system).with do |command|
+ command.should include("emacsclient")
+ command.should include("(set-face-background 'modeline \\\"Yellow\\\")")
+ end
+
+ subject.notify('pending', 'any title', 'any message', 'any image', options)
+ end
+ end
end
end

0 comments on commit 3de3c84

Please sign in to comment.
Something went wrong with that request. Please try again.