guard 2.6.0 → 2.6.1
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 +1 -1
- data/lib/guard.rb +1 -1
- data/lib/guard/notifiers/notifysend.rb +1 -1
- data/lib/guard/notifiers/tmux.rb +14 -12
- data/lib/guard/runner.rb +11 -1
- data/lib/guard/setuper.rb +63 -25
- data/lib/guard/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0397104f7cae5c27eb8622dce9e0bc6ed87aee5
|
4
|
+
data.tar.gz: cd203c2e48e94275ea4216ae408ff674a6585175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccfc1e22709ef26e1c904956c9925058fac6d791ea9123dabbde1df189f0de9fda9b38bb87ac7ac3db36ed4bd93b8ec6f8ea4fe371e7e0efbd6b81dfb5559089
|
7
|
+
data.tar.gz: d7aeedb746d432f07b701c70e78814e445e4800d2ca0b59692ed4f652f6659022589a06627f0424ff1c0697dd280ddcb0433233ad216aa5270f97022eddd963b
|
data/README.md
CHANGED
@@ -785,7 +785,7 @@ Please try to follow these simple rules:
|
|
785
785
|
|
786
786
|
#### Core Team
|
787
787
|
|
788
|
-
* [Michael Kessler](https://github.com/netzpirat) ([@netzpirat](http://twitter.com/netzpirat), [flinkfinger.com](http://www.flinkfinger.com))
|
788
|
+
* R.I.P. :broken_heart: [Michael Kessler](https://github.com/netzpirat) ([@netzpirat](http://twitter.com/netzpirat), [flinkfinger.com](http://www.flinkfinger.com))
|
789
789
|
* [Rémy Coutable](https://github.com/rymai)
|
790
790
|
* [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg), [thibaud.gg](http://thibaud.gg/))
|
791
791
|
|
data/lib/guard.rb
CHANGED
@@ -46,7 +46,7 @@ module Guard
|
|
46
46
|
# Guard.plugins(name: 'rspec', group: 'backend')
|
47
47
|
#
|
48
48
|
# @param [String, Symbol, Regexp, Hash] filter the filter to apply to the plugins
|
49
|
-
# @return [
|
49
|
+
# @return [Array<Plugin>] the filtered plugin(s)
|
50
50
|
#
|
51
51
|
def plugins(filter = nil)
|
52
52
|
@plugins ||= []
|
@@ -87,7 +87,7 @@ module Guard
|
|
87
87
|
# @return [String] the notify-send urgency
|
88
88
|
#
|
89
89
|
def _notifysend_urgency(type)
|
90
|
-
{
|
90
|
+
{ failed: 'normal', pending: 'low' }.fetch(type, 'low')
|
91
91
|
end
|
92
92
|
|
93
93
|
# Builds a shell command out of a command string and option hash.
|
data/lib/guard/notifiers/tmux.rb
CHANGED
@@ -102,7 +102,7 @@ module Guard
|
|
102
102
|
color = tmux_color(opts[:type], opts)
|
103
103
|
|
104
104
|
color_locations.each do |color_location|
|
105
|
-
_run_client "set","
|
105
|
+
_run_client "set","#{_quiet_option}#{ color_location } #{ color }"
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -137,11 +137,7 @@ module Guard
|
|
137
137
|
teaser_message = message.split("\n").first
|
138
138
|
display_title = title_format % [title, teaser_message]
|
139
139
|
|
140
|
-
|
141
|
-
_run_client "set-option", "-q set-titles-string '#{ display_title }'"
|
142
|
-
else
|
143
|
-
_run_client "set-option", "set-titles-string '#{ display_title }'"
|
144
|
-
end
|
140
|
+
_run_client "set-option", "#{_quiet_option}set-titles-string '#{ display_title }'"
|
145
141
|
end
|
146
142
|
|
147
143
|
# Displays a message in the status bar of tmux.
|
@@ -182,11 +178,11 @@ module Guard
|
|
182
178
|
formatted_message = message.split("\n").join(separator)
|
183
179
|
display_message = message_format % [title, formatted_message]
|
184
180
|
|
185
|
-
_run_client "set", "
|
186
|
-
_run_client "set", "
|
187
|
-
_run_client "set", "
|
181
|
+
_run_client "set", "#{_quiet_option}display-time #{ display_time * 1000 }"
|
182
|
+
_run_client "set", "#{_quiet_option}message-fg #{ message_color }"
|
183
|
+
_run_client "set", "#{_quiet_option}message-bg #{ color }"
|
188
184
|
_run_client "display-message", "'#{ display_message }'"
|
189
|
-
|
185
|
+
end
|
190
186
|
|
191
187
|
# Get the Tmux color for the notification type.
|
192
188
|
# You can configure your own color by overwriting the defaults.
|
@@ -251,11 +247,13 @@ module Guard
|
|
251
247
|
end
|
252
248
|
|
253
249
|
def self._clients
|
254
|
-
`#{ DEFAULTS[:client] } list-clients -F '\#{
|
250
|
+
ttys = `#{ DEFAULTS[:client] } list-clients -F '\#{client_tty}'`.split(/\n/)
|
251
|
+
ttys.delete('(null)') #if user is running 'tmux -C' remove this client from list
|
252
|
+
ttys
|
255
253
|
end
|
256
254
|
|
257
255
|
def _clients
|
258
|
-
self.class.
|
256
|
+
self.class._clients
|
259
257
|
end
|
260
258
|
|
261
259
|
def _run_client(cmd, args)
|
@@ -298,6 +296,10 @@ module Guard
|
|
298
296
|
@tmux_version ||= `tmux -V`.chomp.gsub(/[^0-9.]/, '').to_f
|
299
297
|
end
|
300
298
|
|
299
|
+
def _quiet_option
|
300
|
+
'-q ' if _tmux_version >= 1.7
|
301
|
+
end
|
302
|
+
|
301
303
|
end
|
302
304
|
|
303
305
|
end
|
data/lib/guard/runner.rb
CHANGED
@@ -37,6 +37,12 @@ module Guard
|
|
37
37
|
#
|
38
38
|
def run_on_changes(modified, added, removed)
|
39
39
|
::Guard::UI.clearable
|
40
|
+
|
41
|
+
#TODO: this should be handled like every other plugin
|
42
|
+
if ::Guard::Watcher.match_guardfile?(modified)
|
43
|
+
::Guard.evaluator.reevaluate_guardfile
|
44
|
+
end
|
45
|
+
|
40
46
|
_scoped_plugins do |guard|
|
41
47
|
modified_paths = ::Guard::Watcher.match_files(guard, modified)
|
42
48
|
added_paths = ::Guard::Watcher.match_files(guard, added)
|
@@ -64,7 +70,11 @@ module Guard
|
|
64
70
|
begin
|
65
71
|
catch self.class.stopping_symbol_for(guard) do
|
66
72
|
guard.hook("#{ task }_begin", *args)
|
67
|
-
|
73
|
+
begin
|
74
|
+
result = guard.send(task, *args)
|
75
|
+
rescue Interrupt
|
76
|
+
throw(:task_has_failed)
|
77
|
+
end
|
68
78
|
guard.hook("#{ task }_end", result)
|
69
79
|
result
|
70
80
|
end
|
data/lib/guard/setuper.rb
CHANGED
@@ -120,6 +120,8 @@ module Guard
|
|
120
120
|
@scope = { groups: [], plugins: [] }
|
121
121
|
end
|
122
122
|
|
123
|
+
attr_reader :watchdirs
|
124
|
+
|
123
125
|
# Stores the scopes defined by the user via the `--group` / `-g` option (to run
|
124
126
|
# only a specific group) or the `--plugin` / `-P` option (to run only a
|
125
127
|
# specific plugin).
|
@@ -172,35 +174,15 @@ module Guard
|
|
172
174
|
# Initializes the listener and registers a callback for changes.
|
173
175
|
#
|
174
176
|
def _setup_listener
|
175
|
-
listener_callback = lambda do |modified, added, removed|
|
176
|
-
# Convert to relative paths (respective to the watchdir it came from)
|
177
|
-
@watchdirs.each do |watchdir|
|
178
|
-
[modified, added, removed].each do |paths|
|
179
|
-
paths.map! do |path|
|
180
|
-
if path.start_with? watchdir
|
181
|
-
path.sub "#{watchdir}#{File::SEPARATOR}", ''
|
182
|
-
else
|
183
|
-
path
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
evaluator.reevaluate_guardfile if ::Guard::Watcher.match_guardfile?(modified)
|
189
|
-
|
190
|
-
within_preserved_state do
|
191
|
-
runner.run_on_changes(modified, added, removed)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
177
|
if options[:listen_on]
|
196
|
-
@listener = Listen.on(options[:listen_on], &
|
178
|
+
@listener = Listen.on(options[:listen_on], &_listener_callback)
|
197
179
|
else
|
198
180
|
listener_options = {}
|
199
181
|
[:latency, :force_polling, :wait_for_delay].each do |option|
|
200
182
|
listener_options[option] = options[option] if options[option]
|
201
183
|
end
|
202
|
-
listen_args =
|
203
|
-
@listener = Listen.to(*listen_args, &
|
184
|
+
listen_args = watchdirs + [listener_options]
|
185
|
+
@listener = Listen.to(*listen_args, &_listener_callback)
|
204
186
|
end
|
205
187
|
end
|
206
188
|
|
@@ -214,11 +196,19 @@ module Guard
|
|
214
196
|
def _setup_signal_traps
|
215
197
|
unless defined?(JRUBY_VERSION)
|
216
198
|
if Signal.list.keys.include?('USR1')
|
217
|
-
Signal.trap('USR1')
|
199
|
+
Signal.trap('USR1') do
|
200
|
+
unless listener.paused?
|
201
|
+
Thread.new { within_preserved_state { ::Guard.pause } }
|
202
|
+
end
|
203
|
+
end
|
218
204
|
end
|
219
205
|
|
220
206
|
if Signal.list.keys.include?('USR2')
|
221
|
-
Signal.trap('USR2')
|
207
|
+
Signal.trap('USR2') do
|
208
|
+
if listener.paused?
|
209
|
+
Thread.new { within_preserved_state { ::Guard.pause } }
|
210
|
+
end
|
211
|
+
end
|
222
212
|
end
|
223
213
|
|
224
214
|
if Signal.list.keys.include?('INT')
|
@@ -260,5 +250,53 @@ module Guard
|
|
260
250
|
end
|
261
251
|
end
|
262
252
|
|
253
|
+
# Check if any of the changes are actually watched for
|
254
|
+
#
|
255
|
+
# NOTE: this is called from the listen thread - be careful to not
|
256
|
+
# modify any state
|
257
|
+
#
|
258
|
+
# TODO: move this to watcher class?
|
259
|
+
#
|
260
|
+
def _relevant_changes?(changes)
|
261
|
+
# TODO: make a Guardfile reloader "plugin" instead of a special case
|
262
|
+
return true if ::Guard::Watcher.match_guardfile?(changes[:modified])
|
263
|
+
|
264
|
+
# TODO: ignoring irrelevant files should be Listen's responsibility
|
265
|
+
all_files = changes.values.flatten(1)
|
266
|
+
runner.send(:_scoped_plugins) do |guard|
|
267
|
+
return true if ::Guard::Watcher.match_files?([guard], all_files)
|
268
|
+
end
|
269
|
+
false
|
270
|
+
end
|
271
|
+
|
272
|
+
def _relative_paths(changes)
|
273
|
+
# Convert to relative paths (respective to the watchdir it came from)
|
274
|
+
watchdirs.each do |watchdir|
|
275
|
+
changes.each do |type, paths|
|
276
|
+
paths.each do |path|
|
277
|
+
if path.start_with? watchdir
|
278
|
+
path.sub! "#{watchdir}#{File::SEPARATOR}", ''
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def _listener_callback
|
286
|
+
lambda do |modified, added, removed|
|
287
|
+
all_changes = { modified: modified.dup,
|
288
|
+
added: added.dup,
|
289
|
+
removed: removed.dup }
|
290
|
+
|
291
|
+
# TODO: this should be Listen's responsibility
|
292
|
+
_relative_paths(all_changes)
|
293
|
+
|
294
|
+
if _relevant_changes?(all_changes)
|
295
|
+
within_preserved_state do
|
296
|
+
runner.run_on_changes(*all_changes.values)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
263
301
|
end
|
264
302
|
end
|
data/lib/guard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibaud Guillaume-Gentil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.2.
|
168
|
+
rubygems_version: 2.2.2
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: Guard keeps an eye on your file modifications
|