guard 2.8.2 → 2.9.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.
- checksums.yaml +4 -4
- data/README.md +0 -7
- data/lib/guard.rb +220 -152
- data/lib/guard.rb.orig +213 -155
- data/lib/guard/aruba_adapter.rb +2 -2
- data/lib/guard/cli.rb +8 -13
- data/lib/guard/cli.rb.orig +12 -10
- data/lib/guard/commander.rb +15 -7
- data/lib/guard/commands/all.rb +3 -0
- data/lib/guard/commands/change.rb +3 -0
- data/lib/guard/commands/pause.rb +2 -0
- data/lib/guard/commands/reload.rb +4 -0
- data/lib/guard/commands/scope.rb +3 -0
- data/lib/guard/config.rb +24 -0
- data/lib/guard/deprecated/dsl.rb +45 -0
- data/lib/guard/deprecated/guard.rb +166 -0
- data/lib/guard/deprecated/guardfile.rb +84 -0
- data/lib/guard/dsl.rb +24 -13
- data/lib/guard/dsl.rb.orig +378 -0
- data/lib/guard/dsl_describer.rb +8 -2
- data/lib/guard/dsl_describer.rb.orig +11 -3
- data/lib/guard/guardfile.rb +32 -44
- data/lib/guard/guardfile/evaluator.rb +13 -6
- data/lib/guard/guardfile/generator.rb +4 -3
- data/lib/guard/interactor.rb +7 -3
- data/lib/guard/internals/debugging.rb +1 -0
- data/lib/guard/internals/environment.rb +93 -0
- data/lib/guard/internals/helpers.rb +13 -0
- data/lib/guard/internals/traps.rb +10 -0
- data/lib/guard/jobs/pry_wrapper.rb +4 -3
- data/lib/guard/jobs/sleep.rb +2 -0
- data/lib/guard/metadata.rb +190 -0
- data/lib/guard/notifier.rb +124 -99
- data/lib/guard/notifier.rb.orig +124 -99
- data/lib/guard/notifier/detected.rb +83 -0
- data/lib/guard/notifiers/emacs.rb +2 -1
- data/lib/guard/notifiers/tmux.rb +173 -177
- data/lib/guard/plugin/base.rb +2 -0
- data/lib/guard/plugin_util.rb +26 -32
- data/lib/guard/reevaluator.rb +3 -3
- data/lib/guard/reevaluator.rb.orig +22 -0
- data/lib/guard/runner.rb +1 -0
- data/lib/guard/session.rb +5 -0
- data/lib/guard/sheller.rb +2 -2
- data/lib/guard/templates/Guardfile +4 -0
- data/lib/guard/templates/Guardfile.orig +2 -0
- data/lib/guard/terminal.rb +1 -0
- data/lib/guard/ui.rb +4 -1
- data/lib/guard/version.rb +1 -1
- data/lib/guard/version.rb.orig +1 -1
- data/lib/guard/watcher.rb +3 -1
- data/lib/guard/watcher.rb.orig +122 -0
- data/man/guard.1 +1 -4
- data/man/guard.1.html +1 -4
- metadata +17 -25
- data/lib/guard/commander.rb.orig +0 -103
- data/lib/guard/commands/all.rb.orig +0 -36
- data/lib/guard/commands/reload.rb.orig +0 -34
- data/lib/guard/commands/scope.rb.orig +0 -36
- data/lib/guard/deprecated_methods.rb +0 -72
- data/lib/guard/deprecated_methods.rb.orig +0 -71
- data/lib/guard/deprecator.rb +0 -133
- data/lib/guard/deprecator.rb.orig +0 -206
- data/lib/guard/guard.rb +0 -100
- data/lib/guard/guard.rb.orig +0 -42
- data/lib/guard/guardfile.rb.orig +0 -43
- data/lib/guard/guardfile/evaluator.rb.orig +0 -275
- data/lib/guard/internals/debugging.rb.orig +0 -0
- data/lib/guard/internals/environment.rb.orig +0 -0
- data/lib/guard/internals/tracing.rb.orig +0 -0
- data/lib/guard/notifiers/base.rb.orig +0 -221
- data/lib/guard/notifiers/tmux.rb.orig +0 -339
- data/lib/guard/plugin_util.rb.orig +0 -186
- data/lib/guard/runner.rb.orig +0 -210
- data/lib/guard/setuper.rb +0 -359
- data/lib/guard/setuper.rb.orig +0 -395
- data/lib/guard/ui.rb.orig +0 -278
data/lib/guard/notifier.rb
CHANGED
@@ -2,17 +2,10 @@ require "yaml"
|
|
2
2
|
require "rbconfig"
|
3
3
|
require "pathname"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
-
|
72
|
-
ENV["GUARD_NOTIFIERS"] ? YAML::load(ENV["GUARD_NOTIFIERS"]) : []
|
75
|
+
class NotServer < RuntimeError
|
73
76
|
end
|
74
77
|
|
75
|
-
def
|
76
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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.
|
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
|
-
|
93
|
-
|
94
|
-
end
|
111
|
+
_check_server!
|
112
|
+
return unless enabled?
|
95
113
|
|
96
|
-
if
|
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
|
-
|
107
|
-
end
|
116
|
+
silent = opts[:silent]
|
108
117
|
|
109
|
-
|
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
|
-
|
117
|
-
notifier_class = _get_notifier_module(notifier[:name])
|
128
|
+
_check_server!
|
118
129
|
|
119
|
-
|
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
|
-
|
136
|
+
_env.notify_active = false
|
123
137
|
end
|
124
138
|
|
125
139
|
# Toggle the system notifications on/off
|
126
|
-
#
|
127
140
|
def toggle
|
128
|
-
|
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
|
-
|
132
|
-
turn_on
|
149
|
+
return
|
133
150
|
end
|
151
|
+
|
152
|
+
turn_on
|
134
153
|
end
|
135
154
|
|
136
|
-
# Test if the notifications
|
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
|
-
|
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
|
152
|
-
|
172
|
+
def add(name, opts = {})
|
173
|
+
_check_server!
|
153
174
|
|
154
|
-
|
175
|
+
return false unless enabled?
|
155
176
|
|
156
|
-
if
|
157
|
-
|
158
|
-
|
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,
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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
|
-
|
183
|
-
|
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
|
-
|
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
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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
|
-
|
218
|
-
|
219
|
-
|
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
|
data/lib/guard/notifier.rb.orig
CHANGED
@@ -2,17 +2,10 @@ require "yaml"
|
|
2
2
|
require "rbconfig"
|
3
3
|
require "pathname"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
-
|
72
|
-
ENV["GUARD_NOTIFIERS"] ? YAML::load(ENV["GUARD_NOTIFIERS"]) : []
|
75
|
+
class NotServer < RuntimeError
|
73
76
|
end
|
74
77
|
|
75
|
-
def
|
76
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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.
|
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
|
-
|
93
|
-
|
94
|
-
end
|
111
|
+
_check_server!
|
112
|
+
return unless enabled?
|
95
113
|
|
96
|
-
if
|
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
|
-
|
107
|
-
end
|
116
|
+
silent = opts[:silent]
|
108
117
|
|
109
|
-
|
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
|
-
|
117
|
-
notifier_class = _get_notifier_module(notifier[:name])
|
128
|
+
_check_server!
|
118
129
|
|
119
|
-
|
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
|
-
|
136
|
+
_env.notify_active = false
|
123
137
|
end
|
124
138
|
|
125
139
|
# Toggle the system notifications on/off
|
126
|
-
#
|
127
140
|
def toggle
|
128
|
-
|
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
|
-
|
132
|
-
turn_on
|
149
|
+
return
|
133
150
|
end
|
151
|
+
|
152
|
+
turn_on
|
134
153
|
end
|
135
154
|
|
136
|
-
# Test if the notifications
|
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
|
-
|
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
|
152
|
-
|
172
|
+
def add(name, opts = {})
|
173
|
+
_check_server!
|
153
174
|
|
154
|
-
|
175
|
+
return false unless enabled?
|
155
176
|
|
156
|
-
if
|
157
|
-
|
158
|
-
|
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,
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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
|
-
|
183
|
-
|
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
|
-
|
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
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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
|
-
|
218
|
-
|
219
|
-
|
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
|