guard 0.4.0 → 0.5.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.
data/CHANGELOG.md ADDED
@@ -0,0 +1,195 @@
1
+ ## 0.5.0 - July 2, 2011
2
+
3
+ ## New features
4
+
5
+ - Guard::Ego is now part of Guard, so Guardfile is automagically re-evaluated when modified. ([@thibaudgg][])
6
+ - Pull request [#91](https://github.com/guard/guard/pull/91): Show Guards in Guardfile with the `guard -T`. ([@johnbintz][])
7
+
8
+ ## Improvements
9
+
10
+ - Issue [#98](https://github.com/guard/guard/issues/98): Multiple calls per watch event on linux with rb-inotify. ([@jeffutter][] & [@netzpirat][])
11
+ - Pull request [#94](https://github.com/guard/guard/pull/94): Show backtrace in terminal when a problem with a watch action occurs. ([@capotej][])
12
+ - Pull request [#88](https://github.com/guard/guard/pull/88): Write exception trace in the terminal when a supervised task fail. ([@mcmire][])
13
+ - Color in red the "ERROR:" flag when using `UI.error`. ([@rymai][])
14
+ - Issue [#79](https://github.com/guard/guard/issues/79) and Pull request [#82](https://github.com/guard/guard/pull/82): Improve INotify support on Linux. ([@Gazer][] & [@yannlugrin][])
15
+ - Issue [#12](https://github.com/guard/guard/issues/12) and Pull request [#86](https://github.com/guard/guard/pull/86): Eventually exits with SystemStackError. ([@stereobooster][])
16
+ - Pull request [#84](https://github.com/guard/guard/pull/84): Use RbConfig instead of obsolete and deprecated Config. ([@etehtsea][])
17
+ - Pull request [#80](https://github.com/guard/guard/pull/80): Watching dotfile (hidden files under unix). (reported by [@chrisberkhout][], fixed by [@yannlugrin][])
18
+ - Clear the terminal on start when the `:clear` option is given. ([@rymai][])
19
+ - Rename home directory Guardfile to `.Guardfile`. ([@tpope][])
20
+
21
+ ## 0.4.2 - June 7, 2011
22
+
23
+ ### Bugs fixes:
24
+
25
+ - Fixed Guard::Version in ruby 1.8.7 ([@thibaudgg][])
26
+ - Fix ([@mislav][]) link in CHANGELOG (Note: this is a recursive CHANGELOG item). ([@fnichol][])
27
+
28
+ ## 0.4.1 - June 7, 2011
29
+
30
+ ### Improvements
31
+
32
+ - Pull request [#77](https://github.com/guard/guard/pull/77): Refactor `get_guard_class` to first try the constant and fallback to require + various tweaks. ([@mislav][])
33
+ - Notifier improvement, don't use system notification library if could not be required. ([@yannlugrin][])
34
+
35
+ ## 0.4.0 - June 5, 2011
36
+
37
+ ### Bugs fixes:
38
+
39
+ - In Ruby < 1.9, `Symbol#downcase` doesn't exist! ([@rymai][])
40
+
41
+ ### New features:
42
+
43
+ - Pull request [#73](https://github.com/guard/guard/pull/73): Allow DSL's `group` method to accept a Symbol as group name. ([@johnbintz][])
44
+ - Pull request [#51](https://github.com/guard/guard/pull/51): Allow options (like `:priority`) to be passed through to the Notifier. ([@indirect][] & [@netzpirat][])
45
+
46
+ ### Improvements
47
+
48
+ - Pull request [#74](https://github.com/guard/guard/pull/74): Added link definitions to make the CHANGELOG more DRY! That's for sure now, we have the cleanest CHANGELOG ever! (even the link definitions are sorted alphabetically!) ([@pcreux][])
49
+
50
+ ## 0.4.0.rc - May 28, 2011
51
+
52
+ ### Bugs fixes:
53
+
54
+ - Pull request [#69](https://github.com/guard/guard/pull/69): Fixed typo in README: `Ctr-/` => `Ctr-\`. ([@tinogomes][])
55
+ - Pull request [#66](https://github.com/guard/guard/pull/66): Support for dashes in guard names. ([@johnbintz][])
56
+ - Require `guard/ui` because `Guard::Notifier` can be required without full Guard. ([@yannlugrin][])
57
+ - Handled quick file (<1s) modification. Avoid to catch modified files without content modification (sha1 checksum). ([@thibaudgg][] & [@netzpirat][])
58
+ - Fixed `Guard::Notifier` (when growl/libnotify not present). ([@thibaudgg][])
59
+ - Fixed Rubygems deprecation messages. ([@thibaudgg][])
60
+
61
+ ### New features:
62
+
63
+ - Pull request [#67](https://github.com/guard/guard/pull/67): Allow Guardfile in `$HOME` folder. ([@hashrocketeer][])
64
+ - Pull request [#64](https://github.com/guard/guard/pull/64): Windows notifications support. ([@stereobooster][])
65
+ - Pull request [#63](https://github.com/guard/guard/pull/63): Refactor listeners to work as a library. ([@niklas][])
66
+ - Use `ENV["GUARD_NOTIFY"]` to disable notifications. ([@thibaudgg][])
67
+ - Cleaning up all specs. ([@netzpirat][])
68
+ - Pull request [#60](https://github.com/guard/guard/pull/60): Added Windows support. ([@stereobooster][])
69
+ - Pull request [#58](https://github.com/guard/guard/pull/58): Extract code from signal handlers into methods. ([@nicksieger][])
70
+ - Pull request [#55](https://github.com/guard/guard/pull/55): It is now possible to pass `:guardfile` (a Guardfile path) or `:guardfile_contents` (the content of a Guardfile) to `Guard::Dsl.evaluate_guardfile`. Hence this allows the use of `Guard::Dsl.evaluate_guardfile` in a programmatic manner. ([@anithri][], improved by [@rymai][])
71
+
72
+
73
+ ## 0.3.4 - April 24, 2011
74
+
75
+ ### Bugs fixes:
76
+
77
+ - Issue [#41](https://github.com/guard/guard/issues/41): Removed useless Bundler requirement. ([@thibaudgg][])
78
+
79
+ ### New features:
80
+
81
+ - Changed CHANGELOG from RDOC to Markdown and cleaned it! Let's celebrate! ([@rymai][])
82
+ - Changed README from RDOC to Markdown! Let's celebrate! ([@thibaudgg][])
83
+ - Issue [#48](https://github.com/guard/guard/issues/48): Adding support for inline Guard classes rather than requiring a gem. ([@jrsacks][])
84
+
85
+
86
+ ## 0.3.3 - April 18, 2011
87
+
88
+ ### Bugs fixes:
89
+
90
+ - Fixed `new_modified_files` rerun conditions on `Guard.run_on_change_for_all_guards`. ([@thibaudgg][])
91
+
92
+
93
+ ## 0.3.2 - April 17, 2011
94
+
95
+ ### Bugs fixes:
96
+
97
+ - Pull request [#43](https://github.com/guard/guard/pull/43): Fixed `guard init` command. ([@brainopia][])
98
+
99
+
100
+ ## 0.3.1 - April 14, 2011
101
+
102
+ ### Bugs fixes:
103
+
104
+ - Return unique filenames from Linux listener. (Marian Schubert)
105
+ - `Guard.get_guard_class` return wrong class when loaded nested class. ([@koshigoe][])
106
+ - Issue [#35](https://github.com/guard/guard/issues/35): Fixed open-gem/gem_open dependency problem by using `gem which` to locate guards gem path. (reported by [@thierryhenrio][], fixed by [@thibaudgg][])
107
+ - Issue [#38](https://github.com/guard/guard/issues/38) & Pull request [#39](https://github.com/guard/guard/issues/39): Fixed an invalid ANSI escape code in `Guard::UI.reset_line`. ([@gix][])
108
+
109
+ ### New features:
110
+
111
+ - Issue [#28](https://github.com/guard/guard/issues/28): New `-n` command line option to disable notifications (Growl / Libnotify). ([@thibaudgg][])
112
+
113
+
114
+ ## 0.3.0 - January 19, 2011
115
+
116
+ ### Bugs fixes:
117
+
118
+ - Avoid launching `run_on_change` guards method when no files matched. `--clear` guard argument is now usable. ([@thibaudgg][])
119
+
120
+ ### New features:
121
+
122
+ - The whole directory is now watched during `run_on_change` to detect new files modifications. ([@thibaudgg][])
123
+ - Pull request [#26](https://github.com/guard/guard/pull/26): New DSL method: `group` allows you to group several guards. New CLI option: `--group group_name` to specify certain groups of guards to start. ([@netzpirat][])
124
+ - `watch` patterns are now more strict: strings are matched with `String#==`, `Regexp` are matched with `Regexp#match`. ([@rymai][])
125
+ - A deprecation warning is displayed if your `Guardfile` contains `String` that look like `Regexp` (bad!). ([@rymai][])
126
+ - It's now possible to return an `Enumerable` in the `watch` optional blocks in the `Guardfile`. ([@rymai][])
127
+
128
+ ### New specs:
129
+
130
+ - `Guard::Watcher`. ([@rymai][])
131
+ - Pull request [#13](https://github.com/guard/guard/pull/13): `Guard::Dsl`. ([@oliamb][])
132
+
133
+
134
+ ## 0.2.2 - October 25, 2010
135
+
136
+ ### Bugs fixes:
137
+
138
+ - Issue [#5](https://github.com/guard/guard/issues/5): avoid creating new copy of `fsevent_watch` every time a file is changed. (reported by [@stouset][], fixed by [@thibaudgg][])
139
+
140
+
141
+ ## 0.2.1 - October 24, 2010
142
+
143
+ ### Bugs fixes:
144
+
145
+ - Pull request [#7](https://github.com/guard/guard/pull/7): Fixes for Linux support. ([@yannlugrin][])
146
+ - Pull request [#6](https://github.com/guard/guard/pull/6): Locate guard now chomp newline in result path. ([@yannlugrin][])
147
+
148
+
149
+ ## 0.2.0 - October 21, 2010
150
+
151
+ ### Bugs fixes:
152
+
153
+ - Issue [#3](https://github.com/guard/guard/issues/3): `guard init <guard-name>` no more need `Gemfile` but `open_gem` is required now. (reported by [@wereHamster][], fixed by [@thibaudgg][])
154
+ - Issue [#2](https://github.com/guard/guard/issues/2): 1.8.6 compatibility. (reported by [@veged][], fixed by [@thibaudgg][])
155
+ - Removes Growl & Libnotify dependencies. ([@thibaudgg][])
156
+
157
+
158
+ ## 0.2.0.beta.1 - October 17, 2010
159
+
160
+ ### New features:
161
+
162
+ - Improved listeners support (`rb-fsevent` & `rb-inotify`). ([@thibaudgg][])
163
+ - Added polling listening fallback. ([@thibaudgg][])
164
+
165
+ [@anithri]: https://github.com/anithri
166
+ [@brainopia]: https://github.com/brainopia
167
+ [@capotej]: https://github.com/capotej
168
+ [@chrisberkhout]: https://github.com/chrisberkhout
169
+ [@etehtsea]: https://github.com/etehtsea
170
+ [@fnichol]: https://github.com/fnichol
171
+ [@Gazer]: https://github.com/Gazer
172
+ [@gix]: https://github.com/gix
173
+ [@hashrocketeer]: https://github.com/hashrocketeer
174
+ [@indirect]: https://github.com/indirect
175
+ [@jeffutter]: https://github.com/jeffutter
176
+ [@johnbintz]: https://github.com/johnbintz
177
+ [@jrsacks]: https://github.com/jrsacks
178
+ [@koshigoe]: https://github.com/koshigoe
179
+ [@mcmire]: https://github.com/mcmire
180
+ [@mislav]: https://github.com/mislav
181
+ [@netzpirat]: https://github.com/netzpirat
182
+ [@nicksieger]: https://github.com/nicksieger
183
+ [@niklas]: https://github.com/niklas
184
+ [@oliamb]: https://github.com/oliamb
185
+ [@pcreux]: https://github.com/pcreux
186
+ [@rymai]: https://github.com/rymai
187
+ [@stereobooster]: https://github.com/stereobooster
188
+ [@stouset]: https://github.com/stouset
189
+ [@thibaudgg]: https://github.com/thibaudgg
190
+ [@thierryhenrio]: https://github.com/thierryhenrio
191
+ [@tinogomes]: https://github.com/tinogomes
192
+ [@tpope]: https://github.com/tpope
193
+ [@veged]: https://github.com/veged
194
+ [@wereHamster]: https://github.com/wereHamster
195
+ [@yannlugrin]: https://github.com/yannlugrin
data/README.md CHANGED
@@ -3,7 +3,7 @@ Guard [![Build Status](http://travis-ci.org/guard/guard.png)](http://travis-ci.o
3
3
 
4
4
  Guard is a command line tool that easily handle events on files modifications.
5
5
 
6
- If you have any questions/issues please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
6
+ If you have any questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
7
7
 
8
8
  Features
9
9
  --------
@@ -26,7 +26,7 @@ Install the gem:
26
26
  $ gem install guard
27
27
  ```
28
28
 
29
- Add it to your Gemfile (inside the `test` group):
29
+ Add it to your Gemfile (inside the `development` group):
30
30
 
31
31
  ``` ruby
32
32
  gem 'guard'
@@ -38,7 +38,7 @@ Generate an empty Guardfile with:
38
38
  $ guard init
39
39
  ```
40
40
 
41
- You may optionally place this Guardfile in your home directory to use it across multiple projects.
41
+ You may optionally place a .Guardfile in your home directory to use it across multiple projects.
42
42
 
43
43
  Add the guards you need to your Guardfile (see the existing guards below).
44
44
 
@@ -56,9 +56,10 @@ Install the Growl gem if you want notification support:
56
56
  $ gem install growl
57
57
  ```
58
58
 
59
- And add it to you Gemfile:
59
+ And add them to your Gemfile:
60
60
 
61
61
  ``` ruby
62
+ gem 'rb-fsevent'
62
63
  gem 'growl'
63
64
  ```
64
65
 
@@ -76,9 +77,10 @@ Install the Libnotify gem if you want notification support:
76
77
  $ gem install libnotify
77
78
  ```
78
79
 
79
- And add it to you Gemfile:
80
+ And add them to your Gemfile:
80
81
 
81
82
  ``` ruby
83
+ gem 'rb-inotify'
82
84
  gem 'libnotify'
83
85
  ```
84
86
 
@@ -90,6 +92,19 @@ Install the rb-fchange gem for [Directory Change Notification](http://msdn.micro
90
92
  $ gem install rb-fchange
91
93
  ```
92
94
 
95
+ Install the Notifu gem if you want notification support:
96
+
97
+ ``` bash
98
+ $ gem install rb-notifu
99
+ ```
100
+
101
+ And add them to your Gemfile:
102
+
103
+ ``` ruby
104
+ gem 'rb-fchange'
105
+ gem 'rb-notifu'
106
+ ```
107
+
93
108
  Usage
94
109
  -----
95
110
 
@@ -102,22 +117,26 @@ $ guard [start]
102
117
  or if you use Bundler, to run the Guard executable specific to your bundle:
103
118
 
104
119
  ``` bash
105
- $ bundle exec guard
120
+ $ bundle exec guard [start]
106
121
  ```
107
122
 
108
- Guard will look for a Guardfile in your current directory. If it does not find one, it will look in your `$HOME` directory for one.
123
+ Guard will look for a Guardfile in your current directory. If it does not find one, it will look in your `$HOME` directory for a .Guardfile.
109
124
 
110
125
  Command line options
111
126
  --------------------
112
127
 
113
- Shell can be cleared after each change with:
128
+ ### `--clear` option
129
+
130
+ Shell can be cleared after each change:
114
131
 
115
132
  ``` bash
116
133
  $ guard --clear
117
134
  $ guard -c # shortcut
118
135
  ```
119
136
 
120
- Notifications (growl/libnotify) can be disabled with:
137
+ ### `--notify` option
138
+
139
+ Notifications (growl/libnotify) can be disabled:
121
140
 
122
141
  ``` bash
123
142
  $ guard --notify false
@@ -126,14 +145,25 @@ $ guard -n f # shortcut
126
145
 
127
146
  Notifications can also be disabled globally by setting a `GUARD_NOTIFY` environment variable to `false`
128
147
 
129
- The guards to start can be specified by group (see the Guardfile DSL below) specifying the `--group` (or `-g`) option:
148
+ ### `--group` option
149
+
150
+ Only certain guards groups can be run (see the Guardfile DSL below for creating groups):
130
151
 
131
152
  ``` bash
132
153
  $ guard --group group_name another_group_name
133
154
  $ guard -g group_name another_group_name # shortcut
134
155
  ```
135
156
 
136
- Options list is available with:
157
+ ### `--debug` option
158
+
159
+ Guard can be run in debug mode:
160
+
161
+ ``` bash
162
+ $ guard --debug
163
+ $ guard -d # shortcut
164
+ ```
165
+
166
+ An exhaustive list of options is available with:
137
167
 
138
168
  ``` bash
139
169
  $ guard help [TASK]
@@ -144,20 +174,20 @@ Signal handlers
144
174
 
145
175
  Signal handlers are used to interact with Guard:
146
176
 
147
- * `Ctrl-C` - Calls each guard's `stop` method, in the same order they are declared in the Guardfile, and then quits Guard itself.
148
- * `Ctrl-\` - Calls each guard's `run_all` method, in the same order they are declared in the Guardfile.
149
- * `Ctrl-Z` - Calls each guard's `reload` method, in the same order they are declared in the Guardfile.
177
+ * `Ctrl-C` - Calls each guard's `#stop` method, in the same order they are declared in the Guardfile, and then quits Guard itself.
178
+ * `Ctrl-\` - Calls each guard's `#run_all` method, in the same order they are declared in the Guardfile.
179
+ * `Ctrl-Z` - Calls each guard's `#reload` method, in the same order they are declared in the Guardfile.
150
180
 
151
- You can read more about [configure the signal keyboard shortcuts](https://github.com/guard/guard/wiki/Configure-keyboard-shortcuts) on the wiki.
181
+ You can read more about [configure the signal keyboard shortcuts](https://github.com/guard/guard/wiki/Configure-keyboard-shortcuts) in the wiki.
152
182
 
153
183
  Available Guards
154
184
  ----------------
155
185
 
156
- [Available Guards list](https://github.com/guard/guard/wiki/List-of-available-Guards) (on the wiki now)
186
+ A list of the available guards is present [in the wiki](https://github.com/guard/guard/wiki/List-of-available-Guards).
157
187
 
158
188
  ### Add a guard to your Guardfile
159
189
 
160
- Add it to your Gemfile (inside the `test` group):
190
+ Add it to your Gemfile (inside the `development` group):
161
191
 
162
192
  ``` ruby
163
193
  gem '<guard-name>'
@@ -169,21 +199,21 @@ Insert default guard's definition to your Guardfile by running this command:
169
199
  $ guard init <guard-name>
170
200
  ```
171
201
 
172
- You are good to go!
202
+ You are good to go, or you can modify your guards' definition to suit your needs.
173
203
 
174
204
  Guardfile DSL
175
205
  -------------
176
206
 
177
- The Guardfile DSL consists of just three simple methods: `guard`, `watch` & `group`.
207
+ The Guardfile DSL consists of just three simple methods: `#guard`, `#watch` & `#group`.
178
208
 
179
209
  Required:
180
210
 
181
- * The `guard` method allows you to add a guard with an optional hash of options.
182
- * The `watch` method allows you to define which files are supervised by this guard. An optional block can be added to overwrite the paths sent to the `run_on_change` guard method or to launch any arbitrary command.
211
+ * The `#guard` method allows you to add a guard with an optional hash of options.
183
212
 
184
213
  Optional:
185
214
 
186
- * The `group` method allows you to group several guards together. Groups to be run can be specified with the Guard DSL option `--group` (or `-g`). This comes in handy especially when you have a huge Guardfile and want to focus your development on a certain part.
215
+ * The `#watch` method allows you to define which files are supervised by this guard. An optional block can be added to overwrite the paths sent to the guard's `#run_on_change` method or to launch any arbitrary command.
216
+ * The `#group` method allows you to group several guards together. Groups to be run can be specified with the Guard DSL option `--group` (or `-g`). This comes in handy especially when you have a huge Guardfile and want to focus your development on a certain part.
187
217
 
188
218
  Example:
189
219
 
@@ -195,10 +225,10 @@ group 'backend' do
195
225
 
196
226
  guard 'rspec', :cli => '--color --format doc' do
197
227
  # Regexp watch patterns are matched with Regexp#match
198
- watch(%r{^spec/.+_spec\.rb})
199
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
200
- watch(%r{^spec/models/.+\.rb}) { ["spec/models", "spec/acceptance"] }
201
- watch(%r{^spec/.+\.rb}) { `say hello` }
228
+ watch(%r{^spec/.+_spec\.rb$})
229
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
230
+ watch(%r{^spec/models/.+\.rb$}) { ["spec/models", "spec/acceptance"] }
231
+ watch(%r{^spec/.+\.rb$}) { `say hello` }
202
232
 
203
233
  # String watch patterns are matched with simple '=='
204
234
  watch('spec/spec_helper.rb') { "spec" }
@@ -207,22 +237,24 @@ end
207
237
 
208
238
  group 'frontend' do
209
239
  guard 'coffeescript', :output => 'public/javascripts/compiled' do
210
- watch(%r{^app/coffeescripts/.+\.coffee})
240
+ watch(%r{^app/coffeescripts/.+\.coffee$})
211
241
  end
212
242
 
213
243
  guard 'livereload' do
214
- watch(%r{^app/.+\.(erb|haml)})
244
+ watch(%r{^app/.+\.(erb|haml)$})
215
245
  end
216
246
  end
217
247
  ```
218
248
 
249
+ ### Using a Guardfile without the `guard` binary
250
+
219
251
  The Guardfile DSL can also be used in a programmatic fashion by calling directly `Guard::Dsl.evaluate_guardfile`.
220
252
  Available options are as follow:
221
253
 
222
254
  * `:guardfile` - The path to a valid Guardfile.
223
255
  * `:guardfile_contents` - A string representing the content of a valid Guardfile
224
256
 
225
- Without any options given, Guard will look for a Guardfile in your current directory and if it does not find one, it will look in your `$HOME` directory for one.
257
+ Remember, without any options given, Guard will look for a Guardfile in your current directory and if it does not find one, it will look for it in your `$HOME` directory.
226
258
 
227
259
  For instance, you could use it as follow:
228
260
 
@@ -232,28 +264,57 @@ require 'guard'
232
264
 
233
265
  Guard.setup
234
266
 
235
- Guard::Dsl.evaluate_guardfile(:guardfile => '/Your/Custom/Path/To/A/Valid/Guardfile')
267
+ Guard::Dsl.evaluate_guardfile(:guardfile => '/your/custom/path/to/a/valid/Guardfile')
236
268
  # or
237
269
  Guard::Dsl.evaluate_guardfile(:guardfile_contents => "
238
270
  guard 'rspec' do
239
- watch(%r{^spec/.+_spec\.rb})
271
+ watch(%r{^spec/.+_spec\.rb$})
240
272
  end
241
273
  ")
242
274
  ```
243
275
 
276
+ ### Listing defined guards/groups for the current project
277
+
278
+ You can list the defined groups and guards for the current Guardfile from the command line using `guard show` or `guard -T`:
279
+
280
+ ``` bash
281
+ # guard -T
282
+
283
+ (global):
284
+ shell
285
+ Group backend:
286
+ bundler
287
+ rspec: cli => "--color --format doc'
288
+ Group frontend:
289
+ coffeescript: output => "public/javascripts/compiled"
290
+ livereload
291
+ ```
292
+
244
293
  Create a new guard
245
294
  ------------------
246
295
 
247
296
  Creating a new guard is very easy, just create a new gem (`bundle gem` if you use Bundler) with this basic structure:
248
297
 
249
- lib/
250
- guard/
251
- guard-name/
252
- templates/
253
- Guardfile (needed for guard init <guard-name>)
254
- guard-name.rb
298
+ ```
299
+ .travis.yml # bonus point!
300
+ CHANGELOG.md # bonus point!
301
+ Gemfile
302
+ guard-name.gemspec
303
+ Guardfile
304
+ lib/
305
+ guard/
306
+ guard-name/
307
+ templates/
308
+ Guardfile # needed for `guard init <guard-name>`
309
+ version.rb
310
+ guard-name.rb
311
+ test/ # or spec/
312
+ README.md
313
+ ```
314
+
315
+ `Guard::GuardName` (in `lib/guard/guard-name.rb`) must inherit from `Guard::Guard` and should overwrite at least one of the five basic `Guard::Guard` instance methods.
255
316
 
256
- `Guard::GuardName` (in `lib/guard/guard-name.rb`) must inherit from `Guard::Guard` and should overwrite at least one of the five basic `Guard::Guard` instance methods. Example:
317
+ Here is an example scaffold for `lib/guard/guard-name.rb`:
257
318
 
258
319
  ``` ruby
259
320
  require 'guard'
@@ -306,7 +367,7 @@ module Guard
306
367
  end
307
368
  ```
308
369
 
309
- Please take a look at the existing guards' source code (see the list above) for more concrete example.
370
+ Please take a look at the [existing guards' source code](https://github.com/guard/guard/wiki/List-of-available-Guards) for more concrete example and inspiration.
310
371
 
311
372
  Alternatively, a new guard can be added inline to a Guardfile with this basic structure:
312
373
 
@@ -326,14 +387,17 @@ module ::Guard
326
387
  end
327
388
  ```
328
389
 
390
+ Here is a very cool example by [@avdi](https://github.com/avdi) : http://avdi.org/devblog/2011/06/15/a-guardfile-for-redis
391
+
329
392
  Development
330
393
  -----------
331
394
 
332
395
  * Source hosted at [GitHub](https://github.com/guard/guard).
333
- * Report Issues/Feature requests on [GitHub Issues](https://github.com/guard/guard/issues).
396
+ * Report issues and feature requests to [GitHub Issues](https://github.com/guard/guard/issues).
397
+
398
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make. Please **do not change** the version in your pull-request.
334
399
 
335
- Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
336
- you make. Please do not change the version in your pull-request.
400
+ For questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
337
401
 
338
402
  Author
339
403
  ------
data/lib/guard/cli.rb CHANGED
@@ -15,13 +15,13 @@ module Guard
15
15
  ::Guard.start(options)
16
16
  end
17
17
 
18
- desc "version", "Prints Guard's version information"
18
+ desc "version", "Prints Guard's version"
19
19
  def version
20
20
  ::Guard::UI.info "Guard version #{Guard::VERSION}"
21
21
  end
22
22
  map %w(-v --version) => :version
23
23
 
24
- desc "init [GUARD]", "Generates a Guardfile into the current working directory, or insert the given GUARD"
24
+ desc "init [GUARD]", "Generates a Guardfile into the current working directory, or insert the given GUARD in an existing Guardfile"
25
25
  def init(guard_name = nil)
26
26
  if !File.exist?("Guardfile")
27
27
  puts "Writing new Guardfile to #{Dir.pwd}/Guardfile"
@@ -37,5 +37,31 @@ module Guard
37
37
  end
38
38
  end
39
39
 
40
+ desc "show", "Show all defined Guards and their options"
41
+ def show
42
+ ::Guard::DslDescriber.evaluate_guardfile(options)
43
+
44
+ ::Guard::DslDescriber.guardfile_structure.each do |group|
45
+ if !group[:guards].empty?
46
+ if group[:group]
47
+ ::Guard::UI.info "Group #{group[:group]}:"
48
+ else
49
+ ::Guard::UI.info "(global):"
50
+ end
51
+
52
+ group[:guards].each do |guard|
53
+ line = " #{guard[:name]}"
54
+
55
+ if !guard[:options].empty?
56
+ line += ": #{guard[:options].collect { |k, v| "#{k} => #{v.inspect}" }.join(", ")}"
57
+ end
58
+ ::Guard::UI.info line
59
+ end
60
+ end
61
+ end
62
+
63
+ ::Guard::UI.info ''
64
+ end
65
+ map %w(-T) => :show
40
66
  end
41
- end
67
+ end
data/lib/guard/dsl.rb CHANGED
@@ -2,12 +2,22 @@ module Guard
2
2
  class Dsl
3
3
  class << self
4
4
  @@options = nil
5
-
5
+
6
6
  def evaluate_guardfile(options = {})
7
7
  options.is_a?(Hash) or raise ArgumentError.new("evaluate_guardfile not passed a Hash!")
8
8
 
9
9
  @@options = options.dup
10
10
  instance_eval_guardfile(fetch_guardfile_contents)
11
+
12
+ UI.error "No guards found in Guardfile, please add at least one." if ::Guard.guards.empty?
13
+ end
14
+
15
+ def revaluate_guardfile
16
+ ::Guard.guards.clear
17
+ Dsl.evaluate_guardfile(@@options)
18
+ msg = "Guardfile has been re-evaluated."
19
+ UI.info(msg)
20
+ Notifier.notify(msg)
11
21
  end
12
22
 
13
23
  def instance_eval_guardfile(contents)
@@ -69,6 +79,10 @@ module Guard
69
79
  @@options ? @@options[:guardfile_contents] : ""
70
80
  end
71
81
 
82
+ def guardfile_path
83
+ @@options ? @@options[:guardfile_path] : ""
84
+ end
85
+
72
86
  def guardfile_contents_usable?
73
87
  guardfile_contents && guardfile_contents.size >= 'guard :a'.size # smallest guard-definition
74
88
  end
@@ -84,7 +98,7 @@ module Guard
84
98
  end
85
99
 
86
100
  def home_guardfile_path
87
- File.expand_path(File.join("~", "Guardfile"))
101
+ File.expand_path(File.join("~", ".Guardfile"))
88
102
  end
89
103
 
90
104
  end
@@ -0,0 +1,29 @@
1
+ require 'guard/dsl'
2
+
3
+ module Guard
4
+ class DslDescriber < Dsl
5
+ @@guardfile_structure = [ { :guards => [] } ]
6
+
7
+ class << self
8
+ def guardfile_structure
9
+ @@guardfile_structure
10
+ end
11
+ end
12
+
13
+ private
14
+ def group(name, &guard_definition)
15
+ @@guardfile_structure << { :group => name.to_sym, :guards => [] }
16
+
17
+ @group = true
18
+ guard_definition.call
19
+ @group = false
20
+ end
21
+
22
+ def guard(name, options = {}, &watch_definition)
23
+ node = (@group ? @@guardfile_structure.last : @@guardfile_structure.first)
24
+
25
+ node[:guards] << { :name => name, :options => options }
26
+ end
27
+ end
28
+ end
29
+
@@ -47,7 +47,7 @@ module Guard
47
47
  end
48
48
 
49
49
  def modified_files(dirs, options = {})
50
- files = potentially_modified_files(dirs, options).select { |path| File.file?(path) && file_modified?(path) }
50
+ files = potentially_modified_files(dirs, options).select { |path| file_modified?(path) }
51
51
  relativate_paths files
52
52
  end
53
53
 
@@ -77,12 +77,11 @@ module Guard
77
77
  !!@relativate_paths
78
78
  end
79
79
 
80
-
81
80
  private
82
81
 
83
82
  def potentially_modified_files(dirs, options = {})
84
83
  match = options[:all] ? "**/*" : "*"
85
- Dir.glob(dirs.map { |dir| "#{dir}#{match}" })
84
+ Dir.glob(dirs.map { |dir| "#{dir}#{match}" }, File::FNM_DOTMATCH).select { |file| File.file?(file) }
86
85
  end
87
86
 
88
87
  # Depending on the filesystem, mtime is probably only precise to the second, so round
@@ -116,15 +115,15 @@ module Guard
116
115
  end
117
116
 
118
117
  def self.mac?
119
- Config::CONFIG['target_os'] =~ /darwin/i
118
+ RbConfig::CONFIG['target_os'] =~ /darwin/i
120
119
  end
121
120
 
122
121
  def self.linux?
123
- Config::CONFIG['target_os'] =~ /linux/i
122
+ RbConfig::CONFIG['target_os'] =~ /linux/i
124
123
  end
125
124
 
126
125
  def self.windows?
127
- Config::CONFIG['target_os'] =~ /mswin|mingw/i
126
+ RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
128
127
  end
129
128
 
130
129
  end