guard 2.8.2 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -7
  3. data/lib/guard.rb +220 -152
  4. data/lib/guard.rb.orig +213 -155
  5. data/lib/guard/aruba_adapter.rb +2 -2
  6. data/lib/guard/cli.rb +8 -13
  7. data/lib/guard/cli.rb.orig +12 -10
  8. data/lib/guard/commander.rb +15 -7
  9. data/lib/guard/commands/all.rb +3 -0
  10. data/lib/guard/commands/change.rb +3 -0
  11. data/lib/guard/commands/pause.rb +2 -0
  12. data/lib/guard/commands/reload.rb +4 -0
  13. data/lib/guard/commands/scope.rb +3 -0
  14. data/lib/guard/config.rb +24 -0
  15. data/lib/guard/deprecated/dsl.rb +45 -0
  16. data/lib/guard/deprecated/guard.rb +166 -0
  17. data/lib/guard/deprecated/guardfile.rb +84 -0
  18. data/lib/guard/dsl.rb +24 -13
  19. data/lib/guard/dsl.rb.orig +378 -0
  20. data/lib/guard/dsl_describer.rb +8 -2
  21. data/lib/guard/dsl_describer.rb.orig +11 -3
  22. data/lib/guard/guardfile.rb +32 -44
  23. data/lib/guard/guardfile/evaluator.rb +13 -6
  24. data/lib/guard/guardfile/generator.rb +4 -3
  25. data/lib/guard/interactor.rb +7 -3
  26. data/lib/guard/internals/debugging.rb +1 -0
  27. data/lib/guard/internals/environment.rb +93 -0
  28. data/lib/guard/internals/helpers.rb +13 -0
  29. data/lib/guard/internals/traps.rb +10 -0
  30. data/lib/guard/jobs/pry_wrapper.rb +4 -3
  31. data/lib/guard/jobs/sleep.rb +2 -0
  32. data/lib/guard/metadata.rb +190 -0
  33. data/lib/guard/notifier.rb +124 -99
  34. data/lib/guard/notifier.rb.orig +124 -99
  35. data/lib/guard/notifier/detected.rb +83 -0
  36. data/lib/guard/notifiers/emacs.rb +2 -1
  37. data/lib/guard/notifiers/tmux.rb +173 -177
  38. data/lib/guard/plugin/base.rb +2 -0
  39. data/lib/guard/plugin_util.rb +26 -32
  40. data/lib/guard/reevaluator.rb +3 -3
  41. data/lib/guard/reevaluator.rb.orig +22 -0
  42. data/lib/guard/runner.rb +1 -0
  43. data/lib/guard/session.rb +5 -0
  44. data/lib/guard/sheller.rb +2 -2
  45. data/lib/guard/templates/Guardfile +4 -0
  46. data/lib/guard/templates/Guardfile.orig +2 -0
  47. data/lib/guard/terminal.rb +1 -0
  48. data/lib/guard/ui.rb +4 -1
  49. data/lib/guard/version.rb +1 -1
  50. data/lib/guard/version.rb.orig +1 -1
  51. data/lib/guard/watcher.rb +3 -1
  52. data/lib/guard/watcher.rb.orig +122 -0
  53. data/man/guard.1 +1 -4
  54. data/man/guard.1.html +1 -4
  55. metadata +17 -25
  56. data/lib/guard/commander.rb.orig +0 -103
  57. data/lib/guard/commands/all.rb.orig +0 -36
  58. data/lib/guard/commands/reload.rb.orig +0 -34
  59. data/lib/guard/commands/scope.rb.orig +0 -36
  60. data/lib/guard/deprecated_methods.rb +0 -72
  61. data/lib/guard/deprecated_methods.rb.orig +0 -71
  62. data/lib/guard/deprecator.rb +0 -133
  63. data/lib/guard/deprecator.rb.orig +0 -206
  64. data/lib/guard/guard.rb +0 -100
  65. data/lib/guard/guard.rb.orig +0 -42
  66. data/lib/guard/guardfile.rb.orig +0 -43
  67. data/lib/guard/guardfile/evaluator.rb.orig +0 -275
  68. data/lib/guard/internals/debugging.rb.orig +0 -0
  69. data/lib/guard/internals/environment.rb.orig +0 -0
  70. data/lib/guard/internals/tracing.rb.orig +0 -0
  71. data/lib/guard/notifiers/base.rb.orig +0 -221
  72. data/lib/guard/notifiers/tmux.rb.orig +0 -339
  73. data/lib/guard/plugin_util.rb.orig +0 -186
  74. data/lib/guard/runner.rb.orig +0 -210
  75. data/lib/guard/setuper.rb +0 -359
  76. data/lib/guard/setuper.rb.orig +0 -395
  77. data/lib/guard/ui.rb.orig +0 -278
@@ -2,17 +2,10 @@ require "yaml"
2
2
  require "rbconfig"
3
3
  require "pathname"
4
4
 
5
- require "guard/ui"
6
- require "guard/notifiers/emacs"
7
- require "guard/notifiers/file_notifier"
8
- require "guard/notifiers/gntp"
9
- require "guard/notifiers/growl"
10
- require "guard/notifiers/libnotify"
11
- require "guard/notifiers/notifysend"
12
- require "guard/notifiers/rb_notifu"
13
- require "guard/notifiers/terminal_notifier"
14
- require "guard/notifiers/terminal_title"
15
- require "guard/notifiers/tmux"
5
+ require_relative "internals/environment"
6
+ require_relative "notifier/detected"
7
+
8
+ require_relative "ui"
16
9
 
17
10
  module Guard
18
11
  # The notifier handles sending messages to different notifiers. Currently the
@@ -49,11 +42,22 @@ module Guard
49
42
  #
50
43
  # @see Guard::Dsl
51
44
  #
45
+ # TODO: rename to plural
52
46
  module Notifier
53
47
  extend self
54
48
 
49
+ NOTIFICATIONS_DISABLED = "Notifications disabled by GUARD_NOTIFY" +
50
+ " environment variable"
51
+
52
+ USING_NOTIFIER = "Guard is using %s to send notifications."
53
+
54
+ ONLY_NOTIFY = "Only notify() is available from a child process"
55
+
56
+ DEPRECTED_IMPLICIT_CONNECT = "Calling Guard::Notifier.notify()" +
57
+ " without a prior Notifier.connect() is deprecated"
58
+
55
59
  # List of available notifiers, grouped by functionality
56
- NOTIFIERS = [
60
+ SUPPORTED = [
57
61
  {
58
62
  gntp: GNTP,
59
63
  growl: Growl,
@@ -68,77 +72,94 @@ module Guard
68
72
  { file: FileNotifier }
69
73
  ]
70
74
 
71
- def notifiers
72
- ENV["GUARD_NOTIFIERS"] ? YAML::load(ENV["GUARD_NOTIFIERS"]) : []
75
+ class NotServer < RuntimeError
73
76
  end
74
77
 
75
- def notifiers=(notifiers)
76
- ENV["GUARD_NOTIFIERS"] = YAML::dump(notifiers)
78
+ def connect(options = {})
79
+ @detected = Detected.new(SUPPORTED)
80
+ return if _client?
81
+
82
+ _env.notify_pid = $$
83
+
84
+ fail "Already connected" if active?
85
+
86
+ return unless enabled? && options[:notify]
87
+
88
+ turn_on
89
+ rescue Detected::NoneAvailableError => e
90
+ ::Guard::UI.info e.to_s
77
91
  end
78
92
 
79
- # Clear available notifications.
80
- #
81
- def clear_notifiers
82
- ENV["GUARD_NOTIFIERS"] = nil
93
+ def disconnect
94
+ if _client?
95
+ @detected = nil
96
+ return
97
+ end
98
+
99
+ turn_off if active?
100
+ @detected.reset unless @detected.nil?
101
+ _env.notify_pid = nil
102
+ @detected = nil
83
103
  end
84
104
 
85
- # Turn notifications on. If no notifications are defined in the `Guardfile`
86
- # Guard auto detects the first available library.
105
+ # Turn notifications on.
87
106
  #
88
107
  # @param [Hash] options the turn_on options
89
108
  # @option options [Boolean] silent disable any logging
90
109
  #
91
110
  def turn_on(opts = {})
92
- if notifiers.empty? && (::Guard.options || {})[:notify]
93
- _auto_detect_notification
94
- end
111
+ _check_server!
112
+ return unless enabled?
95
113
 
96
- if notifiers.empty?
97
- turn_off
98
- else
99
- notifiers.each do |notifier|
100
- notifier_class = _get_notifier_module(notifier[:name])
101
- unless opts[:silent]
102
- ::Guard::UI.info \
103
- "Guard is using #{ notifier_class.title } to send notifications."
104
- end
114
+ fail "Already active!" if active?
105
115
 
106
- notifier_class.turn_on if notifier_class.respond_to?(:turn_on)
107
- end
116
+ silent = opts[:silent]
108
117
 
109
- ENV["GUARD_NOTIFY"] = "true"
118
+ @detected.available.each do |klass, _|
119
+ ::Guard::UI.info(format(USING_NOTIFIER, klass.title)) unless silent
120
+ klass.turn_on if klass.respond_to?(:turn_on)
110
121
  end
122
+
123
+ _env.notify_active = true
111
124
  end
112
125
 
113
126
  # Turn notifications off.
114
- #
115
127
  def turn_off
116
- notifiers.each do |notifier|
117
- notifier_class = _get_notifier_module(notifier[:name])
128
+ _check_server!
118
129
 
119
- notifier_class.turn_off if notifier_class.respond_to?(:turn_off)
130
+ fail "Not active!" unless active?
131
+
132
+ @detected.available.each do |klass, _|
133
+ klass.turn_off if klass.respond_to?(:turn_off)
120
134
  end
121
135
 
122
- ENV["GUARD_NOTIFY"] = "false"
136
+ _env.notify_active = false
123
137
  end
124
138
 
125
139
  # Toggle the system notifications on/off
126
- #
127
140
  def toggle
128
- if enabled?
141
+ unless enabled?
142
+ ::Guard::UI.error NOTIFICATIONS_DISABLED
143
+ return
144
+ end
145
+
146
+ if active?
129
147
  ::Guard::UI.info "Turn off notifications"
130
148
  turn_off
131
- else
132
- turn_on
149
+ return
133
150
  end
151
+
152
+ turn_on
134
153
  end
135
154
 
136
- # Test if the notifications are on.
137
- #
138
- # @return [Boolean] whether the notifications are on
139
- #
155
+ # Test if the notifications can be enabled based on ENV['GUARD_NOTIFY']
140
156
  def enabled?
141
- ENV["GUARD_NOTIFY"] == "true"
157
+ _env.notify?
158
+ end
159
+
160
+ # Test if notifiers are currently turned on
161
+ def active?
162
+ _env.notify_active?
142
163
  end
143
164
 
144
165
  # Add a notification library to be used.
@@ -148,75 +169,79 @@ module Guard
148
169
  # @option options [String] silent disable any error message
149
170
  # @return [Boolean] if the notification could be added
150
171
  #
151
- def add_notifier(name, opts = {})
152
- return turn_off if name == :off
172
+ def add(name, opts = {})
173
+ _check_server!
153
174
 
154
- notifier_class = _get_notifier_module(name)
175
+ return false unless enabled?
155
176
 
156
- if notifier_class && notifier_class.available?(opts)
157
- self.notifiers = notifiers << { name: name, options: opts }
158
- true
159
- else
160
- false
177
+ if name == :off && active?
178
+ turn_off
179
+ return false
161
180
  end
181
+
182
+ # ok to pass new instance when called without connect (e.g. evaluator)
183
+ (@detected || Detected.new(SUPPORTED)).add(name, opts)
162
184
  end
163
185
 
186
+ # TODO: deprecate/remove
187
+ alias :add_notifier :add
188
+
164
189
  # Show a system notification with all configured notifiers.
165
190
  #
166
191
  # @param [String] message the message to show
167
192
  # @option opts [Symbol, String] image the image symbol or path to an image
168
193
  # @option opts [String] title the notification title
169
194
  #
170
- def notify(message, opts = {})
171
- return unless enabled?
172
-
173
- notifiers.each do |notifier|
174
- notifier = _get_notifier_module(notifier[:name]).new(notifier[:options])
175
-
176
- begin
177
- notifier.notify(message, opts.dup)
178
- rescue RuntimeError => e
179
- ::Guard::UI.error \
180
- "Error sending notification with #{ notifier.name }: #{ e.message }"
195
+ def notify(message, message_opts = {})
196
+ if _client?
197
+ # TODO: reenable again?
198
+ # UI.deprecation(DEPRECTED_IMPLICIT_CONNECT)
199
+ return unless enabled?
200
+ connect(notify: true)
201
+ else
202
+ return unless active?
203
+ end
181
204
 
182
- ::Guard::UI.debug e.backtrace.join("\n")
183
- end
205
+ @detected.available.each do |klass, options|
206
+ _notify(klass, options, message, message_opts)
184
207
  end
185
208
  end
186
209
 
210
+ # Used by dsl describer
211
+ def notifiers
212
+ @detected.available.map { |mod, opts| { name: mod.name, options: opts } }
213
+ end
214
+
187
215
  private
188
216
 
189
- # Get the notifier module for the given name.
190
- #
191
- # @param [Symbol] name the notifier name
192
- # @return [Module] the notifier module
193
- #
194
- def _get_notifier_module(name)
195
- NOTIFIERS.each do |group|
196
- next unless (notifier = group.detect { |n, _| n == name })
197
- return notifier.last
198
- end
199
- nil
217
+ def _env
218
+ (@environment ||= _create_env)
200
219
  end
201
220
 
202
- # Auto detect the available notification library. This goes through
203
- # the list of supported notification gems and picks the first that
204
- # is available in each notification group.
205
- #
206
- def _auto_detect_notification
207
- self.notifiers = []
208
- available = nil
209
-
210
- NOTIFIERS.each do |group|
211
- notifier_added = group.detect do |name, _|
212
- add_notifier(name, silent: true)
213
- end
214
- available ||= notifier_added
221
+ def _create_env
222
+ Internals::Environment.new("GUARD").tap do |env|
223
+ env.create_method(:notify?) { |data| data != "false" }
224
+ env.create_method(:notify_pid) { |data| data && Integer(data) }
225
+ env.create_method(:notify_pid=)
226
+ env.create_method(:notify_active?)
227
+ env.create_method(:notify_active=)
215
228
  end
229
+ end
230
+
231
+ def _check_server!
232
+ _client? && fail(NotServer, ONLY_NOTIFY)
233
+ end
234
+
235
+ def _client?
236
+ (pid = _env.notify_pid) && (pid != $$)
237
+ end
216
238
 
217
- return if available
218
- ::Guard::UI.info \
219
- "Guard could not detect any of the supported notification libraries."
239
+ def _notify(klass, options, message, message_options)
240
+ notifier = klass.new(options)
241
+ notifier.notify(message, message_options.dup)
242
+ rescue RuntimeError => e
243
+ ::Guard::UI.error "Notification failed for #{notifier.name}: #{e.message}"
244
+ ::Guard::UI.debug e.backtrace.join("\n")
220
245
  end
221
246
  end
222
247
  end
@@ -2,17 +2,10 @@ require "yaml"
2
2
  require "rbconfig"
3
3
  require "pathname"
4
4
 
5
- require "guard/ui"
6
- require "guard/notifiers/emacs"
7
- require "guard/notifiers/file_notifier"
8
- require "guard/notifiers/gntp"
9
- require "guard/notifiers/growl"
10
- require "guard/notifiers/libnotify"
11
- require "guard/notifiers/notifysend"
12
- require "guard/notifiers/rb_notifu"
13
- require "guard/notifiers/terminal_notifier"
14
- require "guard/notifiers/terminal_title"
15
- require "guard/notifiers/tmux"
5
+ require_relative "internals/environment"
6
+ require_relative "notifier/detected"
7
+
8
+ require_relative "ui"
16
9
 
17
10
  module Guard
18
11
  # The notifier handles sending messages to different notifiers. Currently the
@@ -49,11 +42,22 @@ module Guard
49
42
  #
50
43
  # @see Guard::Dsl
51
44
  #
45
+ # TODO: rename to plural
52
46
  module Notifier
53
47
  extend self
54
48
 
49
+ NOTIFICATIONS_DISABLED = "Notifications disabled by GUARD_NOTIFY" +
50
+ " environment variable"
51
+
52
+ USING_NOTIFIER = "Guard is using %s to send notifications."
53
+
54
+ ONLY_NOTIFY = "Only notify() is available from a child process"
55
+
56
+ DEPRECTED_IMPLICIT_CONNECT = "Calling Guard::Notifier.notify()" +
57
+ " without a prior Notifier.connect() is deprecated"
58
+
55
59
  # List of available notifiers, grouped by functionality
56
- NOTIFIERS = [
60
+ SUPPORTED = [
57
61
  {
58
62
  gntp: GNTP,
59
63
  growl: Growl,
@@ -68,77 +72,94 @@ module Guard
68
72
  { file: FileNotifier }
69
73
  ]
70
74
 
71
- def notifiers
72
- ENV["GUARD_NOTIFIERS"] ? YAML::load(ENV["GUARD_NOTIFIERS"]) : []
75
+ class NotServer < RuntimeError
73
76
  end
74
77
 
75
- def notifiers=(notifiers)
76
- ENV["GUARD_NOTIFIERS"] = YAML::dump(notifiers)
78
+ def connect(options = {})
79
+ @detected = Detected.new(SUPPORTED)
80
+ return if _client?
81
+
82
+ _env.notify_pid = $$
83
+
84
+ fail "Already connected" if active?
85
+
86
+ return unless enabled? && options[:notify]
87
+
88
+ turn_on
89
+ rescue Detected::NoneAvailableError => e
90
+ ::Guard::UI.info e.to_s
77
91
  end
78
92
 
79
- # Clear available notifications.
80
- #
81
- def clear_notifiers
82
- ENV["GUARD_NOTIFIERS"] = nil
93
+ def disconnect
94
+ if _client?
95
+ @detected = nil
96
+ return
97
+ end
98
+
99
+ turn_off if active?
100
+ @detected.reset
101
+ _env.notify_pid = nil
102
+ @detected = nil
83
103
  end
84
104
 
85
- # Turn notifications on. If no notifications are defined in the `Guardfile`
86
- # Guard auto detects the first available library.
105
+ # Turn notifications on.
87
106
  #
88
107
  # @param [Hash] options the turn_on options
89
108
  # @option options [Boolean] silent disable any logging
90
109
  #
91
110
  def turn_on(opts = {})
92
- if notifiers.empty? && (::Guard.options || {})[:notify]
93
- _auto_detect_notification
94
- end
111
+ _check_server!
112
+ return unless enabled?
95
113
 
96
- if notifiers.empty?
97
- turn_off
98
- else
99
- notifiers.each do |notifier|
100
- notifier_class = _get_notifier_module(notifier[:name])
101
- unless opts[:silent]
102
- ::Guard::UI.info \
103
- "Guard is using #{ notifier_class.title } to send notifications."
104
- end
114
+ fail "Already active!" if active?
105
115
 
106
- notifier_class.turn_on if notifier_class.respond_to?(:turn_on)
107
- end
116
+ silent = opts[:silent]
108
117
 
109
- ENV["GUARD_NOTIFY"] = "true"
118
+ @detected.available.each do |klass, _|
119
+ ::Guard::UI.info(format(USING_NOTIFIER, klass.title)) unless silent
120
+ klass.turn_on if klass.respond_to?(:turn_on)
110
121
  end
122
+
123
+ _env.notify_active = true
111
124
  end
112
125
 
113
126
  # Turn notifications off.
114
- #
115
127
  def turn_off
116
- notifiers.each do |notifier|
117
- notifier_class = _get_notifier_module(notifier[:name])
128
+ _check_server!
118
129
 
119
- notifier_class.turn_off if notifier_class.respond_to?(:turn_off)
130
+ fail "Not active!" unless active?
131
+
132
+ @detected.available.each do |klass, _|
133
+ klass.turn_off if klass.respond_to?(:turn_off)
120
134
  end
121
135
 
122
- ENV["GUARD_NOTIFY"] = "false"
136
+ _env.notify_active = false
123
137
  end
124
138
 
125
139
  # Toggle the system notifications on/off
126
- #
127
140
  def toggle
128
- if enabled?
141
+ unless enabled?
142
+ ::Guard::UI.error NOTIFICATIONS_DISABLED
143
+ return
144
+ end
145
+
146
+ if active?
129
147
  ::Guard::UI.info "Turn off notifications"
130
148
  turn_off
131
- else
132
- turn_on
149
+ return
133
150
  end
151
+
152
+ turn_on
134
153
  end
135
154
 
136
- # Test if the notifications are on.
137
- #
138
- # @return [Boolean] whether the notifications are on
139
- #
155
+ # Test if the notifications can be enabled based on ENV['GUARD_NOTIFY']
140
156
  def enabled?
141
- ENV["GUARD_NOTIFY"] == "true"
157
+ _env.notify?
158
+ end
159
+
160
+ # Test if notifiers are currently turned on
161
+ def active?
162
+ _env.notify_active?
142
163
  end
143
164
 
144
165
  # Add a notification library to be used.
@@ -148,75 +169,79 @@ module Guard
148
169
  # @option options [String] silent disable any error message
149
170
  # @return [Boolean] if the notification could be added
150
171
  #
151
- def add_notifier(name, opts = {})
152
- return turn_off if name == :off
172
+ def add(name, opts = {})
173
+ _check_server!
153
174
 
154
- notifier_class = _get_notifier_module(name)
175
+ return false unless enabled?
155
176
 
156
- if notifier_class && notifier_class.available?(opts)
157
- self.notifiers = notifiers << { name: name, options: opts }
158
- true
159
- else
160
- false
177
+ if name == :off && active?
178
+ turn_off
179
+ return false
161
180
  end
181
+
182
+ # ok to pass new instance when called without connect (e.g. evaluator)
183
+ (@detected || Detected.new(SUPPORTED)).add(name, opts)
162
184
  end
163
185
 
186
+ # TODO: deprecate/remove
187
+ alias :add_notifier :add
188
+
164
189
  # Show a system notification with all configured notifiers.
165
190
  #
166
191
  # @param [String] message the message to show
167
192
  # @option opts [Symbol, String] image the image symbol or path to an image
168
193
  # @option opts [String] title the notification title
169
194
  #
170
- def notify(message, opts = {})
171
- return unless enabled?
172
-
173
- notifiers.each do |notifier|
174
- notifier = _get_notifier_module(notifier[:name]).new(notifier[:options])
175
-
176
- begin
177
- notifier.notify(message, opts.dup)
178
- rescue RuntimeError => e
179
- ::Guard::UI.error \
180
- "Error sending notification with #{ notifier.name }: #{ e.message }"
195
+ def notify(message, message_opts = {})
196
+ if _client?
197
+ # TODO: remove
198
+ UI.deprecation(DEPRECTED_IMPLICIT_CONNECT)
199
+ return unless enabled?
200
+ connect(notify: true)
201
+ else
202
+ return unless active?
203
+ end
181
204
 
182
- ::Guard::UI.debug e.backtrace.join("\n")
183
- end
205
+ @detected.available.each do |klass, options|
206
+ _notify(klass, options, message, message_opts)
184
207
  end
185
208
  end
186
209
 
210
+ # Used by dsl describer
211
+ def notifiers
212
+ @detected.available.map { |mod, opts| { name: mod.name, options: opts } }
213
+ end
214
+
187
215
  private
188
216
 
189
- # Get the notifier module for the given name.
190
- #
191
- # @param [Symbol] name the notifier name
192
- # @return [Module] the notifier module
193
- #
194
- def _get_notifier_module(name)
195
- NOTIFIERS.each do |group|
196
- next unless (notifier = group.detect { |n, _| n == name })
197
- return notifier.last
198
- end
199
- nil
217
+ def _env
218
+ (@environment ||= _create_env)
200
219
  end
201
220
 
202
- # Auto detect the available notification library. This goes through
203
- # the list of supported notification gems and picks the first that
204
- # is available in each notification group.
205
- #
206
- def _auto_detect_notification
207
- self.notifiers = []
208
- available = nil
209
-
210
- NOTIFIERS.each do |group|
211
- notifier_added = group.detect do |name, _|
212
- add_notifier(name, silent: true)
213
- end
214
- available ||= notifier_added
221
+ def _create_env
222
+ Internals::Environment.new("GUARD").tap do |env|
223
+ env.create_method(:notify?) { |data| data != "false" }
224
+ env.create_method(:notify_pid) { |data| data && Integer(data) }
225
+ env.create_method(:notify_pid=)
226
+ env.create_method(:notify_active?)
227
+ env.create_method(:notify_active=)
215
228
  end
229
+ end
230
+
231
+ def _check_server!
232
+ _client? && fail(NotServer, ONLY_NOTIFY)
233
+ end
234
+
235
+ def _client?
236
+ (pid = _env.notify_pid) && (pid != $$)
237
+ end
216
238
 
217
- return if available
218
- ::Guard::UI.info \
219
- "Guard could not detect any of the supported notification libraries."
239
+ def _notify(klass, options, message, message_options)
240
+ notifier = klass.new(options)
241
+ notifier.notify(message, message_options.dup)
242
+ rescue RuntimeError => e
243
+ ::Guard::UI.error "Notification failed for #{notifier.name}: #{e.message}"
244
+ ::Guard::UI.debug e.backtrace.join("\n")
220
245
  end
221
246
  end
222
247
  end