guard 1.6.1 → 1.6.2
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.
- data/CHANGELOG.md +17 -0
- data/LICENSE +2 -2
- data/README.md +46 -29
- data/lib/guard.rb +10 -10
- data/lib/guard/cli.rb +3 -6
- data/lib/guard/commands/show.rb +1 -1
- data/lib/guard/dsl.rb +19 -70
- data/lib/guard/dsl_describer.rb +25 -94
- data/lib/guard/guard.rb +5 -4
- data/lib/guard/interactor.rb +14 -1
- data/lib/guard/ui.rb +4 -1
- data/lib/guard/version.rb +1 -1
- metadata +20 -4
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 1.6.2 - 27 January, 2013
|
2
|
+
|
3
|
+
### Improvements
|
4
|
+
|
5
|
+
- Allow the logger device to be set with the `:device` option. ([@netzpirat][])
|
6
|
+
- Improve `list` and `show` command output. ([@netzpirat][])
|
7
|
+
- [#386][] Replace Pry's reset command. ([@envygeeks][])
|
8
|
+
|
9
|
+
### Bug fixes
|
10
|
+
|
11
|
+
- [#389][] Fix `list` and `show` commands. ([@netzpirat][])
|
12
|
+
- [#387][] Load the users defined guardrc file. ([@envygeeks][])
|
13
|
+
|
1
14
|
## 1.6.1 - 27 December, 2012
|
2
15
|
|
3
16
|
### Improvements
|
@@ -701,6 +714,9 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
|
|
701
714
|
[#376]: https://github.com/guard/guard/issues/376
|
702
715
|
[#377]: https://github.com/guard/guard/issues/377
|
703
716
|
[#378]: https://github.com/guard/guard/issues/378
|
717
|
+
[#386]: https://github.com/guard/guard/issues/386
|
718
|
+
[#387]: https://github.com/guard/guard/issues/387
|
719
|
+
[#389]: https://github.com/guard/guard/issues/389
|
704
720
|
[@Gazer]: https://github.com/Gazer
|
705
721
|
[@Maher4Ever]: https://github.com/Maher4Ever
|
706
722
|
[@alandipert]: https://github.com/alandipert
|
@@ -720,6 +736,7 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
|
|
720
736
|
[@docwhat]: https://github.com/docwhat
|
721
737
|
[@dyfrgi]: https://github.com/dyfrgi
|
722
738
|
[@earlonrails]: https://github.com/earlonrails
|
739
|
+
[@envygeeks]: https://github.com/envygeeks
|
723
740
|
[@etehtsea]: https://github.com/etehtsea
|
724
741
|
[@f1sherman]: https://github.com/f1sherman
|
725
742
|
[@fabioyamate]: https://github.com/fabioyamate
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2009-
|
1
|
+
Copyright (c) 2009-2013 Thibaud Guillaume-Gentil
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Guard [](http://travis-ci.org/guard/guard) [](https://gemnasium.com/guard/guard) [](https://codeclimate.com/github/guard/guard)
|
1
|
+
Guard [](http://badge.fury.io/rb/guard) [](http://travis-ci.org/guard/guard) [](https://gemnasium.com/guard/guard) [](https://codeclimate.com/github/guard/guard)
|
2
2
|
=====
|
3
3
|
|
4
4
|
Guard is a command line tool to easily handle events on file system modifications.
|
@@ -81,12 +81,11 @@ end
|
|
81
81
|
```
|
82
82
|
|
83
83
|
If you're using Windows and at least Ruby 1.9.2, then [Windows Directory Monitor](https://github.com/Maher4Ever/wdm) is
|
84
|
-
more efficient than using `rb-fchange`.
|
85
|
-
impossible to add it to the `Gemfile` for projects developed on multiple platforms.
|
84
|
+
more efficient than using `rb-fchange`.
|
86
85
|
|
87
86
|
```Ruby
|
88
87
|
group :development do
|
89
|
-
gem 'wdm', :require => false
|
88
|
+
gem 'wdm', :platforms => [:mswin, :mingw], :require => false
|
90
89
|
end
|
91
90
|
```
|
92
91
|
|
@@ -361,6 +360,12 @@ $ guard --clear
|
|
361
360
|
$ guard -c # shortcut
|
362
361
|
```
|
363
362
|
|
363
|
+
You can add the following snippet to your `~/.guardrc` to have the clear option always be enabled:
|
364
|
+
|
365
|
+
```
|
366
|
+
Guard.options[:clear] = true
|
367
|
+
```
|
368
|
+
|
364
369
|
#### `-n`/`--notify` option
|
365
370
|
|
366
371
|
System notifications can be disabled:
|
@@ -389,7 +394,7 @@ Scope Guard to certain plugins on start:
|
|
389
394
|
|
390
395
|
```bash
|
391
396
|
$ guard --plugins plugin_name another_plugin_name
|
392
|
-
$ guard -
|
397
|
+
$ guard -P plugin_name another_plugin_name # shortcut
|
393
398
|
```
|
394
399
|
|
395
400
|
#### `-d`/`--debug` option
|
@@ -462,18 +467,19 @@ You can list the available plugins with the `list` task:
|
|
462
467
|
|
463
468
|
```bash
|
464
469
|
$ guard list
|
465
|
-
|
466
|
-
Available
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
470
|
+
+----------+--------------+
|
471
|
+
| Available Guard plugins |
|
472
|
+
+----------+--------------+
|
473
|
+
| Plugin | In Guardfile |
|
474
|
+
+----------+--------------+
|
475
|
+
| Compass | ✘ |
|
476
|
+
| Cucumber | ✘ |
|
477
|
+
| Jammit | ✘ |
|
478
|
+
| Ronn | ✔ |
|
479
|
+
| Rspec | ✔ |
|
480
|
+
| Spork | ✘ |
|
481
|
+
| Yard | ✘ |
|
482
|
+
+----------+--------------+
|
477
483
|
```
|
478
484
|
|
479
485
|
### Show
|
@@ -482,19 +488,25 @@ You can show the structure of the groups and their plugins with the `show` task:
|
|
482
488
|
|
483
489
|
```bash
|
484
490
|
$ guard show
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
Group
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
491
|
+
+---------+--------+-----------------+----------------------------+
|
492
|
+
| Guardfile structure |
|
493
|
+
+---------+--------+-----------------+----------------------------+
|
494
|
+
| Group | Plugin | Option | Value |
|
495
|
+
+---------+--------+-----------------+----------------------------+
|
496
|
+
| Default | | | |
|
497
|
+
| Specs | Rspec | all_after_pass | true |
|
498
|
+
| | | all_on_start | true |
|
499
|
+
| | | cli | "--fail-fast --format doc" |
|
500
|
+
| | | focus_on_failed | false |
|
501
|
+
| | | keep_failed | true |
|
502
|
+
| | | run_all | {} |
|
503
|
+
| | | spec_paths | ["spec"] |
|
504
|
+
| Docs | Ronn | | |
|
505
|
+
+---------+--------+-----------------+----------------------------+
|
494
506
|
```
|
495
507
|
|
496
508
|
This shows the internal structure of the evaluated `Guardfile` or `.Guardfile`, with the `.guard.rb` file. You can
|
497
|
-
read more about these files in the shared configuration section
|
509
|
+
read more about these files in the [shared configuration section](https://github.com/guard/guard#shared-configurations).
|
498
510
|
|
499
511
|
Interactions
|
500
512
|
------------
|
@@ -783,14 +795,16 @@ filter /\.js$/
|
|
783
795
|
|
784
796
|
### logger
|
785
797
|
|
786
|
-
The `logger` method allows you to customize the
|
798
|
+
The `logger` method allows you to customize the [Lumberjack](https://github.com/bdurand/lumberjack) log output to your
|
799
|
+
needs by specifying one or more options like:
|
787
800
|
|
788
801
|
```ruby
|
789
802
|
logger :level => :warn,
|
790
803
|
:template => '[:severity - :time - :progname] :message',
|
791
804
|
:time_format => 'at %I:%M%p',
|
792
805
|
:only => [:rspec, :jasmine, 'coffeescript'],
|
793
|
-
:except => :jammit
|
806
|
+
:except => :jammit,
|
807
|
+
:device => 'guard.log'
|
794
808
|
```
|
795
809
|
|
796
810
|
Log `:level` option must be either `:debug`, `:info`, `:warn` or `:error`. If Guard is started in debug mode, the log
|
@@ -805,6 +819,9 @@ The `:time_format` option directives are the same as Time#strftime or can be `:m
|
|
805
819
|
The `:only` and `:except` are either a string or a symbol, or an array of strings or symbols that matches the name of
|
806
820
|
the Guard plugin name that sends the log message. They cannot be specified at the same time.
|
807
821
|
|
822
|
+
By default the logger uses `$stderr` as device, but you can override this by supplying the `:device` option and set
|
823
|
+
either an IO stream or a filename.
|
824
|
+
|
808
825
|
### Example
|
809
826
|
|
810
827
|
```ruby
|
data/lib/guard.rb
CHANGED
@@ -22,8 +22,8 @@ module Guard
|
|
22
22
|
# The location of user defined templates
|
23
23
|
HOME_TEMPLATES = File.expand_path('~/.guard/templates')
|
24
24
|
|
25
|
-
WINDOWS = RbConfig::CONFIG[
|
26
|
-
DEV_NULL = WINDOWS ?
|
25
|
+
WINDOWS = RbConfig::CONFIG['host_os'] =~ %r!(msdos|mswin|djgpp|mingw)!
|
26
|
+
DEV_NULL = WINDOWS ? 'NUL' : '/dev/null'
|
27
27
|
|
28
28
|
class << self
|
29
29
|
attr_accessor :options, :interactor, :runner, :listener, :lock, :scope, :running
|
@@ -44,12 +44,12 @@ module Guard
|
|
44
44
|
# @deprecated @option options [Boolean] no_vendor ignore vendored dependencies
|
45
45
|
#
|
46
46
|
def setup(options = {})
|
47
|
-
@running
|
48
|
-
@lock
|
49
|
-
@options
|
50
|
-
@watchdir
|
51
|
-
@runner
|
52
|
-
@scope
|
47
|
+
@running = true
|
48
|
+
@lock = Mutex.new
|
49
|
+
@options = options.dup
|
50
|
+
@watchdir = (options[:watchdir] && File.expand_path(options[:watchdir])) || Dir.pwd
|
51
|
+
@runner = ::Guard::Runner.new
|
52
|
+
@scope = { :plugins => [], :groups => [] }
|
53
53
|
|
54
54
|
if options[:debug]
|
55
55
|
Thread.abort_on_exception = true
|
@@ -433,8 +433,8 @@ module Guard
|
|
433
433
|
Gem::Specification.find_all.select do |x|
|
434
434
|
if x.name =~ /^guard-/
|
435
435
|
true
|
436
|
-
elsif x.name !=
|
437
|
-
guard_plugin_path = File.join(x.full_gem_path, "lib/guard/#{x.name}.rb")
|
436
|
+
elsif x.name != 'guard'
|
437
|
+
guard_plugin_path = File.join(x.full_gem_path, "lib/guard/#{ x.name }.rb")
|
438
438
|
File.exists?( guard_plugin_path )
|
439
439
|
end
|
440
440
|
end
|
data/lib/guard/cli.rb
CHANGED
@@ -124,8 +124,7 @@ module Guard
|
|
124
124
|
# @see Guard::DslDescriber.list
|
125
125
|
#
|
126
126
|
def list
|
127
|
-
|
128
|
-
::Guard::DslDescriber.list(options)
|
127
|
+
puts ::Guard::DslDescriber.list(options)
|
129
128
|
end
|
130
129
|
|
131
130
|
desc 'version', 'Show the Guard version'
|
@@ -136,8 +135,7 @@ module Guard
|
|
136
135
|
# @see Guard::VERSION
|
137
136
|
#
|
138
137
|
def version
|
139
|
-
|
140
|
-
::Guard::UI.info "Guard version #{ ::Guard::VERSION }"
|
138
|
+
puts "Guard version #{ ::Guard::VERSION }"
|
141
139
|
end
|
142
140
|
|
143
141
|
desc 'init [GUARDS]', 'Generates a Guardfile at the current directory (if it is not already there) and adds all installed guards or the given GUARDS into it'
|
@@ -182,8 +180,7 @@ module Guard
|
|
182
180
|
# @see Guard::DslDescriber.show
|
183
181
|
#
|
184
182
|
def show
|
185
|
-
|
186
|
-
::Guard::DslDescriber.show(options)
|
183
|
+
puts ::Guard::DslDescriber.show(options)
|
187
184
|
end
|
188
185
|
|
189
186
|
private
|
data/lib/guard/commands/show.rb
CHANGED
data/lib/guard/dsl.rb
CHANGED
@@ -29,58 +29,7 @@ module Guard
|
|
29
29
|
# In addition, if a user configuration `.guard.rb` in your home directory is found, it will
|
30
30
|
# be appended to the current project `Guardfile`.
|
31
31
|
#
|
32
|
-
# @
|
33
|
-
#
|
34
|
-
# notification :growl
|
35
|
-
#
|
36
|
-
# group 'frontend' do
|
37
|
-
# guard 'passenger', :ping => true do
|
38
|
-
# watch('config/application.rb')
|
39
|
-
# watch('config/environment.rb')
|
40
|
-
# watch(%r{^config/environments/.+\.rb})
|
41
|
-
# watch(%r{^config/initializers/.+\.rb})
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# guard 'livereload', :apply_js_live => false do
|
45
|
-
# watch(%r{^app/.+\.(erb|haml)})
|
46
|
-
# watch(%r{^app/helpers/.+\.rb})
|
47
|
-
# watch(%r{^public/javascripts/.+\.js})
|
48
|
-
# watch(%r{^public/stylesheets/.+\.css})
|
49
|
-
# watch(%r{^public/.+\.html})
|
50
|
-
# watch(%r{^config/locales/.+\.yml})
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# group 'backend' do
|
55
|
-
# # Reload the bundle when the Gemfile is modified
|
56
|
-
# guard 'bundler' do
|
57
|
-
# watch('Gemfile')
|
58
|
-
# end
|
59
|
-
#
|
60
|
-
# # for big project you can fine tune the "timeout" before Spork's launch is considered failed
|
61
|
-
# guard 'spork', :wait => 40 do
|
62
|
-
# watch('Gemfile')
|
63
|
-
# watch('config/application.rb')
|
64
|
-
# watch('config/environment.rb')
|
65
|
-
# watch(%r{^config/environments/.+\.rb})
|
66
|
-
# watch(%r{^config/initializers/.+\.rb})
|
67
|
-
# watch('spec/spec_helper.rb')
|
68
|
-
# end
|
69
|
-
#
|
70
|
-
# # use RSpec 2, from the system's gem and with some direct RSpec CLI options
|
71
|
-
# guard 'rspec', :version => 2, :cli => "--color --drb -f doc", :bundler => false do
|
72
|
-
# watch('spec/spec_helper.rb') { "spec" }
|
73
|
-
# watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
74
|
-
# watch('config/routes.rb') { "spec/routing" }
|
75
|
-
# watch(%r{^spec/support/(controllers|acceptance)_helpers\.rb}) { |m| "spec/#{m[1]}" }
|
76
|
-
# watch(%r{^spec/.+_spec\.rb})
|
77
|
-
#
|
78
|
-
# watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
79
|
-
#
|
80
|
-
# watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
81
|
-
# watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
82
|
-
# end
|
83
|
-
# end
|
32
|
+
# @see https://github.com/guard/guard/wiki/Guardfile-examples
|
84
33
|
#
|
85
34
|
class Dsl
|
86
35
|
|
@@ -107,7 +56,7 @@ module Guard
|
|
107
56
|
|
108
57
|
class << self
|
109
58
|
|
110
|
-
|
59
|
+
attr_accessor :options
|
111
60
|
|
112
61
|
# Evaluate the DSL methods in the `Guardfile`.
|
113
62
|
#
|
@@ -119,7 +68,7 @@ module Guard
|
|
119
68
|
def evaluate_guardfile(options = {})
|
120
69
|
raise ArgumentError.new('No option hash passed to evaluate_guardfile!') unless options.is_a?(Hash)
|
121
70
|
|
122
|
-
|
71
|
+
self.options = options.dup
|
123
72
|
|
124
73
|
fetch_guardfile_contents
|
125
74
|
instance_eval_guardfile(guardfile_contents_with_user_config)
|
@@ -129,7 +78,7 @@ module Guard
|
|
129
78
|
#
|
130
79
|
def reevaluate_guardfile
|
131
80
|
before_reevaluate_guardfile
|
132
|
-
::Guard::Dsl.evaluate_guardfile(
|
81
|
+
::Guard::Dsl.evaluate_guardfile(options)
|
133
82
|
after_reevaluate_guardfile
|
134
83
|
end
|
135
84
|
|
@@ -142,7 +91,7 @@ module Guard
|
|
142
91
|
::Guard.setup_groups
|
143
92
|
::Guard::Notifier.clear_notifications
|
144
93
|
|
145
|
-
|
94
|
+
options.delete(:guardfile_contents)
|
146
95
|
end
|
147
96
|
|
148
97
|
# Start Guard and notification and show a message
|
@@ -167,7 +116,7 @@ module Guard
|
|
167
116
|
# @param [String] contents the content to evaluate.
|
168
117
|
#
|
169
118
|
def instance_eval_guardfile(contents)
|
170
|
-
new.instance_eval(contents,
|
119
|
+
new.instance_eval(contents, options[:guardfile_path], 1)
|
171
120
|
rescue
|
172
121
|
::Guard::UI.error "Invalid Guardfile, original error is:\n#{ $! }"
|
173
122
|
end
|
@@ -186,8 +135,8 @@ module Guard
|
|
186
135
|
# @param [String] guardfile_path the path to the Guardfile
|
187
136
|
#
|
188
137
|
def read_guardfile(guardfile_path)
|
189
|
-
|
190
|
-
|
138
|
+
options[:guardfile_path] = guardfile_path
|
139
|
+
options[:guardfile_contents] = File.read(guardfile_path)
|
191
140
|
rescue
|
192
141
|
::Guard::UI.error("Error reading file #{ guardfile_path }")
|
193
142
|
exit 1
|
@@ -197,16 +146,16 @@ module Guard
|
|
197
146
|
# the options as `:guardfile_contents`.
|
198
147
|
#
|
199
148
|
def fetch_guardfile_contents
|
200
|
-
if
|
149
|
+
if options[:guardfile_contents]
|
201
150
|
::Guard::UI.info 'Using inline Guardfile.'
|
202
|
-
|
151
|
+
options[:guardfile_path] = 'Inline Guardfile'
|
203
152
|
|
204
|
-
elsif
|
205
|
-
if File.exist?(
|
206
|
-
read_guardfile(
|
207
|
-
::Guard::UI.info "Using Guardfile at #{
|
153
|
+
elsif options[:guardfile]
|
154
|
+
if File.exist?(options[:guardfile])
|
155
|
+
read_guardfile(options[:guardfile])
|
156
|
+
::Guard::UI.info "Using Guardfile at #{ options[:guardfile] }."
|
208
157
|
else
|
209
|
-
::Guard::UI.error "No Guardfile exists at #{
|
158
|
+
::Guard::UI.error "No Guardfile exists at #{ options[:guardfile] }."
|
210
159
|
exit 1
|
211
160
|
end
|
212
161
|
|
@@ -229,7 +178,7 @@ module Guard
|
|
229
178
|
# @return [String] the Guardfile content
|
230
179
|
#
|
231
180
|
def guardfile_contents
|
232
|
-
|
181
|
+
options ? options[:guardfile_contents] : ''
|
233
182
|
end
|
234
183
|
|
235
184
|
# Get the content of the `Guardfile` and the global
|
@@ -249,7 +198,7 @@ module Guard
|
|
249
198
|
# @return [String] the path to the Guardfile
|
250
199
|
#
|
251
200
|
def guardfile_path
|
252
|
-
|
201
|
+
options ? options[:guardfile_path] : ''
|
253
202
|
end
|
254
203
|
|
255
204
|
# Tests if the current `Guardfile` content is usable.
|
@@ -361,7 +310,7 @@ module Guard
|
|
361
310
|
# @see Guard::DslDescriber
|
362
311
|
#
|
363
312
|
def group(name, options = {})
|
364
|
-
name
|
313
|
+
name = name.to_sym
|
365
314
|
|
366
315
|
if block_given?
|
367
316
|
::Guard.add_group(name.to_s.downcase, options)
|
@@ -536,7 +485,7 @@ module Guard
|
|
536
485
|
end
|
537
486
|
|
538
487
|
if options[:only] && options[:except]
|
539
|
-
::Guard::UI.warning
|
488
|
+
::Guard::UI.warning 'You cannot specify the logger options :only and :except at the same time.'
|
540
489
|
|
541
490
|
options.delete :only
|
542
491
|
options.delete :except
|
data/lib/guard/dsl_describer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Guard
|
2
4
|
|
3
5
|
# The DslDescriber overrides methods to create an internal structure
|
@@ -12,139 +14,68 @@ module Guard
|
|
12
14
|
require 'guard/dsl'
|
13
15
|
require 'guard/ui'
|
14
16
|
|
17
|
+
require 'terminal-table'
|
18
|
+
|
15
19
|
class << self
|
16
20
|
|
17
|
-
#
|
21
|
+
# Setups groups and plugins state and evaluates the DSL methods in the `Guardfile`.
|
18
22
|
#
|
19
23
|
# @option options [Array<Symbol,String>] groups the groups to evaluate
|
20
24
|
# @option options [String] guardfile the path to a valid Guardfile
|
21
25
|
# @option options [String] guardfile_contents a string representing the content of a valid Guardfile
|
22
26
|
# @raise [ArgumentError] when options are not a Hash
|
23
27
|
#
|
24
|
-
def evaluate_guardfile(options = {})
|
25
|
-
|
28
|
+
def evaluate_guardfile(options = { })
|
29
|
+
::Guard.options = { :plugin => [], :group => [] }
|
30
|
+
::Guard.setup_groups
|
31
|
+
::Guard.setup_guards
|
32
|
+
|
26
33
|
super options
|
27
34
|
end
|
28
35
|
|
29
36
|
# List the Guard plugins that are available for use in your system and marks
|
30
37
|
# those that are currently used in your `Guardfile`.
|
31
38
|
#
|
32
|
-
# @example Guard list output
|
33
|
-
#
|
34
|
-
# Available guards:
|
35
|
-
# bundler *
|
36
|
-
# livereload
|
37
|
-
# ronn
|
38
|
-
# rspec *
|
39
|
-
# spork
|
40
|
-
#
|
41
|
-
# See also https://github.com/guard/guard/wiki/List-of-available-Guards
|
42
|
-
# * denotes ones already in your Guardfile
|
43
|
-
#
|
44
39
|
# @param [Hash] options the Guard options
|
45
40
|
#
|
46
41
|
def list(options)
|
47
42
|
evaluate_guardfile(options)
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
installed
|
52
|
-
end
|
53
|
-
|
54
|
-
::Guard::UI.info 'Available guards:'
|
55
|
-
|
56
|
-
::Guard.guard_gem_names.sort.uniq.each do |name|
|
57
|
-
::Guard::UI.info " #{ name }#{ installed_guards.include?(name) ? '*' : '' }"
|
44
|
+
rows = ::Guard.guard_gem_names.sort.uniq.inject([]) do |rows, name|
|
45
|
+
rows << [name.capitalize, ::Guard.guards(name) ? '✔' : '✘']
|
58
46
|
end
|
59
47
|
|
60
|
-
::
|
61
|
-
::Guard::UI.info 'See also https://github.com/guard/guard/wiki/List-of-available-Guards'
|
62
|
-
::Guard::UI.info '* denotes ones already in your Guardfile'
|
48
|
+
Terminal::Table.new(:title => 'Available Guard plugins', :headings => ['Plugin', 'In Guardfile'], :rows => rows)
|
63
49
|
end
|
64
50
|
|
65
51
|
# Shows all Guard plugins and their options that are defined in
|
66
52
|
# the `Guardfile`.
|
67
53
|
#
|
68
|
-
# @example guard show output
|
69
|
-
#
|
70
|
-
# (global):
|
71
|
-
# bundler
|
72
|
-
# coffeescript: input => "app/assets/javascripts", noop => true
|
73
|
-
# jasmine
|
74
|
-
# rspec: cli => "--fail-fast --format Fuubar
|
75
|
-
#
|
76
54
|
# @param [Hash] options the Guard options
|
77
55
|
#
|
78
56
|
def show(options)
|
79
57
|
evaluate_guardfile(options)
|
80
58
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
else
|
86
|
-
::Guard::UI.info '(global):'
|
87
|
-
end
|
88
|
-
|
89
|
-
group[:guards].each do |guard|
|
90
|
-
line = " #{ guard[:name] }"
|
59
|
+
rows = ::Guard.groups.inject([]) do |rows, group|
|
60
|
+
plugins = ''
|
61
|
+
options = ''
|
62
|
+
values = ''
|
91
63
|
|
92
|
-
|
93
|
-
|
94
|
-
end
|
64
|
+
::Guard.guards({ :group => group.name }).each do |plugin|
|
65
|
+
plugins << plugin.to_s
|
95
66
|
|
96
|
-
|
67
|
+
plugin.options.inject({}) { |o, (k, v)| o[k.to_s] = v; o }.sort.each do |name, value|
|
68
|
+
options << name.to_s << "\n"
|
69
|
+
values << value.inspect << "\n"
|
97
70
|
end
|
98
71
|
end
|
99
|
-
end
|
100
72
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
private
|
73
|
+
rows << [group.to_s, plugins, options, values]
|
74
|
+
end
|
105
75
|
|
106
|
-
|
107
|
-
#
|
108
|
-
# @return [Array<Hash>] the structure
|
109
|
-
#
|
110
|
-
def guardfile_structure
|
111
|
-
@@guardfile_structure
|
76
|
+
Terminal::Table.new(:title => 'Guardfile structure', :headings => %w(Group Plugin Option Value), :rows => rows)
|
112
77
|
end
|
113
78
|
|
114
79
|
end
|
115
|
-
|
116
|
-
private
|
117
|
-
|
118
|
-
# Declares a group of guards.
|
119
|
-
#
|
120
|
-
# @param [String] name the group's name called from the CLI
|
121
|
-
# @yield a block where you can declare several guards
|
122
|
-
#
|
123
|
-
# @see Guard::Dsl#group
|
124
|
-
#
|
125
|
-
def group(name)
|
126
|
-
@@guardfile_structure << { :group => name.to_sym, :guards => [] }
|
127
|
-
@group = true
|
128
|
-
|
129
|
-
yield if block_given?
|
130
|
-
|
131
|
-
@group = false
|
132
|
-
end
|
133
|
-
|
134
|
-
# Declares a Guard.
|
135
|
-
#
|
136
|
-
# @param [String] name the Guard name
|
137
|
-
# @param [Hash] options the options accepted by the Guard
|
138
|
-
# @yield a block where you can declare several watch patterns and actions
|
139
|
-
#
|
140
|
-
# @see Guard::Dsl#guard
|
141
|
-
#
|
142
|
-
def guard(name, options = { })
|
143
|
-
@group ||= false
|
144
|
-
node = (@group ? @@guardfile_structure.last : @@guardfile_structure.first)
|
145
|
-
|
146
|
-
node[:guards] << { :name => name, :options => options }
|
147
|
-
end
|
148
|
-
|
149
80
|
end
|
150
81
|
end
|
data/lib/guard/guard.rb
CHANGED
@@ -7,12 +7,12 @@ module Guard
|
|
7
7
|
# depending on user interaction and file modification.
|
8
8
|
#
|
9
9
|
# `run_on_changes` could be implemented to handle all the changes task case (additions,
|
10
|
-
# modifications, removals) in once, or each task can be implemented
|
10
|
+
# modifications, removals) in once, or each task can be implemented separately with a
|
11
11
|
# specific behavior.
|
12
12
|
#
|
13
13
|
# In each of these Guard task methods you have to implement some work when you want to
|
14
14
|
# support this kind of task. The return value of each Guard task method is not evaluated
|
15
|
-
# by Guard, but
|
15
|
+
# by Guard, but it'll be passed to the "_end" hook for further evaluation. You can
|
16
16
|
# throw `:task_has_failed` to indicate that your Guard plugin method was not successful,
|
17
17
|
# and successive Guard plugin tasks will be aborted when the group has set the `:halt_on_fail`
|
18
18
|
# option.
|
@@ -47,6 +47,7 @@ module Guard
|
|
47
47
|
attr_accessor :watchers, :options, :group
|
48
48
|
|
49
49
|
# Initializes a Guard plugin.
|
50
|
+
# Don't do any work here, especially as Guard plugins get initialized even if they are not in an active group!
|
50
51
|
#
|
51
52
|
# @param [Array<Guard::Watcher>] watchers the Guard plugin file watchers
|
52
53
|
# @param [Hash] options the custom Guard plugin options
|
@@ -67,7 +68,7 @@ module Guard
|
|
67
68
|
File.read("#{ ::Guard.locate_guard(name) }/lib/guard/#{ name }/templates/Guardfile")
|
68
69
|
end
|
69
70
|
|
70
|
-
# Initialize the Guard plugin. This will copy the Guardfile template inside the Guard plugin
|
71
|
+
# Initialize the Guard plugin. This will copy the Guardfile template inside the Guard plugin Gem.
|
71
72
|
# The template Guardfile must be located within the Gem at `lib/guard/guard-name/templates/Guardfile`.
|
72
73
|
#
|
73
74
|
# @param [String] name the name of the Guard plugin
|
@@ -89,7 +90,7 @@ module Guard
|
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
92
|
-
#
|
93
|
+
# Called once when Guard starts. Please override initialize method to init stuff.
|
93
94
|
#
|
94
95
|
# @raise [:task_has_failed] when start has failed
|
95
96
|
# @return [Object] the task result
|
data/lib/guard/interactor.rb
CHANGED
@@ -91,6 +91,7 @@ module Guard
|
|
91
91
|
|
92
92
|
add_hooks
|
93
93
|
|
94
|
+
replace_reset_command
|
94
95
|
create_run_all_command
|
95
96
|
create_command_aliases
|
96
97
|
create_guard_commands
|
@@ -106,7 +107,9 @@ module Guard
|
|
106
107
|
#
|
107
108
|
def add_hooks
|
108
109
|
Pry.config.hooks.add_hook :when_started, :load_guard_rc do
|
109
|
-
|
110
|
+
(self.class.options[:guard_rc] || GUARD_RC).tap do |p|
|
111
|
+
load p if File.exist?(File.expand_path(p))
|
112
|
+
end
|
110
113
|
end
|
111
114
|
|
112
115
|
if stty_exists?
|
@@ -116,6 +119,16 @@ module Guard
|
|
116
119
|
end
|
117
120
|
end
|
118
121
|
|
122
|
+
# Replaces reset defined inside of Pry with a reset that
|
123
|
+
# instead restarts guard.
|
124
|
+
|
125
|
+
def replace_reset_command
|
126
|
+
Pry.commands.command "reset", "Reset the Guard to a clean state." do
|
127
|
+
output.puts "Guard reset."
|
128
|
+
exec "guard"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
119
132
|
# Creates a command that triggers the `:run_all` action
|
120
133
|
# when the command is empty (just pressing enter on the
|
121
134
|
# beginning of a line).
|
data/lib/guard/ui.rb
CHANGED
@@ -16,7 +16,10 @@ module Guard
|
|
16
16
|
# Get the Guard::UI logger instance
|
17
17
|
#
|
18
18
|
def logger
|
19
|
-
@logger ||=
|
19
|
+
@logger ||= begin
|
20
|
+
options = self.options.dup
|
21
|
+
Lumberjack::Logger.new(options.delete(:device) || $stderr, options)
|
22
|
+
end
|
20
23
|
end
|
21
24
|
|
22
25
|
# Get the logger options
|
data/lib/guard/version.rb
CHANGED
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.6.
|
4
|
+
version: 1.6.2
|
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:
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.0.2
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: terminal-table
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.4.3
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.4.3
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: bundler
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +130,7 @@ dependencies:
|
|
114
130
|
requirements:
|
115
131
|
- - ~>
|
116
132
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
133
|
+
version: 2.4.0
|
118
134
|
type: :development
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +138,7 @@ dependencies:
|
|
122
138
|
requirements:
|
123
139
|
- - ~>
|
124
140
|
- !ruby/object:Gem::Version
|
125
|
-
version: 2.
|
141
|
+
version: 2.4.0
|
126
142
|
description: Guard is a command line tool to easily handle events on file system modifications.
|
127
143
|
email:
|
128
144
|
- thibaud@thibaud.me
|