added notifier listener and documentation on listener customization

This commit is contained in:
Nick Gauthier 2010-03-25 13:52:40 -04:00
parent 11f69fe9ba
commit 02cd1ee662
7 changed files with 61 additions and 4 deletions

View File

@ -132,6 +132,36 @@ Use ssh_opts to set the port or compression options.
The *directory* option is the path for the project directory The *directory* option is the path for the project directory
where the tests should be run. 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 == More Information
For more information on Hydra, check out the rdocs: For more information on Hydra, check out the rdocs:

BIN
hydra-icon-64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -26,12 +26,14 @@ Gem::Specification.new do |s|
"TODO", "TODO",
"VERSION", "VERSION",
"caliper.yml", "caliper.yml",
"hydra-icon-64x64.png",
"hydra.gemspec", "hydra.gemspec",
"hydra_gray.png", "hydra_gray.png",
"lib/hydra.rb", "lib/hydra.rb",
"lib/hydra/hash.rb", "lib/hydra/hash.rb",
"lib/hydra/listener/abstract.rb", "lib/hydra/listener/abstract.rb",
"lib/hydra/listener/minimal_output.rb", "lib/hydra/listener/minimal_output.rb",
"lib/hydra/listener/notifier.rb",
"lib/hydra/listener/report_generator.rb", "lib/hydra/listener/report_generator.rb",
"lib/hydra/master.rb", "lib/hydra/master.rb",
"lib/hydra/message.rb", "lib/hydra/message.rb",

View File

@ -10,5 +10,6 @@ require 'hydra/master'
require 'hydra/listener/abstract' require 'hydra/listener/abstract'
require 'hydra/listener/minimal_output' require 'hydra/listener/minimal_output'
require 'hydra/listener/report_generator' require 'hydra/listener/report_generator'
require 'hydra/listener/notifier'

View File

@ -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

View File

@ -38,6 +38,11 @@ module Hydra #:nodoc:
@workers = [] @workers = []
@listeners = [] @listeners = []
@event_listeners = Array(opts.fetch('listeners') { nil } ) @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 } @verbose = opts.fetch('verbose') { false }
@autosort = opts.fetch('autosort') { true } @autosort = opts.fetch('autosort') { true }
@sync = opts.fetch('sync') { nil } @sync = opts.fetch('sync') { nil }

View File

@ -19,16 +19,18 @@ module Hydra #:nodoc:
# If not set, it will check 'hydra.yml' and 'config/hydra.yml' # If not set, it will check 'hydra.yml' and 'config/hydra.yml'
attr_accessor :config 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. # Automatically sort files using their historical runtimes.
# Defaults to true # Defaults to true
# To disable: # To disable:
# t.autosort = false # t.autosort = false
attr_accessor :autosort 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 # Search for the hydra config file
def find_config_file def find_config_file