guard 2.0.0.pre → 2.0.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -945
- data/README.md +5 -21
- data/lib/guard.rb +2 -0
- data/lib/guard/dsl.rb +6 -26
- data/lib/guard/interactor.rb +39 -15
- data/lib/guard/setuper.rb +1 -1
- data/lib/guard/ui.rb +38 -36
- data/lib/guard/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Before you file an issue, make sure you have read the _[known issues](#issues)_
|
|
23
23
|
* File system changes handled by our awesome [Listen](https://github.com/guard/listen) gem.
|
24
24
|
* Support for visual system notifications.
|
25
25
|
* Huge eco-system with [more than 220](https://rubygems.org/search?query=guard-) Guard plugins.
|
26
|
-
* Tested against Ruby 1.9.
|
26
|
+
* Tested against Ruby 1.9.3, 2.0.0, JRuby (1.9 mode) & Rubinius (1.9 mode).
|
27
27
|
|
28
28
|
#### Screencast
|
29
29
|
|
@@ -603,11 +603,10 @@ used the `watch` method to monitor a directory, but you are not interested in ch
|
|
603
603
|
the ignore method to exclude them.
|
604
604
|
|
605
605
|
This comes in handy when you have large amounts of non-source data in you project. By default
|
606
|
-
[`.rbx`, `.bundle`, `.git`, `.svn`, `log`, `tmp`, `vendor`](https://github.com/guard/listen/blob/master/lib/listen/
|
606
|
+
[`.rbx`, `.bundle`, `.DS_Store`, `.git`, `.hg` ,`.svn`, `bundle`, `log`, `tmp`, `vendor/bundle`](https://github.com/guard/listen/blob/master/lib/listen/silencer.rb#L5-L9)
|
607
607
|
are ignored.
|
608
608
|
|
609
|
-
Please note that method only accept regexps.
|
610
|
-
[Listen README](https://github.com/guard/listen#note-on-the-patterns-for-ignoring-and-filtering-paths).
|
609
|
+
Please note that method only accept regexps. See [Listen README](https://github.com/guard/listen#ignore--ignore).
|
611
610
|
|
612
611
|
To append to the default ignored files and directories, use the `ignore` method:
|
613
612
|
|
@@ -615,7 +614,7 @@ To append to the default ignored files and directories, use the `ignore` method:
|
|
615
614
|
ignore %r{^ignored/path/}, /public/
|
616
615
|
```
|
617
616
|
|
618
|
-
To _replace_
|
617
|
+
To _replace_ any existing ignored files and directories, use the `ignore!` method:
|
619
618
|
|
620
619
|
```ruby
|
621
620
|
ignore! /data/
|
@@ -623,22 +622,7 @@ ignore! /data/
|
|
623
622
|
|
624
623
|
### filter
|
625
624
|
|
626
|
-
|
627
|
-
`watch` method. E.g. if you are watching multiple directories but only interested in changes to the Ruby files, then use
|
628
|
-
the `filter` method.
|
629
|
-
|
630
|
-
Please note that method only accept regexps. More on the
|
631
|
-
[Listen README](https://github.com/guard/listen#note-on-the-patterns-for-ignoring-and-filtering-paths).
|
632
|
-
|
633
|
-
```ruby
|
634
|
-
filter /\.txt$/, /.*\.zip/
|
635
|
-
```
|
636
|
-
|
637
|
-
To _replace_ any existing filter, use the `filter!` method:
|
638
|
-
|
639
|
-
```ruby
|
640
|
-
filter! /\.js$/
|
641
|
-
```
|
625
|
+
Alias of the [ignore](https://github.com/guard/guard#ignore) method.
|
642
626
|
|
643
627
|
### logger
|
644
628
|
|
data/lib/guard.rb
CHANGED
data/lib/guard/dsl.rb
CHANGED
@@ -223,8 +223,9 @@ module Guard
|
|
223
223
|
# @param [Regexp] regexps a pattern (or list of patterns) for ignoring paths
|
224
224
|
#
|
225
225
|
def ignore(*regexps)
|
226
|
-
::Guard.listener
|
226
|
+
::Guard.listener.ignore(*regexps) if ::Guard.listener
|
227
227
|
end
|
228
|
+
alias filter ignore
|
228
229
|
|
229
230
|
# Replaces ignored paths globally
|
230
231
|
#
|
@@ -234,32 +235,11 @@ module Guard
|
|
234
235
|
# @param [Regexp] regexps a pattern (or list of patterns) for ignoring paths
|
235
236
|
#
|
236
237
|
def ignore!(*regexps)
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
# Filters certain paths globally.
|
241
|
-
#
|
242
|
-
# @example Filter some files
|
243
|
-
# filter /\.txt$/, /.*\.zip/
|
244
|
-
#
|
245
|
-
# @param [Regexp] regexps a pattern (or list of patterns) for filtering
|
246
|
-
# paths
|
247
|
-
#
|
248
|
-
def filter(*regexps)
|
249
|
-
::Guard.listener = ::Guard.listener.filter(*regexps) if ::Guard.listener
|
250
|
-
end
|
251
|
-
|
252
|
-
# Replaces filtered paths globally.
|
253
|
-
#
|
254
|
-
# @example Filter only these files
|
255
|
-
# filter! /\.txt$/, /.*\.zip/
|
256
|
-
#
|
257
|
-
# @param [Regexp] regexps a pattern (or list of patterns) for filtering
|
258
|
-
# paths
|
259
|
-
#
|
260
|
-
def filter!(*regexps)
|
261
|
-
::Guard.listener = ::Guard.listener.filter!(*regexps) if ::Guard.listener
|
238
|
+
@ignore_regexps ||= []
|
239
|
+
@ignore_regexps << regexps
|
240
|
+
::Guard.listener.ignore!(@ignore_regexps) if ::Guard.listener
|
262
241
|
end
|
242
|
+
alias filter! ignore!
|
263
243
|
|
264
244
|
# Configures the Guard logger.
|
265
245
|
#
|
data/lib/guard/interactor.rb
CHANGED
@@ -159,21 +159,35 @@ module Guard
|
|
159
159
|
# * Restore prompt after each evaluation.
|
160
160
|
#
|
161
161
|
def _add_hooks
|
162
|
+
_add_load_guard_rc_hook
|
163
|
+
_add_load_project_guard_rc_hook
|
164
|
+
_add_restore_visibility_hook if _stty_exists?
|
165
|
+
end
|
166
|
+
|
167
|
+
# Add a `when_started` hook that loads a global .guardrc if it exists.
|
168
|
+
#
|
169
|
+
def _add_load_guard_rc_hook
|
162
170
|
Pry.config.hooks.add_hook :when_started, :load_guard_rc do
|
163
171
|
(self.class.options[:guard_rc] || GUARD_RC).tap do |p|
|
164
172
|
load p if File.exist?(File.expand_path(p))
|
165
173
|
end
|
166
174
|
end
|
175
|
+
end
|
167
176
|
|
177
|
+
# Add a `when_started` hook that loads a project .guardrc if it exists.
|
178
|
+
#
|
179
|
+
def _add_load_project_guard_rc_hook
|
168
180
|
Pry.config.hooks.add_hook :when_started, :load_project_guard_rc do
|
169
181
|
project_guard_rc = Dir.pwd + '/.guardrc'
|
170
182
|
load project_guard_rc if File.exist?(project_guard_rc)
|
171
183
|
end
|
184
|
+
end
|
172
185
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
186
|
+
# Add a `after_eval` hook that restores visibility after a command is eval.
|
187
|
+
#
|
188
|
+
def _add_restore_visibility_hook
|
189
|
+
Pry.config.hooks.add_hook :after_eval, :restore_visibility do
|
190
|
+
system("stty echo 2>#{ DEV_NULL }")
|
177
191
|
end
|
178
192
|
end
|
179
193
|
|
@@ -243,13 +257,30 @@ module Guard
|
|
243
257
|
end
|
244
258
|
end
|
245
259
|
|
246
|
-
#
|
260
|
+
# Configures the pry prompt to see `guard` instead of
|
247
261
|
# `pry`.
|
248
262
|
#
|
249
263
|
def _configure_prompt
|
250
264
|
Pry.config.prompt = [_prompt('>'), _prompt('*')]
|
251
265
|
end
|
252
266
|
|
267
|
+
# Returns the plugins scope, or the groups scope ready for display in the
|
268
|
+
# prompt.
|
269
|
+
#
|
270
|
+
def _scope_for_prompt
|
271
|
+
[:plugins, :groups].each do |scope_name|
|
272
|
+
return _join_scope(scope_name) unless ::Guard.scope[scope_name].empty?
|
273
|
+
end
|
274
|
+
|
275
|
+
''
|
276
|
+
end
|
277
|
+
|
278
|
+
# Joins the scope corresponding to the given scope name with commas.
|
279
|
+
#
|
280
|
+
def _join_scope_for_prompt(scope_name)
|
281
|
+
::Guard.scope[scope_name].map(&:title).join(',')
|
282
|
+
end
|
283
|
+
|
253
284
|
# Returns a proc that will return itself a string ending with the given
|
254
285
|
# `ending_char` when called.
|
255
286
|
#
|
@@ -258,16 +289,9 @@ module Guard
|
|
258
289
|
history = pry.input_array.size
|
259
290
|
process = ::Guard.listener.paused? ? 'pause' : 'guard'
|
260
291
|
clip = Pry.view_clip(target_self)
|
261
|
-
level
|
262
|
-
|
263
|
-
|
264
|
-
elsif !::Guard.scope[:groups].empty?
|
265
|
-
"{#{ ::Guard.scope[:groups].map(&:title).join(',') }} "
|
266
|
-
else
|
267
|
-
''
|
268
|
-
end
|
269
|
-
|
270
|
-
"[#{ history }] #{ scope }#{ process }(#{ clip })#{ level }#{ending_char} "
|
292
|
+
level = ":#{ nest_level }" unless nest_level.zero?
|
293
|
+
|
294
|
+
"[#{ history }] #{ _scope_for_prompt }#{ process }(#{ clip })#{ level }#{ ending_char } "
|
271
295
|
end
|
272
296
|
end
|
273
297
|
|
data/lib/guard/setuper.rb
CHANGED
@@ -177,7 +177,7 @@ module Guard
|
|
177
177
|
end
|
178
178
|
|
179
179
|
listen_args = @watchdirs + [listener_options]
|
180
|
-
@listener = Listen.to(*listen_args
|
180
|
+
@listener = Listen.to(*listen_args, &listener_callback)
|
181
181
|
end
|
182
182
|
|
183
183
|
# Sets up traps to catch signals used to control Guard.
|
data/lib/guard/ui.rb
CHANGED
@@ -51,10 +51,7 @@ module Guard
|
|
51
51
|
# @option options [String] plugin manually define the calling plugin
|
52
52
|
#
|
53
53
|
def info(message, options = {})
|
54
|
-
|
55
|
-
reset_line if options[:reset]
|
56
|
-
logger.info(message, plugin)
|
57
|
-
end
|
54
|
+
_filtered_logger_message(message, :info, nil, options)
|
58
55
|
end
|
59
56
|
|
60
57
|
# Show a yellow warning message that is prefixed with WARNING.
|
@@ -64,10 +61,7 @@ module Guard
|
|
64
61
|
# @option options [String] plugin manually define the calling plugin
|
65
62
|
#
|
66
63
|
def warning(message, options = {})
|
67
|
-
|
68
|
-
reset_line if options[:reset]
|
69
|
-
logger.warn(color(message, :yellow), plugin)
|
70
|
-
end
|
64
|
+
_filtered_logger_message(message, :warn, :yellow, options)
|
71
65
|
end
|
72
66
|
|
73
67
|
# Show a red error message that is prefixed with ERROR.
|
@@ -77,10 +71,7 @@ module Guard
|
|
77
71
|
# @option options [String] plugin manually define the calling plugin
|
78
72
|
#
|
79
73
|
def error(message, options = {})
|
80
|
-
|
81
|
-
reset_line if options[:reset]
|
82
|
-
logger.error(color(message, :red), plugin)
|
83
|
-
end
|
74
|
+
_filtered_logger_message(message, :error, :red, options)
|
84
75
|
end
|
85
76
|
|
86
77
|
# Show a red deprecation message that is prefixed with DEPRECATION.
|
@@ -91,12 +82,7 @@ module Guard
|
|
91
82
|
# @option options [String] plugin manually define the calling plugin
|
92
83
|
#
|
93
84
|
def deprecation(message, options = {})
|
94
|
-
|
95
|
-
|
96
|
-
filter(options[:plugin]) do |plugin|
|
97
|
-
reset_line if options[:reset]
|
98
|
-
logger.warn(color(message, :yellow), plugin)
|
99
|
-
end
|
85
|
+
warning(message, options) if ::Guard.options.show_deprecations
|
100
86
|
end
|
101
87
|
|
102
88
|
# Show a debug message that is prefixed with DEBUG and a timestamp.
|
@@ -106,10 +92,7 @@ module Guard
|
|
106
92
|
# @option options [String] plugin manually define the calling plugin
|
107
93
|
#
|
108
94
|
def debug(message, options = {})
|
109
|
-
|
110
|
-
reset_line if options[:reset]
|
111
|
-
logger.debug(color(message, :yellow), plugin)
|
112
|
-
end
|
95
|
+
_filtered_logger_message(message, :debug, :yellow, options)
|
113
96
|
end
|
114
97
|
|
115
98
|
# Reset a line.
|
@@ -138,24 +121,27 @@ module Guard
|
|
138
121
|
# @param [String] action the action to show
|
139
122
|
# @param [Hash] scopes hash with a guard or a group scope
|
140
123
|
#
|
141
|
-
def action_with_scopes(action,
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
if plugins.empty? && groups.empty?
|
146
|
-
plugins = ::Guard.scope[:plugins] || []
|
147
|
-
groups = ::Guard.scope[:groups] || []
|
148
|
-
end
|
149
|
-
|
150
|
-
scope_message ||= plugins.map(&:title).join(', ') unless plugins.empty?
|
151
|
-
scope_message ||= groups.map(&:title).join(', ') unless groups.empty?
|
152
|
-
scope_message ||= 'all'
|
124
|
+
def action_with_scopes(action, scope)
|
125
|
+
first_non_blank_scope = _first_non_blank_scope(scope)
|
126
|
+
scope_message = first_non_blank_scope.map(&:title).join(', ') unless first_non_blank_scope.nil?
|
153
127
|
|
154
|
-
info "#{ action } #{ scope_message }"
|
128
|
+
info "#{ action } #{ scope_message || 'all' }"
|
155
129
|
end
|
156
130
|
|
157
131
|
private
|
158
132
|
|
133
|
+
# Returns the first non-blank scope by searching in the given `scope`
|
134
|
+
# hash and in Guard.scope. Returns nil if no non-blank scope is found.
|
135
|
+
#
|
136
|
+
def _first_non_blank_scope(scope)
|
137
|
+
[:plugins, :groups].each do |scope_name|
|
138
|
+
s = scope[scope_name] || ::Guard.scope[scope_name]
|
139
|
+
return s if !s.nil? && !s.empty?
|
140
|
+
end
|
141
|
+
|
142
|
+
nil
|
143
|
+
end
|
144
|
+
|
159
145
|
# Filters log messages depending on either the
|
160
146
|
# `:only`` or `:except` option.
|
161
147
|
#
|
@@ -163,7 +149,7 @@ module Guard
|
|
163
149
|
# @yield When the message should be logged
|
164
150
|
# @yieldparam [String] param the calling plugin name
|
165
151
|
#
|
166
|
-
def
|
152
|
+
def _filter(plugin)
|
167
153
|
only = options.only
|
168
154
|
except = options.except
|
169
155
|
plugin = plugin || calling_plugin_name
|
@@ -173,6 +159,22 @@ module Guard
|
|
173
159
|
end
|
174
160
|
end
|
175
161
|
|
162
|
+
# Display a message of the type `method` and with the color `color_name`
|
163
|
+
# (no color by default) conditionnaly given a `plugin_name`.
|
164
|
+
#
|
165
|
+
# @param [String] plugin_name the calling plugin name
|
166
|
+
# @option options [Boolean] reset whether to clean the output before
|
167
|
+
# @option options [String] plugin manually define the calling plugin
|
168
|
+
#
|
169
|
+
def _filtered_logger_message(message, method, color_name, options = {})
|
170
|
+
message = color(message, color_name) if color_name
|
171
|
+
|
172
|
+
_filter(options[:plugin]) do |plugin|
|
173
|
+
reset_line if options[:reset]
|
174
|
+
logger.send(method, message, plugin)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
176
178
|
# Tries to extract the calling Guard plugin name
|
177
179
|
# from the call stack.
|
178
180
|
#
|
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.0.0.pre
|
4
|
+
version: 2.0.0.pre.2
|
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: 2013-09-
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.0.0.beta.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.0.0.beta.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|