marcinbunsch-bolt 0.1.10 → 0.2.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.
data/lib/bolt/listener.rb CHANGED
@@ -53,6 +53,16 @@ module Bolt
53
53
  # Pick a listener to launch
54
54
  def listener
55
55
  return selected if selected
56
+
57
+ if Bolt['listener'] and ['generic', 'osx'].include?(Bolt['listener'])
58
+ self.selected= Bolt::Listeners::Generic.new if Bolt['listener'] == 'generic'
59
+ self.selected= Bolt::Listeners::Osx.new if Bolt['listener'] == 'osx'
60
+ $stdout.puts "** Found listener setting in .bolt"
61
+ return self.selected
62
+ end
63
+
64
+ $stdout.puts "** Determining listener..."
65
+
56
66
  # TODO: os identification via RUBY_PLATFORM is flawed as it will return 'java' in jruby. Look for a different solution
57
67
  os_string = RUBY_PLATFORM.downcase
58
68
  self.selected= Bolt::Listeners::Generic.new
data/lib/bolt/notifier.rb CHANGED
@@ -9,29 +9,39 @@ module Bolt
9
9
 
10
10
  # Constructor
11
11
  def initialize
12
- # find appropriate listener
13
- $stdout.puts "** Using #{notifier.class} \n"
14
-
15
- # launch appropriate listener
16
- # notifier.new
17
-
12
+ # find appropriate notifier
13
+ notifier
14
+ # present
15
+ $stdout.puts "** Using #{notifier.class} \n"
18
16
  end
19
17
 
20
18
  # Pick a listener to launch
21
19
  def notifier
22
- return selected if selected
23
- self.selected= Bolt::Notifiers::Generic.new
24
- # growl
20
+ return selected if selected
21
+
22
+
23
+ if Bolt['notifier'] and ['generic', 'growl'].include?(Bolt['notifier'])
24
+ self.selected= Bolt::Notifiers::Growl.new if Bolt['notifier'] == 'growl'
25
+ self.selected= Bolt::Notifiers::Generic.new if Bolt['notifier'] == 'generic'
26
+ $stdout.puts "** Found 'notifier' setting in .bolt"
27
+ return self.selected
28
+ end
29
+
30
+ $stdout.puts "** Determining notifier... \n"
31
+
32
+ # default - growl (if growlnotify is present)
25
33
  output = %x[which growlnotify]
26
- if output.to_s.include?('/growlnotify')
27
- self.selected= Bolt::Notifiers::Growl.new
34
+ if !Bolt['notifier'] and output.to_s.include?('/growlnotify')
35
+ self.selected= Bolt::Notifiers::Growl.new(:use_growlnotify => true)
28
36
  end
29
- #self.selected= Bolt::Listeners::Generic
30
- # self.selected= Bolt::Listeners::OSX if os_string.include?("darwin")
31
- #self.selected= Bolt::Listeners::Windows if os_string.include?("mswin")
32
- #self.selected= Bolt::Listeners::Linux if os_string.include?("linux")
37
+
38
+ # default if else fails
39
+ if !selected
40
+ self.selected= Bolt::Notifiers::Generic.new
41
+ end
42
+
33
43
  selected
34
44
  end
35
45
 
36
46
  end
37
- end
47
+ end
@@ -1,16 +1,41 @@
1
1
  #
2
- # Bolt::Notifiers::Generic
2
+ # Bolt::Notifiers::Growl
3
3
  #
4
- # The Generic Notifier does not do anything, it's for stability
4
+ # The Growl Notifier uses Growl to report on test results
5
5
  # The Growl Notifer is copied from mislav/rspactor growl module
6
6
  #
7
+ # Growl network support implemented by cziko (http://github.com/cziko/)
8
+ #
7
9
  module Bolt
8
10
  module Notifiers
9
11
  class Growl
12
+
13
+ attr_accessor :host, :use_growlnotify
14
+
15
+ def initialize(pars = {})
16
+ if Bolt['notifier_host']
17
+ @host = Bolt['notifier_host']
18
+ # load the gem only if required
19
+ begin
20
+ gem 'ruby-growl'
21
+ require 'ruby-growl'
22
+ rescue ::Gem::LoadError
23
+ puts "** ERROR: Could not start growl network support. Install 'ruby-growl' gem to enable."
24
+ @host = nil
25
+ end
26
+ end
27
+ @use_growlnotify = false
28
+ @use_growlnotify = true if pars[:use_growlnotify] or !@host
29
+ end
10
30
 
11
31
  # generic notify method
12
32
  def notify(title, msg, img, pri = 0)
13
- system("growlnotify -w -n rspactor --image #{img} -p #{pri} -m #{msg.inspect} #{title} &")
33
+ if @use_growlnotify
34
+ system("growlnotify -w -n bolt --image #{img} -p #{pri} -m #{msg.inspect} #{title} &")
35
+ else
36
+ g = ::Growl.new(@host, "bolt", ["notification"])
37
+ g.notify("notification", title, msg, pri)
38
+ end
14
39
  end
15
40
 
16
41
  # info message
@@ -52,4 +77,4 @@ module Bolt
52
77
 
53
78
  end
54
79
  end
55
- end
80
+ end
data/lib/bolt/runner.rb CHANGED
@@ -9,8 +9,10 @@ module Bolt
9
9
 
10
10
  # Constructor
11
11
  def initialize
12
- # find appropriate listener
12
+ # find appropriate runner
13
13
  runner
14
+
15
+ $stdout.puts "** Using #{selected.class} \n"
14
16
  end
15
17
 
16
18
  # Pick a listener to launch
@@ -20,13 +22,12 @@ module Bolt
20
22
  if Bolt['runner'] and ['test_unit', 'rspec'].include?(Bolt['runner'])
21
23
  self.selected= Bolt::Runners::TestUnit.new if Bolt['runner'] == 'test_unit'
22
24
  self.selected= Bolt::Runners::RSpec.new if Bolt['runner'] == 'rspec'
23
- $stdout.puts "** Using #{selected.class} based on 'runner' setting in .bolt file \n"
25
+ $stdout.puts "** Found 'runner' setting in .bolt"
24
26
  return self.selected
25
27
  end
26
28
  $stdout.puts "** Determining runner... \n"
27
29
  self.selected= Bolt::Runners::TestUnit.new
28
30
  self.selected= Bolt::Runners::RSpec.new if File.directory?('spec')
29
- $stdout.puts "** Using #{selected.class} \n"
30
31
  self.selected
31
32
  end
32
33
 
data/lib/bolt.rb CHANGED
@@ -82,4 +82,4 @@ module Bolt
82
82
  autoload :Generic, 'bolt/notifiers/generic'
83
83
  autoload :Growl, 'bolt/notifiers/growl'
84
84
  end
85
- end
85
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcinbunsch-bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bunsch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-17 00:00:00 -07:00
12
+ date: 2009-06-18 00:00:00 -07:00
13
13
  default_executable: bolt
14
14
  dependencies: []
15
15