lib/bolt/notifier.rb in marcinbunsch-bolt-0.1.10 vs lib/bolt/notifier.rb in marcinbunsch-bolt-0.2.0
- old
+ new
@@ -7,31 +7,41 @@
class Notifier
attr_accessor :selected
# Constructor
def initialize
- # find appropriate listener
- $stdout.puts "** Using #{notifier.class} \n"
-
- # launch appropriate listener
- # notifier.new
-
+ # find appropriate notifier
+ notifier
+ # present
+ $stdout.puts "** Using #{notifier.class} \n"
end
# Pick a listener to launch
def notifier
- return selected if selected
- self.selected= Bolt::Notifiers::Generic.new
- # growl
+ return selected if selected
+
+
+ if Bolt['notifier'] and ['generic', 'growl'].include?(Bolt['notifier'])
+ self.selected= Bolt::Notifiers::Growl.new if Bolt['notifier'] == 'growl'
+ self.selected= Bolt::Notifiers::Generic.new if Bolt['notifier'] == 'generic'
+ $stdout.puts "** Found 'notifier' setting in .bolt"
+ return self.selected
+ end
+
+ $stdout.puts "** Determining notifier... \n"
+
+ # default - growl (if growlnotify is present)
output = %x[which growlnotify]
- if output.to_s.include?('/growlnotify')
- self.selected= Bolt::Notifiers::Growl.new
+ if !Bolt['notifier'] and output.to_s.include?('/growlnotify')
+ self.selected= Bolt::Notifiers::Growl.new(:use_growlnotify => true)
end
- #self.selected= Bolt::Listeners::Generic
- # self.selected= Bolt::Listeners::OSX if os_string.include?("darwin")
- #self.selected= Bolt::Listeners::Windows if os_string.include?("mswin")
- #self.selected= Bolt::Listeners::Linux if os_string.include?("linux")
+
+ # default if else fails
+ if !selected
+ self.selected= Bolt::Notifiers::Generic.new
+ end
+
selected
end
end
-end
\ No newline at end of file
+end