Sha256: 56b0a19bc1b49919107c56cc65576360a27253f134ef12634135c8bd734d328d

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

#
# Bolt::Notifier
#
# The Notifier sends notification of the test results to the user
#
module Bolt
  class Notifier
    attr_accessor :selected
    
    # Constructor
    def initialize 
      # find appropriate notifier
      notifier
      # present
      $stdout.puts "** Using #{notifier.class} \n" if Bolt['verbose']
    end

    # Pick a listener to launch
    def notifier
      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'
        self.selected= Bolt::Notifiers::NotifyOsd.new if Bolt['notifier'] == 'notify_send'
        $stdout.puts "** Found 'notifier' setting in .bolt" if Bolt['verbose']
        return self.selected
      end
      
      $stdout.puts "** Determining notifier... \n" if Bolt['verbose']
      
      # default - growl (if growlnotify is present)
      output = %x[which growlnotify]
      if !Bolt['notifier'] and output.to_s.include?('/growlnotify')
        self.selected= Bolt::Notifiers::Growl.new(:use_growlnotify => true)        
      end
      
      output = %x[which notify-send]
      if !Bolt['notifier'] and output.to_s.include?('/notify-send')
        self.selected= Bolt::Notifiers::NotifyOsd.new     
      end
      
      # default if else fails
      if !selected
        self.selected= Bolt::Notifiers::Generic.new
      end

      selected
    end
   
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marcinbunsch-bolt-0.2.4 lib/bolt/notifier.rb
marcinbunsch-bolt-0.2.5 lib/bolt/notifier.rb
marcinbunsch-bolt-0.2.6 lib/bolt/notifier.rb