guard 1.5.4 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +44 -2
- data/README.md +55 -2
- data/lib/guard.rb +84 -12
- data/lib/guard/cli.rb +12 -3
- data/lib/guard/commands/scope.rb +32 -0
- data/lib/guard/dsl.rb +64 -12
- data/lib/guard/group.rb +1 -1
- data/lib/guard/guard.rb +14 -4
- data/lib/guard/guardfile.rb +21 -0
- data/lib/guard/interactor.rb +99 -17
- data/lib/guard/notifier.rb +7 -0
- data/lib/guard/notifiers/emacs.rb +11 -9
- data/lib/guard/notifiers/gntp.rb +1 -1
- data/lib/guard/notifiers/tmux.rb +60 -4
- data/lib/guard/runner.rb +48 -6
- data/lib/guard/ui.rb +16 -8
- data/lib/guard/version.rb +1 -1
- data/man/guard.1 +5 -2
- data/man/guard.1.html +8 -4
- metadata +10 -9
data/lib/guard/notifiers/gntp.rb
CHANGED
@@ -57,7 +57,7 @@ module Guard
|
|
57
57
|
# @return [Boolean] the availability status
|
58
58
|
#
|
59
59
|
def available?(silent = false)
|
60
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin|linux|freebsd|openbsd|sunos|solaris|mswin|mingw/
|
60
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin|linux|freebsd|openbsd|sunos|solaris|mswin|mingw|cygwin/
|
61
61
|
require 'ruby_gntp'
|
62
62
|
true
|
63
63
|
|
data/lib/guard/notifiers/tmux.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module Guard
|
2
2
|
module Notifier
|
3
3
|
|
4
|
-
# Default options for Tmux
|
5
|
-
|
6
4
|
# Changes the color of the Tmux status bar and optionally
|
7
5
|
# shows messages in the status bar.
|
8
6
|
#
|
@@ -18,6 +16,7 @@ module Guard
|
|
18
16
|
module Tmux
|
19
17
|
extend self
|
20
18
|
|
19
|
+
# Default options for Tmux
|
21
20
|
DEFAULTS = {
|
22
21
|
:client => 'tmux',
|
23
22
|
:tmux_environment => 'TMUX',
|
@@ -62,9 +61,10 @@ module Guard
|
|
62
61
|
# @option options [Boolean] display_message whether to display a message or not
|
63
62
|
#
|
64
63
|
def notify(type, title, message, image, options = { })
|
65
|
-
color = tmux_color
|
64
|
+
color = tmux_color(type, options)
|
66
65
|
color_location = options[:color_location] || DEFAULTS[:color_location]
|
67
|
-
|
66
|
+
|
67
|
+
system("#{ DEFAULTS[:client] } set #{ color_location } #{ color }")
|
68
68
|
|
69
69
|
show_message = options[:display_message] || DEFAULTS[:display_message]
|
70
70
|
display_message(type, title, message, options) if show_message
|
@@ -121,6 +121,62 @@ module Guard
|
|
121
121
|
options[:default] || DEFAULTS[:default]
|
122
122
|
end
|
123
123
|
end
|
124
|
+
|
125
|
+
# Notification starting, save the current Tmux settings
|
126
|
+
# and quiet the Tmux output.
|
127
|
+
#
|
128
|
+
def turn_on(options = { })
|
129
|
+
unless @options_stored
|
130
|
+
reset_options_store
|
131
|
+
|
132
|
+
`#{ DEFAULTS[:client] } show`.each_line do |line|
|
133
|
+
option, _, setting = line.chomp.partition(' ')
|
134
|
+
@options_store[option] = setting
|
135
|
+
end
|
136
|
+
|
137
|
+
@options_stored = true
|
138
|
+
end
|
139
|
+
|
140
|
+
system("#{ DEFAULTS[:client] } set quiet on")
|
141
|
+
end
|
142
|
+
|
143
|
+
# Notification stopping. Restore the previous Tmux state
|
144
|
+
# if available (existing options are restored, new options
|
145
|
+
# are unset) and unquite the Tmux output.
|
146
|
+
#
|
147
|
+
def turn_off(options = { })
|
148
|
+
if @options_stored
|
149
|
+
@options_store.each do |key, value|
|
150
|
+
if value
|
151
|
+
system("#{ DEFAULTS[:client] } set #{ key } #{ value }")
|
152
|
+
else
|
153
|
+
system("#{ DEFAULTS[:client] } set -u #{ key }")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
reset_options_store
|
158
|
+
end
|
159
|
+
|
160
|
+
system("#{ DEFAULTS[:client] } set quiet off")
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
# Reset the internal Tmux options store defaults.
|
166
|
+
#
|
167
|
+
def reset_options_store
|
168
|
+
@options_stored = false
|
169
|
+
@options_store = {
|
170
|
+
'status-left-bg' => nil,
|
171
|
+
'status-right-bg' => nil,
|
172
|
+
'status-left-fg' => nil,
|
173
|
+
'status-right-fg' => nil,
|
174
|
+
'message-bg' => nil,
|
175
|
+
'message-fg' => nil,
|
176
|
+
'display-time' => nil
|
177
|
+
}
|
178
|
+
end
|
179
|
+
|
124
180
|
end
|
125
181
|
end
|
126
182
|
end
|
data/lib/guard/runner.rb
CHANGED
@@ -7,7 +7,7 @@ module Guard
|
|
7
7
|
require 'guard'
|
8
8
|
require 'guard/ui'
|
9
9
|
require 'guard/watcher'
|
10
|
-
|
10
|
+
|
11
11
|
require 'lumberjack'
|
12
12
|
|
13
13
|
# Deprecation message for the `run_on_change` method
|
@@ -153,18 +153,23 @@ module Guard
|
|
153
153
|
|
154
154
|
# Loop through all groups and run the given task for each Guard plugin.
|
155
155
|
#
|
156
|
+
# If no scope is supplied, the global Guard scope is taken into account.
|
157
|
+
# If both a plugin and a group scope is given, then only the plugin scope
|
158
|
+
# is used.
|
159
|
+
#
|
156
160
|
# Stop the task run for the all Guard plugins within a group if one Guard
|
157
161
|
# throws `:task_has_failed`.
|
158
162
|
#
|
159
|
-
# @param [Hash] scopes hash with
|
163
|
+
# @param [Hash] scopes hash with plugins or a groups scope
|
160
164
|
# @yield the task to run
|
161
165
|
#
|
162
166
|
def scoped_guards(scopes = {})
|
163
|
-
if
|
164
|
-
|
167
|
+
if guards = current_plugins_scope(scopes)
|
168
|
+
guards.each do |guard|
|
169
|
+
yield(guard)
|
170
|
+
end
|
165
171
|
else
|
166
|
-
|
167
|
-
groups.each do |group|
|
172
|
+
current_groups_scope(scopes).each do |group|
|
168
173
|
catch :task_has_failed do
|
169
174
|
::Guard.guards(:group => group.name).each do |guard|
|
170
175
|
yield(guard)
|
@@ -188,5 +193,42 @@ module Guard
|
|
188
193
|
(REMOVAL_TASKS.any? { |task| guard.respond_to?(task) } && !removed_paths.empty?)
|
189
194
|
end
|
190
195
|
|
196
|
+
# Returns the current plugins scope.
|
197
|
+
# Local plugins scope wins over global plugins scope.
|
198
|
+
# If no plugins scope is found, then NO plugins are returned.
|
199
|
+
#
|
200
|
+
# @param [Hash] scopes hash with a local plugins or a groups scope
|
201
|
+
# @return [Array<Guard::Guard>] the plugins to scope to
|
202
|
+
#
|
203
|
+
def current_plugins_scope(scopes)
|
204
|
+
if scopes[:plugins] && !scopes[:plugins].empty?
|
205
|
+
scopes[:plugins]
|
206
|
+
|
207
|
+
elsif !::Guard.scope[:plugins].empty?
|
208
|
+
::Guard.scope[:plugins]
|
209
|
+
|
210
|
+
else
|
211
|
+
nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns the current groups scope.
|
216
|
+
# Local groups scope wins over global groups scope.
|
217
|
+
# If no groups scope is found, then ALL groups are returned.
|
218
|
+
#
|
219
|
+
# @param [Hash] scopes hash with a local plugins or a groups scope
|
220
|
+
# @return [Array<Guard::Group>] the groups to scope to
|
221
|
+
#
|
222
|
+
def current_groups_scope(scopes)
|
223
|
+
if scopes[:groups] && !scopes[:groups].empty?
|
224
|
+
scopes[:groups]
|
225
|
+
|
226
|
+
elsif !::Guard.scope[:groups].empty?
|
227
|
+
::Guard.scope[:groups]
|
228
|
+
|
229
|
+
else
|
230
|
+
::Guard.groups
|
231
|
+
end
|
232
|
+
end
|
191
233
|
end
|
192
234
|
end
|
data/lib/guard/ui.rb
CHANGED
@@ -10,7 +10,7 @@ module Guard
|
|
10
10
|
# processing, please just write it to STDOUT with `puts`.
|
11
11
|
#
|
12
12
|
module UI
|
13
|
-
|
13
|
+
|
14
14
|
class << self
|
15
15
|
|
16
16
|
# Get the Guard::UI logger instance
|
@@ -18,7 +18,7 @@ module Guard
|
|
18
18
|
def logger
|
19
19
|
@logger ||= Lumberjack::Logger.new($stderr, self.options)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
# Get the logger options
|
23
23
|
#
|
24
24
|
# @return [Hash] the logger options
|
@@ -131,27 +131,35 @@ module Guard
|
|
131
131
|
# @param [Hash] scopes hash with a guard or a group scope
|
132
132
|
#
|
133
133
|
def action_with_scopes(action, scopes)
|
134
|
-
|
135
|
-
|
134
|
+
plugins = scopes[:plugins] || []
|
135
|
+
groups = scopes[:groups] || []
|
136
|
+
|
137
|
+
if plugins.empty? && groups.empty?
|
138
|
+
plugins = ::Guard.scope[:plugins] || []
|
139
|
+
groups = ::Guard.scope[:groups] || []
|
140
|
+
end
|
141
|
+
|
142
|
+
scope_message ||= plugins.join(',') unless plugins.empty?
|
143
|
+
scope_message ||= groups.join(',') unless groups.empty?
|
136
144
|
scope_message ||= 'all'
|
137
145
|
|
138
|
-
info "#{action} #{scope_message}"
|
146
|
+
info "#{ action } #{ scope_message }"
|
139
147
|
end
|
140
148
|
|
141
149
|
private
|
142
|
-
|
150
|
+
|
143
151
|
# Filters log messages depending on either the
|
144
152
|
# `:only`` or `:except` option.
|
145
153
|
#
|
146
154
|
# @param [String] plugin the calling plugin name
|
147
155
|
# @yield When the message should be logged
|
148
|
-
# @yieldparam [String] param the calling plugin name
|
156
|
+
# @yieldparam [String] param the calling plugin name
|
149
157
|
#
|
150
158
|
def filter(plugin)
|
151
159
|
only = self.options[:only]
|
152
160
|
except = self.options[:except]
|
153
161
|
plugin = plugin || calling_plugin_name
|
154
|
-
|
162
|
+
|
155
163
|
if (!only && !except) || (only && only.match(plugin)) || (except && !except.match(plugin))
|
156
164
|
yield plugin
|
157
165
|
end
|
data/lib/guard/version.rb
CHANGED
data/man/guard.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "GUARD" "1" "
|
4
|
+
.TH "GUARD" "1" "December 2012" "" ""
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBguard\fR \- Guard keeps an eye on your file modifications\.
|
@@ -30,7 +30,10 @@ The following options are available:
|
|
30
30
|
\fB\-d\fR, \fB\-\-debug\fR Runs Guard in debug mode\.
|
31
31
|
.
|
32
32
|
.P
|
33
|
-
\fB\-g\fR, \fB\-\-group\fR \fIGROUP1\fR \fIGROUP2\fR\.\.\.
|
33
|
+
\fB\-g\fR, \fB\-\-group\fR \fIGROUP1\fR \fIGROUP2\fR\.\.\. Scopes the Guard actions to the groups specified by GROUP1, GROUP2, etc\. Group names should be separated by spaces\. Plugins that don\'t belong to a group are considered global and are always run\.
|
34
|
+
.
|
35
|
+
.P
|
36
|
+
\fB\-P\fR, \fB\-\-plugin\fR \fIPLUGIN1\fR \fIPLUGIN2\fR\.\.\. Scopes the Guard actions to the plugins specified by PLUGIN1, PLUGIN2, etc\. Plugin names should be separated by spaces\.
|
34
37
|
.
|
35
38
|
.P
|
36
39
|
\fB\-w\fR, \fB\-\-watchdir\fR \fIPATH\fR Tells Guard to watch PATH instead of \fB\./\fR\.
|
data/man/guard.1.html
CHANGED
@@ -101,9 +101,13 @@
|
|
101
101
|
Runs Guard in debug mode.</p>
|
102
102
|
|
103
103
|
<p><code>-g</code>, <code>--group</code> <var>GROUP1</var> <var>GROUP2</var>...
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
Scopes the Guard actions to the groups specified by GROUP1, GROUP2, etc.
|
105
|
+
Group names should be separated by spaces.
|
106
|
+
Plugins that don't belong to a group are considered global and are always run.</p>
|
107
|
+
|
108
|
+
<p><code>-P</code>, <code>--plugin</code> <var>PLUGIN1</var> <var>PLUGIN2</var>...
|
109
|
+
Scopes the Guard actions to the plugins specified by PLUGIN1, PLUGIN2, etc.
|
110
|
+
Plugin names should be separated by spaces.</p>
|
107
111
|
|
108
112
|
<p><code>-w</code>, <code>--watchdir</code> <var>PATH</var>
|
109
113
|
Tells Guard to watch PATH instead of <code>./</code>.</p>
|
@@ -181,7 +185,7 @@ https://github.com/guard/guard/blob/master/CHANGELOG.md</p>
|
|
181
185
|
|
182
186
|
<ol class='man-decor man-foot man foot'>
|
183
187
|
<li class='tl'></li>
|
184
|
-
<li class='tc'>
|
188
|
+
<li class='tc'>December 2012</li>
|
185
189
|
<li class='tr'>guard(1)</li>
|
186
190
|
</ol>
|
187
191
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.6.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.6.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: pry
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 2.
|
101
|
+
version: 2.12.0
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.
|
109
|
+
version: 2.12.0
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: guard-rspec
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
117
|
+
version: 2.3.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 2.
|
125
|
+
version: 2.3.0
|
126
126
|
description: Guard is a command line tool to easily handle events on file system modifications.
|
127
127
|
email:
|
128
128
|
- thibaud@thibaud.me
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/guard/commands/notification.rb
|
143
143
|
- lib/guard/commands/pause.rb
|
144
144
|
- lib/guard/commands/reload.rb
|
145
|
+
- lib/guard/commands/scope.rb
|
145
146
|
- lib/guard/commands/show.rb
|
146
147
|
- lib/guard/dsl.rb
|
147
148
|
- lib/guard/dsl_describer.rb
|
@@ -193,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
194
|
version: 1.3.6
|
194
195
|
requirements: []
|
195
196
|
rubyforge_project: guard
|
196
|
-
rubygems_version: 1.8.
|
197
|
+
rubygems_version: 1.8.24
|
197
198
|
signing_key:
|
198
199
|
specification_version: 3
|
199
200
|
summary: Guard keeps an eye on your file modifications
|