diff --git a/README.rdoc b/README.rdoc index 3c651fc..fe6d733 100644 --- a/README.rdoc +++ b/README.rdoc @@ -132,6 +132,36 @@ Use ssh_opts to set the port or compression options. The *directory* option is the path for the project directory where the tests should be run. +=== Using Hydra::Listeners + +Hydra comes with a couple of listeners for the events it fires. By +default, Hydra::Listener::MinimalOutput is used to display the +files being tests and the ./F/E for each file and F/E output. + +It also uses Hydra::Listener::ReportGenerator to generate reports +of the test files to that it can order them by their run times. + +To use another listener, just add a listeners node to the config file. +For example, if you are on Ubuntu Linux (or have access to the +notify-send command) you can add a notifier listener like this: + + listeners: + - Hydra::Listener::Notifier.new + +Note that if you make a listener node, the default listeners will be +overridden, so you will no longer have the standard minimal output +unless you do: + + listeners: + - Hydra::Listener::Notifier.new + - Hydra::Listener::MinimalOutput.new + +Listeners take one argument to their contstructor: an IO object. So, +you can easily output Hydra to a variety of log files. For example: + + listeners: + - Hydra::Listener::ReportGenerator.new(File.new('/home/ngauthier/Desktop/hydra_log.yml', 'w')) + == More Information For more information on Hydra, check out the rdocs: diff --git a/hydra-icon-64x64.png b/hydra-icon-64x64.png new file mode 100644 index 0000000..2a2bb3e Binary files /dev/null and b/hydra-icon-64x64.png differ diff --git a/hydra.gemspec b/hydra.gemspec index 7be199c..98c9f5f 100644 --- a/hydra.gemspec +++ b/hydra.gemspec @@ -26,12 +26,14 @@ Gem::Specification.new do |s| "TODO", "VERSION", "caliper.yml", + "hydra-icon-64x64.png", "hydra.gemspec", "hydra_gray.png", "lib/hydra.rb", "lib/hydra/hash.rb", "lib/hydra/listener/abstract.rb", "lib/hydra/listener/minimal_output.rb", + "lib/hydra/listener/notifier.rb", "lib/hydra/listener/report_generator.rb", "lib/hydra/master.rb", "lib/hydra/message.rb", diff --git a/lib/hydra.rb b/lib/hydra.rb index f7179de..1d81077 100644 --- a/lib/hydra.rb +++ b/lib/hydra.rb @@ -10,5 +10,6 @@ require 'hydra/master' require 'hydra/listener/abstract' require 'hydra/listener/minimal_output' require 'hydra/listener/report_generator' +require 'hydra/listener/notifier' diff --git a/lib/hydra/listener/notifier.rb b/lib/hydra/listener/notifier.rb new file mode 100644 index 0000000..9e29b0a --- /dev/null +++ b/lib/hydra/listener/notifier.rb @@ -0,0 +1,17 @@ +module Hydra #:nodoc: + module Listener #:nodoc: + # Sends a command to Notifier when the testing has finished + # http://manpages.ubuntu.com/manpages/gutsy/man1/notify-send.1.html + class Notifier < Hydra::Listener::Abstract + # output a finished notification + def testing_end + icon_path = File.join( + File.dirname(__FILE__), '..', '..', '..', + 'hydra-icon-64x64.png' + ) + `notify-send -i #{icon_path} "Hydra" "Testing Completed"` + end + end + end +end + diff --git a/lib/hydra/master.rb b/lib/hydra/master.rb index 96da462..1bd1efd 100644 --- a/lib/hydra/master.rb +++ b/lib/hydra/master.rb @@ -38,6 +38,11 @@ module Hydra #:nodoc: @workers = [] @listeners = [] @event_listeners = Array(opts.fetch('listeners') { nil } ) + @event_listeners.select{|l| l.is_a? String}.each do |l| + @event_listeners.delete_at(@event_listeners.index(l)) + listener = eval(l) + @event_listeners << listener if listener.is_a?(Hydra::Listener::Abstract) + end @verbose = opts.fetch('verbose') { false } @autosort = opts.fetch('autosort') { true } @sync = opts.fetch('sync') { nil } diff --git a/lib/hydra/tasks.rb b/lib/hydra/tasks.rb index 5fe904c..666c421 100644 --- a/lib/hydra/tasks.rb +++ b/lib/hydra/tasks.rb @@ -19,16 +19,18 @@ module Hydra #:nodoc: # If not set, it will check 'hydra.yml' and 'config/hydra.yml' attr_accessor :config - # Set to true if you want hydra to generate a report. - # Defaults to false - attr_accessor :report - # Automatically sort files using their historical runtimes. # Defaults to true # To disable: # t.autosort = false attr_accessor :autosort + # Event listeners. Defaults to the MinimalOutput listener. + # You can add additional listeners if you'd like. For example, + # on linux (with notify-send) you can add the notifier listener: + # t.listeners << Hydra::Listener::Notifier.new + attr_accessor :listeners + # # Search for the hydra config file def find_config_file