guard 0.7.0.rc1 → 0.7.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/CHANGELOG.md +281 -279
- data/LICENSE +19 -19
- data/README.md +487 -487
- data/bin/guard +5 -5
- data/lib/guard.rb +186 -186
- data/lib/guard/cli.rb +90 -90
- data/lib/guard/dsl.rb +148 -148
- data/lib/guard/dsl_describer.rb +28 -28
- data/lib/guard/guard.rb +58 -58
- data/lib/guard/hook.rb +72 -72
- data/lib/guard/interactor.rb +40 -40
- data/lib/guard/listener.rb +191 -191
- data/lib/guard/listeners/darwin.rb +47 -47
- data/lib/guard/listeners/linux.rb +74 -74
- data/lib/guard/listeners/polling.rb +37 -37
- data/lib/guard/listeners/windows.rb +42 -42
- data/lib/guard/notifier.rb +136 -136
- data/lib/guard/templates/Guardfile +2 -2
- data/lib/guard/ui.rb +110 -110
- data/lib/guard/version.rb +3 -3
- data/lib/guard/watcher.rb +66 -66
- data/man/guard.1 +93 -93
- data/man/guard.1.html +176 -176
- metadata +11 -25
- data/lib/guard.rbc +0 -3978
- data/lib/guard/dsl.rbc +0 -3248
- data/lib/guard/dsl_describer.rbc +0 -785
- data/lib/guard/guard.rbc +0 -1007
- data/lib/guard/interactor.rbc +0 -1218
- data/lib/guard/listener.rbc +0 -3507
- data/lib/guard/listeners/darwin.rbc +0 -1106
- data/lib/guard/listeners/linux.rbc +0 -1747
- data/lib/guard/listeners/polling.rbc +0 -775
- data/lib/guard/listeners/windows.rbc +0 -967
- data/lib/guard/notifier.rbc +0 -2994
- data/lib/guard/ui.rbc +0 -2416
- data/lib/guard/version.rbc +0 -180
- data/lib/guard/watcher.rbc +0 -1854
@@ -1,47 +1,47 @@
|
|
1
|
-
module Guard
|
2
|
-
class Darwin < Listener
|
3
|
-
|
4
|
-
def initialize(*)
|
5
|
-
super
|
6
|
-
@fsevent = FSEvent.new
|
7
|
-
end
|
8
|
-
|
9
|
-
def worker
|
10
|
-
@fsevent
|
11
|
-
end
|
12
|
-
|
13
|
-
def start
|
14
|
-
super
|
15
|
-
worker.run
|
16
|
-
end
|
17
|
-
|
18
|
-
def stop
|
19
|
-
super
|
20
|
-
worker.stop
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.usable?
|
24
|
-
require 'rb-fsevent'
|
25
|
-
if !defined?(FSEvent::VERSION) || (defined?(Gem::Version) &&
|
26
|
-
Gem::Version.new(FSEvent::VERSION) < Gem::Version.new('0.4.0'))
|
27
|
-
UI.info "Please update rb-fsevent (>= 0.4.0)"
|
28
|
-
false
|
29
|
-
else
|
30
|
-
true
|
31
|
-
end
|
32
|
-
rescue LoadError
|
33
|
-
UI.info "Please install rb-fsevent gem for Mac OSX FSEvents support"
|
34
|
-
false
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def watch(directory)
|
40
|
-
worker.watch(directory) do |modified_dirs|
|
41
|
-
files = modified_files(modified_dirs)
|
42
|
-
@callback.call(files) unless files.empty?
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
1
|
+
module Guard
|
2
|
+
class Darwin < Listener
|
3
|
+
|
4
|
+
def initialize(*)
|
5
|
+
super
|
6
|
+
@fsevent = FSEvent.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def worker
|
10
|
+
@fsevent
|
11
|
+
end
|
12
|
+
|
13
|
+
def start
|
14
|
+
super
|
15
|
+
worker.run
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop
|
19
|
+
super
|
20
|
+
worker.stop
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.usable?
|
24
|
+
require 'rb-fsevent'
|
25
|
+
if !defined?(FSEvent::VERSION) || (defined?(Gem::Version) &&
|
26
|
+
Gem::Version.new(FSEvent::VERSION) < Gem::Version.new('0.4.0'))
|
27
|
+
UI.info "Please update rb-fsevent (>= 0.4.0)"
|
28
|
+
false
|
29
|
+
else
|
30
|
+
true
|
31
|
+
end
|
32
|
+
rescue LoadError
|
33
|
+
UI.info "Please install rb-fsevent gem for Mac OSX FSEvents support"
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def watch(directory)
|
40
|
+
worker.watch(directory) do |modified_dirs|
|
41
|
+
files = modified_files(modified_dirs)
|
42
|
+
@callback.call(files) unless files.empty?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -1,74 +1,74 @@
|
|
1
|
-
module Guard
|
2
|
-
class Linux < Listener
|
3
|
-
|
4
|
-
def initialize(*)
|
5
|
-
super
|
6
|
-
@inotify = INotify::Notifier.new
|
7
|
-
@files = []
|
8
|
-
@latency = 0.5
|
9
|
-
end
|
10
|
-
|
11
|
-
def start
|
12
|
-
@stop = false
|
13
|
-
super
|
14
|
-
watch_change unless watch_change?
|
15
|
-
end
|
16
|
-
|
17
|
-
def stop
|
18
|
-
super
|
19
|
-
@stop = true
|
20
|
-
sleep(@latency)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.usable?
|
24
|
-
require 'rb-inotify'
|
25
|
-
if !defined?(INotify::VERSION) || (defined?(Gem::Version) &&
|
26
|
-
Gem::Version.new(INotify::VERSION.join('.')) < Gem::Version.new('0.8.5'))
|
27
|
-
UI.info "Please update rb-inotify (>= 0.8.5)"
|
28
|
-
false
|
29
|
-
else
|
30
|
-
true
|
31
|
-
end
|
32
|
-
rescue LoadError
|
33
|
-
UI.info "Please install rb-inotify gem for Linux inotify support"
|
34
|
-
false
|
35
|
-
end
|
36
|
-
|
37
|
-
def watch_change?
|
38
|
-
!!@watch_change
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def worker
|
44
|
-
@inotify
|
45
|
-
end
|
46
|
-
|
47
|
-
def watch(directory)
|
48
|
-
# The event selection is based on https://github.com/guard/guard/wiki/Analysis-of-inotify-events-for-different-editors
|
49
|
-
worker.watch(directory, :recursive, :attrib, :create, :move_self, :close_write) do |event|
|
50
|
-
unless event.name == "" # Event on root directory
|
51
|
-
@files << event.absolute_name
|
52
|
-
end
|
53
|
-
end
|
54
|
-
rescue Interrupt
|
55
|
-
end
|
56
|
-
|
57
|
-
def watch_change
|
58
|
-
@watch_change = true
|
59
|
-
until @stop
|
60
|
-
if RbConfig::CONFIG['build'] =~ /java/ || IO.select([worker.to_io], [], [], @latency)
|
61
|
-
break if @stop
|
62
|
-
|
63
|
-
sleep(@latency)
|
64
|
-
worker.process
|
65
|
-
|
66
|
-
files = modified_files(@files.shift(@files.size).map { |f| File.dirname(f) }.uniq)
|
67
|
-
@callback.call(files) unless files.empty?
|
68
|
-
end
|
69
|
-
end
|
70
|
-
@watch_change = false
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
1
|
+
module Guard
|
2
|
+
class Linux < Listener
|
3
|
+
|
4
|
+
def initialize(*)
|
5
|
+
super
|
6
|
+
@inotify = INotify::Notifier.new
|
7
|
+
@files = []
|
8
|
+
@latency = 0.5
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
@stop = false
|
13
|
+
super
|
14
|
+
watch_change unless watch_change?
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop
|
18
|
+
super
|
19
|
+
@stop = true
|
20
|
+
sleep(@latency)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.usable?
|
24
|
+
require 'rb-inotify'
|
25
|
+
if !defined?(INotify::VERSION) || (defined?(Gem::Version) &&
|
26
|
+
Gem::Version.new(INotify::VERSION.join('.')) < Gem::Version.new('0.8.5'))
|
27
|
+
UI.info "Please update rb-inotify (>= 0.8.5)"
|
28
|
+
false
|
29
|
+
else
|
30
|
+
true
|
31
|
+
end
|
32
|
+
rescue LoadError
|
33
|
+
UI.info "Please install rb-inotify gem for Linux inotify support"
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
def watch_change?
|
38
|
+
!!@watch_change
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def worker
|
44
|
+
@inotify
|
45
|
+
end
|
46
|
+
|
47
|
+
def watch(directory)
|
48
|
+
# The event selection is based on https://github.com/guard/guard/wiki/Analysis-of-inotify-events-for-different-editors
|
49
|
+
worker.watch(directory, :recursive, :attrib, :create, :move_self, :close_write) do |event|
|
50
|
+
unless event.name == "" # Event on root directory
|
51
|
+
@files << event.absolute_name
|
52
|
+
end
|
53
|
+
end
|
54
|
+
rescue Interrupt
|
55
|
+
end
|
56
|
+
|
57
|
+
def watch_change
|
58
|
+
@watch_change = true
|
59
|
+
until @stop
|
60
|
+
if RbConfig::CONFIG['build'] =~ /java/ || IO.select([worker.to_io], [], [], @latency)
|
61
|
+
break if @stop
|
62
|
+
|
63
|
+
sleep(@latency)
|
64
|
+
worker.process
|
65
|
+
|
66
|
+
files = modified_files(@files.shift(@files.size).map { |f| File.dirname(f) }.uniq)
|
67
|
+
@callback.call(files) unless files.empty?
|
68
|
+
end
|
69
|
+
end
|
70
|
+
@watch_change = false
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
module Guard
|
2
|
-
class Polling < Listener
|
3
|
-
|
4
|
-
def initialize(*)
|
5
|
-
super
|
6
|
-
@latency = 1.5
|
7
|
-
end
|
8
|
-
|
9
|
-
def start
|
10
|
-
@stop = false
|
11
|
-
super
|
12
|
-
watch_change
|
13
|
-
end
|
14
|
-
|
15
|
-
def stop
|
16
|
-
super
|
17
|
-
@stop = true
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def watch_change
|
23
|
-
until @stop
|
24
|
-
start = Time.now.to_f
|
25
|
-
files = modified_files([@directory], :all => true)
|
26
|
-
@callback.call(files) unless files.empty?
|
27
|
-
nap_time = @latency - (Time.now.to_f - start)
|
28
|
-
sleep(nap_time) if nap_time > 0
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def watch(directory)
|
33
|
-
@existing = all_files
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
1
|
+
module Guard
|
2
|
+
class Polling < Listener
|
3
|
+
|
4
|
+
def initialize(*)
|
5
|
+
super
|
6
|
+
@latency = 1.5
|
7
|
+
end
|
8
|
+
|
9
|
+
def start
|
10
|
+
@stop = false
|
11
|
+
super
|
12
|
+
watch_change
|
13
|
+
end
|
14
|
+
|
15
|
+
def stop
|
16
|
+
super
|
17
|
+
@stop = true
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def watch_change
|
23
|
+
until @stop
|
24
|
+
start = Time.now.to_f
|
25
|
+
files = modified_files([@directory], :all => true)
|
26
|
+
@callback.call(files) unless files.empty?
|
27
|
+
nap_time = @latency - (Time.now.to_f - start)
|
28
|
+
sleep(nap_time) if nap_time > 0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def watch(directory)
|
33
|
+
@existing = all_files
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
module Guard
|
2
|
-
class Windows < Listener
|
3
|
-
|
4
|
-
def initialize(*)
|
5
|
-
super
|
6
|
-
@fchange = FChange::Notifier.new
|
7
|
-
end
|
8
|
-
|
9
|
-
def start
|
10
|
-
super
|
11
|
-
worker.run
|
12
|
-
end
|
13
|
-
|
14
|
-
def stop
|
15
|
-
super
|
16
|
-
worker.stop
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.usable?
|
20
|
-
require 'rb-fchange'
|
21
|
-
true
|
22
|
-
rescue LoadError
|
23
|
-
UI.info "Please install rb-fchange gem for Windows file events support"
|
24
|
-
false
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def worker
|
30
|
-
@fchange
|
31
|
-
end
|
32
|
-
|
33
|
-
def watch(directory)
|
34
|
-
worker.watch(directory, :all_events, :recursive) do |event|
|
35
|
-
paths = [File.expand_path(event.watcher.path)]
|
36
|
-
files = modified_files(paths, :all => true)
|
37
|
-
@callback.call(files) unless files.empty?
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
1
|
+
module Guard
|
2
|
+
class Windows < Listener
|
3
|
+
|
4
|
+
def initialize(*)
|
5
|
+
super
|
6
|
+
@fchange = FChange::Notifier.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def start
|
10
|
+
super
|
11
|
+
worker.run
|
12
|
+
end
|
13
|
+
|
14
|
+
def stop
|
15
|
+
super
|
16
|
+
worker.stop
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.usable?
|
20
|
+
require 'rb-fchange'
|
21
|
+
true
|
22
|
+
rescue LoadError
|
23
|
+
UI.info "Please install rb-fchange gem for Windows file events support"
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def worker
|
30
|
+
@fchange
|
31
|
+
end
|
32
|
+
|
33
|
+
def watch(directory)
|
34
|
+
worker.watch(directory, :all_events, :recursive) do |event|
|
35
|
+
paths = [File.expand_path(event.watcher.path)]
|
36
|
+
files = modified_files(paths, :all => true)
|
37
|
+
@callback.call(files) unless files.empty?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/lib/guard/notifier.rb
CHANGED
@@ -1,136 +1,136 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require 'pathname'
|
3
|
-
require 'guard/ui'
|
4
|
-
|
5
|
-
module Guard
|
6
|
-
module Notifier
|
7
|
-
APPLICATION_NAME = "Guard"
|
8
|
-
|
9
|
-
def self.turn_off
|
10
|
-
ENV["GUARD_NOTIFY"] = 'false'
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.turn_on
|
14
|
-
ENV["GUARD_NOTIFY"] = 'true'
|
15
|
-
case RbConfig::CONFIG['target_os']
|
16
|
-
when /darwin/i
|
17
|
-
require_growl
|
18
|
-
when /linux/i
|
19
|
-
require_libnotify
|
20
|
-
when /mswin|mingw/i
|
21
|
-
require_rbnotifu
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.notify(message, options = {})
|
26
|
-
if enabled?
|
27
|
-
image = options.delete(:image) || :success
|
28
|
-
title = options.delete(:title) || "Guard"
|
29
|
-
|
30
|
-
case RbConfig::CONFIG['target_os']
|
31
|
-
when /darwin/i
|
32
|
-
notify_mac(title, message, image, options)
|
33
|
-
when /linux/i
|
34
|
-
notify_linux(title, message, image, options)
|
35
|
-
when /mswin|mingw/i
|
36
|
-
notify_windows(title, message, image, options)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.enabled?
|
42
|
-
ENV["GUARD_NOTIFY"] == 'true'
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def self.notify_mac(title, message, image, options)
|
48
|
-
require_growl # need for guard-rspec formatter that is called out of guard scope
|
49
|
-
|
50
|
-
default_options = { :title => title, :icon => image_path(image), :name => APPLICATION_NAME }
|
51
|
-
default_options.merge!(options)
|
52
|
-
|
53
|
-
if defined?(GrowlNotify)
|
54
|
-
default_options[:description] = message
|
55
|
-
default_options[:application_name] = APPLICATION_NAME
|
56
|
-
default_options.delete(:name)
|
57
|
-
|
58
|
-
GrowlNotify.send_notification(default_options) if enabled?
|
59
|
-
else
|
60
|
-
Growl.notify message, default_options.merge(options) if enabled?
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.notify_linux(title, message, image, options)
|
65
|
-
require_libnotify # need for guard-rspec formatter that is called out of guard scope
|
66
|
-
default_options = { :body => message, :summary => title, :icon_path => image_path(image), :transient => true }
|
67
|
-
Libnotify.show default_options.merge(options) if enabled?
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.notify_windows(title, message, image, options)
|
71
|
-
require_rbnotifu # need for guard-rspec formatter that is called out of guard scope
|
72
|
-
default_options = { :message => message, :title => title, :type => image_level(image), :time => 3 }
|
73
|
-
Notifu.show default_options.merge(options) if enabled?
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.image_path(image)
|
77
|
-
images_path = Pathname.new(File.dirname(__FILE__)).join('../../images')
|
78
|
-
case image
|
79
|
-
when :failed
|
80
|
-
images_path.join("failed.png").to_s
|
81
|
-
when :pending
|
82
|
-
images_path.join("pending.png").to_s
|
83
|
-
when :success
|
84
|
-
images_path.join("success.png").to_s
|
85
|
-
else
|
86
|
-
# path given
|
87
|
-
image
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.image_level(image)
|
92
|
-
case image
|
93
|
-
when :failed
|
94
|
-
:error
|
95
|
-
when :pending
|
96
|
-
:warn
|
97
|
-
when :success
|
98
|
-
:info
|
99
|
-
else
|
100
|
-
:info
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.require_growl
|
105
|
-
begin
|
106
|
-
require 'growl_notify'
|
107
|
-
|
108
|
-
if GrowlNotify.application_name != APPLICATION_NAME
|
109
|
-
GrowlNotify.config do |c|
|
110
|
-
c.notifications = c.default_notifications = [ APPLICATION_NAME ]
|
111
|
-
c.application_name = c.notifications.first
|
112
|
-
end
|
113
|
-
end
|
114
|
-
rescue LoadError
|
115
|
-
require 'growl'
|
116
|
-
end
|
117
|
-
rescue LoadError
|
118
|
-
turn_off
|
119
|
-
UI.info "Please install growl_notify or growl gem for Mac OS X notification support and add it to your Gemfile"
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.require_libnotify
|
123
|
-
require 'libnotify'
|
124
|
-
rescue LoadError
|
125
|
-
turn_off
|
126
|
-
UI.info "Please install libnotify gem for Linux notification support and add it to your Gemfile"
|
127
|
-
end
|
128
|
-
|
129
|
-
def self.require_rbnotifu
|
130
|
-
require 'rb-notifu'
|
131
|
-
rescue LoadError
|
132
|
-
turn_off
|
133
|
-
UI.info "Please install rb-notifu gem for Windows notification support and add it to your Gemfile"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'pathname'
|
3
|
+
require 'guard/ui'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
module Notifier
|
7
|
+
APPLICATION_NAME = "Guard"
|
8
|
+
|
9
|
+
def self.turn_off
|
10
|
+
ENV["GUARD_NOTIFY"] = 'false'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.turn_on
|
14
|
+
ENV["GUARD_NOTIFY"] = 'true'
|
15
|
+
case RbConfig::CONFIG['target_os']
|
16
|
+
when /darwin/i
|
17
|
+
require_growl
|
18
|
+
when /linux/i
|
19
|
+
require_libnotify
|
20
|
+
when /mswin|mingw/i
|
21
|
+
require_rbnotifu
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.notify(message, options = {})
|
26
|
+
if enabled?
|
27
|
+
image = options.delete(:image) || :success
|
28
|
+
title = options.delete(:title) || "Guard"
|
29
|
+
|
30
|
+
case RbConfig::CONFIG['target_os']
|
31
|
+
when /darwin/i
|
32
|
+
notify_mac(title, message, image, options)
|
33
|
+
when /linux/i
|
34
|
+
notify_linux(title, message, image, options)
|
35
|
+
when /mswin|mingw/i
|
36
|
+
notify_windows(title, message, image, options)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.enabled?
|
42
|
+
ENV["GUARD_NOTIFY"] == 'true'
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def self.notify_mac(title, message, image, options)
|
48
|
+
require_growl # need for guard-rspec formatter that is called out of guard scope
|
49
|
+
|
50
|
+
default_options = { :title => title, :icon => image_path(image), :name => APPLICATION_NAME }
|
51
|
+
default_options.merge!(options)
|
52
|
+
|
53
|
+
if defined?(GrowlNotify)
|
54
|
+
default_options[:description] = message
|
55
|
+
default_options[:application_name] = APPLICATION_NAME
|
56
|
+
default_options.delete(:name)
|
57
|
+
|
58
|
+
GrowlNotify.send_notification(default_options) if enabled?
|
59
|
+
else
|
60
|
+
Growl.notify message, default_options.merge(options) if enabled?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.notify_linux(title, message, image, options)
|
65
|
+
require_libnotify # need for guard-rspec formatter that is called out of guard scope
|
66
|
+
default_options = { :body => message, :summary => title, :icon_path => image_path(image), :transient => true }
|
67
|
+
Libnotify.show default_options.merge(options) if enabled?
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.notify_windows(title, message, image, options)
|
71
|
+
require_rbnotifu # need for guard-rspec formatter that is called out of guard scope
|
72
|
+
default_options = { :message => message, :title => title, :type => image_level(image), :time => 3 }
|
73
|
+
Notifu.show default_options.merge(options) if enabled?
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.image_path(image)
|
77
|
+
images_path = Pathname.new(File.dirname(__FILE__)).join('../../images')
|
78
|
+
case image
|
79
|
+
when :failed
|
80
|
+
images_path.join("failed.png").to_s
|
81
|
+
when :pending
|
82
|
+
images_path.join("pending.png").to_s
|
83
|
+
when :success
|
84
|
+
images_path.join("success.png").to_s
|
85
|
+
else
|
86
|
+
# path given
|
87
|
+
image
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.image_level(image)
|
92
|
+
case image
|
93
|
+
when :failed
|
94
|
+
:error
|
95
|
+
when :pending
|
96
|
+
:warn
|
97
|
+
when :success
|
98
|
+
:info
|
99
|
+
else
|
100
|
+
:info
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.require_growl
|
105
|
+
begin
|
106
|
+
require 'growl_notify'
|
107
|
+
|
108
|
+
if GrowlNotify.application_name != APPLICATION_NAME
|
109
|
+
GrowlNotify.config do |c|
|
110
|
+
c.notifications = c.default_notifications = [ APPLICATION_NAME ]
|
111
|
+
c.application_name = c.notifications.first
|
112
|
+
end
|
113
|
+
end
|
114
|
+
rescue LoadError
|
115
|
+
require 'growl'
|
116
|
+
end
|
117
|
+
rescue LoadError
|
118
|
+
turn_off
|
119
|
+
UI.info "Please install growl_notify or growl gem for Mac OS X notification support and add it to your Gemfile"
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.require_libnotify
|
123
|
+
require 'libnotify'
|
124
|
+
rescue LoadError
|
125
|
+
turn_off
|
126
|
+
UI.info "Please install libnotify gem for Linux notification support and add it to your Gemfile"
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.require_rbnotifu
|
130
|
+
require 'rb-notifu'
|
131
|
+
rescue LoadError
|
132
|
+
turn_off
|
133
|
+
UI.info "Please install rb-notifu gem for Windows notification support and add it to your Gemfile"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|