hydra 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,6 +132,36 @@ Use ssh_opts to set the port or compression options.
132
132
  The *directory* option is the path for the project directory
133
133
  where the tests should be run.
134
134
 
135
+ === Using Hydra::Listeners
136
+
137
+ Hydra comes with a couple of listeners for the events it fires. By
138
+ default, Hydra::Listener::MinimalOutput is used to display the
139
+ files being tests and the ./F/E for each file and F/E output.
140
+
141
+ It also uses Hydra::Listener::ReportGenerator to generate reports
142
+ of the test files to that it can order them by their run times.
143
+
144
+ To use another listener, just add a listeners node to the config file.
145
+ For example, if you are on Ubuntu Linux (or have access to the
146
+ notify-send command) you can add a notifier listener like this:
147
+
148
+ listeners:
149
+ - Hydra::Listener::Notifier.new
150
+
151
+ Note that if you make a listener node, the default listeners will be
152
+ overridden, so you will no longer have the standard minimal output
153
+ unless you do:
154
+
155
+ listeners:
156
+ - Hydra::Listener::Notifier.new
157
+ - Hydra::Listener::MinimalOutput.new
158
+
159
+ Listeners take one argument to their contstructor: an IO object. So,
160
+ you can easily output Hydra to a variety of log files. For example:
161
+
162
+ listeners:
163
+ - Hydra::Listener::ReportGenerator.new(File.new('/home/ngauthier/Desktop/hydra_log.yml', 'w'))
164
+
135
165
  == More Information
136
166
 
137
167
  For more information on Hydra, check out the rdocs:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.0
1
+ 0.14.0
Binary file
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hydra}
8
- s.version = "0.13.0"
8
+ s.version = "0.14.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nick Gauthier"]
@@ -26,12 +26,15 @@ Gem::Specification.new do |s|
26
26
  "TODO",
27
27
  "VERSION",
28
28
  "caliper.yml",
29
+ "hydra-icon-64x64.png",
29
30
  "hydra.gemspec",
30
31
  "hydra_gray.png",
31
32
  "lib/hydra.rb",
32
33
  "lib/hydra/hash.rb",
33
34
  "lib/hydra/listener/abstract.rb",
34
35
  "lib/hydra/listener/minimal_output.rb",
36
+ "lib/hydra/listener/notifier.rb",
37
+ "lib/hydra/listener/progress_bar.rb",
35
38
  "lib/hydra/listener/report_generator.rb",
36
39
  "lib/hydra/master.rb",
37
40
  "lib/hydra/message.rb",
@@ -10,5 +10,6 @@ require 'hydra/master'
10
10
  require 'hydra/listener/abstract'
11
11
  require 'hydra/listener/minimal_output'
12
12
  require 'hydra/listener/report_generator'
13
-
13
+ require 'hydra/listener/notifier'
14
+ require 'hydra/listener/progress_bar'
14
15
 
@@ -0,0 +1,17 @@
1
+ module Hydra #:nodoc:
2
+ module Listener #:nodoc:
3
+ # Sends a command to Notifier when the testing has finished
4
+ # http://manpages.ubuntu.com/manpages/gutsy/man1/notify-send.1.html
5
+ class Notifier < Hydra::Listener::Abstract
6
+ # output a finished notification
7
+ def testing_end
8
+ icon_path = File.join(
9
+ File.dirname(__FILE__), '..', '..', '..',
10
+ 'hydra-icon-64x64.png'
11
+ )
12
+ `notify-send -i #{icon_path} "Hydra" "Testing Completed"`
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,48 @@
1
+ module Hydra #:nodoc:
2
+ module Listener #:nodoc:
3
+ # Output a progress bar as files are completed
4
+ class ProgressBar < Hydra::Listener::Abstract
5
+ # Store the total number of files
6
+ def testing_begin(files)
7
+ @total_files = files.size
8
+ @files_completed = 0
9
+ @test_output = ""
10
+ @errors = false
11
+ render_progress_bar
12
+ end
13
+
14
+ # Increment completed files count and update bar
15
+ def file_end(file, output)
16
+ unless output == '.'
17
+ @output.write "\r#{' '*60}\r#{output}\n"
18
+ @errors = true
19
+ end
20
+ @files_completed += 1
21
+ render_progress_bar
22
+ end
23
+
24
+ # Break the line
25
+ def testing_end
26
+ render_progress_bar
27
+ @output.write "\n"
28
+ end
29
+
30
+ private
31
+
32
+ def render_progress_bar
33
+ width = 30
34
+ complete = ((@files_completed.to_f / @total_files.to_f) * width).to_i
35
+ @output.write "\r" # move to beginning
36
+ @output.write 'Progress ['
37
+ @output.write @errors ? "\033[1;31m" : "\033[1;32m"
38
+ complete.times{@output.write '#'}
39
+ @output.write '>'
40
+ (width-complete).times{@output.write ' '}
41
+ @output.write "\033[0m"
42
+ @output.write "] #{@files_completed}/#{@total_files}"
43
+ @output.flush
44
+ end
45
+ end
46
+ end
47
+ end
48
+
@@ -38,6 +38,11 @@ module Hydra #:nodoc:
38
38
  @workers = []
39
39
  @listeners = []
40
40
  @event_listeners = Array(opts.fetch('listeners') { nil } )
41
+ @event_listeners.select{|l| l.is_a? String}.each do |l|
42
+ @event_listeners.delete_at(@event_listeners.index(l))
43
+ listener = eval(l)
44
+ @event_listeners << listener if listener.is_a?(Hydra::Listener::Abstract)
45
+ end
41
46
  @verbose = opts.fetch('verbose') { false }
42
47
  @autosort = opts.fetch('autosort') { true }
43
48
  @sync = opts.fetch('sync') { nil }
@@ -19,16 +19,18 @@ module Hydra #:nodoc:
19
19
  # If not set, it will check 'hydra.yml' and 'config/hydra.yml'
20
20
  attr_accessor :config
21
21
 
22
- # Set to true if you want hydra to generate a report.
23
- # Defaults to false
24
- attr_accessor :report
25
-
26
22
  # Automatically sort files using their historical runtimes.
27
23
  # Defaults to true
28
24
  # To disable:
29
25
  # t.autosort = false
30
26
  attr_accessor :autosort
31
27
 
28
+ # Event listeners. Defaults to the MinimalOutput listener.
29
+ # You can add additional listeners if you'd like. For example,
30
+ # on linux (with notify-send) you can add the notifier listener:
31
+ # t.listeners << Hydra::Listener::Notifier.new
32
+ attr_accessor :listeners
33
+
32
34
  #
33
35
  # Search for the hydra config file
34
36
  def find_config_file
@@ -66,7 +68,7 @@ module Hydra #:nodoc:
66
68
  @files = []
67
69
  @verbose = false
68
70
  @autosort = true
69
- @listeners = [Hydra::Listener::MinimalOutput.new]
71
+ @listeners = [Hydra::Listener::ProgressBar.new]
70
72
 
71
73
  yield self if block_given?
72
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Gauthier
@@ -41,12 +41,15 @@ files:
41
41
  - TODO
42
42
  - VERSION
43
43
  - caliper.yml
44
+ - hydra-icon-64x64.png
44
45
  - hydra.gemspec
45
46
  - hydra_gray.png
46
47
  - lib/hydra.rb
47
48
  - lib/hydra/hash.rb
48
49
  - lib/hydra/listener/abstract.rb
49
50
  - lib/hydra/listener/minimal_output.rb
51
+ - lib/hydra/listener/notifier.rb
52
+ - lib/hydra/listener/progress_bar.rb
50
53
  - lib/hydra/listener/report_generator.rb
51
54
  - lib/hydra/master.rb
52
55
  - lib/hydra/message.rb