guard 1.4.0 → 2.18.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.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +1 -677
  3. data/LICENSE +4 -2
  4. data/README.md +91 -753
  5. data/bin/_guard-core +11 -0
  6. data/bin/guard +108 -3
  7. data/lib/guard/aruba_adapter.rb +59 -0
  8. data/lib/guard/cli/environments/bundler.rb +22 -0
  9. data/lib/guard/cli/environments/evaluate_only.rb +35 -0
  10. data/lib/guard/cli/environments/valid.rb +69 -0
  11. data/lib/guard/cli.rb +129 -128
  12. data/lib/guard/commander.rb +104 -0
  13. data/lib/guard/commands/all.rb +37 -0
  14. data/lib/guard/commands/change.rb +31 -0
  15. data/lib/guard/commands/notification.rb +26 -0
  16. data/lib/guard/commands/pause.rb +29 -0
  17. data/lib/guard/commands/reload.rb +36 -0
  18. data/lib/guard/commands/scope.rb +38 -0
  19. data/lib/guard/commands/show.rb +24 -0
  20. data/lib/guard/config.rb +18 -0
  21. data/lib/guard/deprecated/dsl.rb +45 -0
  22. data/lib/guard/deprecated/evaluator.rb +39 -0
  23. data/lib/guard/deprecated/guard.rb +328 -0
  24. data/lib/guard/deprecated/guardfile.rb +84 -0
  25. data/lib/guard/deprecated/watcher.rb +27 -0
  26. data/lib/guard/dsl.rb +332 -363
  27. data/lib/guard/dsl_describer.rb +132 -122
  28. data/lib/guard/dsl_reader.rb +51 -0
  29. data/lib/guard/group.rb +34 -14
  30. data/lib/guard/guardfile/evaluator.rb +232 -0
  31. data/lib/guard/guardfile/generator.rb +128 -0
  32. data/lib/guard/guardfile.rb +24 -60
  33. data/lib/guard/interactor.rb +31 -255
  34. data/lib/guard/internals/debugging.rb +68 -0
  35. data/lib/guard/internals/groups.rb +40 -0
  36. data/lib/guard/internals/helpers.rb +13 -0
  37. data/lib/guard/internals/plugins.rb +53 -0
  38. data/lib/guard/internals/queue.rb +51 -0
  39. data/lib/guard/internals/scope.rb +121 -0
  40. data/lib/guard/internals/session.rb +180 -0
  41. data/lib/guard/internals/state.rb +25 -0
  42. data/lib/guard/internals/tracing.rb +33 -0
  43. data/lib/guard/internals/traps.rb +10 -0
  44. data/lib/guard/jobs/base.rb +21 -0
  45. data/lib/guard/jobs/pry_wrapper.rb +336 -0
  46. data/lib/guard/jobs/sleep.rb +26 -0
  47. data/lib/guard/notifier.rb +46 -212
  48. data/lib/guard/options.rb +22 -0
  49. data/lib/guard/plugin.rb +303 -0
  50. data/lib/guard/plugin_util.rb +191 -0
  51. data/lib/guard/rake_task.rb +42 -0
  52. data/lib/guard/runner.rb +80 -140
  53. data/lib/guard/templates/Guardfile +14 -0
  54. data/lib/guard/terminal.rb +13 -0
  55. data/lib/guard/ui/colors.rb +56 -0
  56. data/lib/guard/ui/config.rb +70 -0
  57. data/lib/guard/ui/logger.rb +30 -0
  58. data/lib/guard/ui.rb +163 -128
  59. data/lib/guard/version.rb +1 -2
  60. data/lib/guard/watcher/pattern/deprecated_regexp.rb +45 -0
  61. data/lib/guard/watcher/pattern/match_result.rb +18 -0
  62. data/lib/guard/watcher/pattern/matcher.rb +33 -0
  63. data/lib/guard/watcher/pattern/pathname_path.rb +15 -0
  64. data/lib/guard/watcher/pattern/simple_path.rb +23 -0
  65. data/lib/guard/watcher/pattern.rb +24 -0
  66. data/lib/guard/watcher.rb +52 -95
  67. data/lib/guard.rb +108 -376
  68. data/lib/tasks/releaser.rb +116 -0
  69. data/man/guard.1 +12 -9
  70. data/man/guard.1.html +18 -12
  71. metadata +148 -77
  72. data/images/guard.png +0 -0
  73. data/lib/guard/guard.rb +0 -156
  74. data/lib/guard/hook.rb +0 -120
  75. data/lib/guard/interactors/coolline.rb +0 -64
  76. data/lib/guard/interactors/helpers/completion.rb +0 -32
  77. data/lib/guard/interactors/helpers/terminal.rb +0 -46
  78. data/lib/guard/interactors/readline.rb +0 -94
  79. data/lib/guard/interactors/simple.rb +0 -19
  80. data/lib/guard/notifiers/emacs.rb +0 -69
  81. data/lib/guard/notifiers/gntp.rb +0 -118
  82. data/lib/guard/notifiers/growl.rb +0 -99
  83. data/lib/guard/notifiers/growl_notify.rb +0 -92
  84. data/lib/guard/notifiers/libnotify.rb +0 -96
  85. data/lib/guard/notifiers/notifysend.rb +0 -84
  86. data/lib/guard/notifiers/rb_notifu.rb +0 -102
  87. data/lib/guard/notifiers/terminal_notifier.rb +0 -66
  88. data/lib/guard/notifiers/tmux.rb +0 -69
  89. data/lib/guard/version.rbc +0 -130
data/README.md CHANGED
@@ -1,234 +1,109 @@
1
- Guard [![Build Status](https://secure.travis-ci.org/guard/guard.png?branch=master)](http://travis-ci.org/guard/guard)
2
- =====
1
+ # Guard
3
2
 
4
- Guard is a command line tool to easily handle events on file system modifications.
3
+ **IMPORTANT: Please upgrade to Ruby >= 2.4 before installing Guard! To install for older versions, update Bundler at least 1.12: `gem update bundler` and Bundler should correctly resolve to earlier gems for your given Ruby version.**
5
4
 
6
- This document contains a lot of information, please take your time and read these instructions carefully. If you have
7
- any questions, ask them in our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
8
- (irc.freenode.net).
5
+ - [Ruby 2.1 is officially outdated and unsupported!](https://www.ruby-lang.org/en/news/2016/03/30/ruby-2-1-9-released/)
6
+ - [Ruby 2.2 is officially outdated and unsupported!](https://www.ruby-lang.org/en/news/2018/06/20/support-of-ruby-2-2-has-ended/)
7
+ - [Ruby 2.3 is officially outdated and unsupported!](https://www.ruby-lang.org/en/news/2019/03/31/support-of-ruby-2-3-has-ended/)
9
8
 
10
- Information on advanced topics like creating your own Guard plugin, programatic use of Guard, hooks and callbacks and
11
- more can be found in the [Guard wiki](https://github.com/guard/guard/wiki).
9
+ :exclamation: Guard is currently accepting more maintainers. Please [read this](https://github.com/guard/guard/wiki/Maintainers) if you're interested in joining the team.
12
10
 
13
- Before you file an issue, make sure you have read the _[file an issue](#file-an-issue)_ section that contains some
14
- important information.
11
+ [![Gem Version](https://img.shields.io/gem/v/guard.svg?style=flat)](https://rubygems.org/gems/guard) [![Build Status](https://travis-ci.org/guard/guard.svg?branch=master)](https://travis-ci.org/guard/guard) [![Code Climate](https://codeclimate.com/github/guard/guard/badges/gpa.svg)](https://codeclimate.com/github/guard/guard) [![Test Coverage](https://codeclimate.com/github/guard/guard/badges/coverage.svg)](https://codeclimate.com/github/guard/guard) [![Inline docs](http://inch-ci.org/github/guard/guard.svg)](http://inch-ci.org/github/guard/guard) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
15
12
 
16
- Features
17
- --------
13
+ <img src="http://f.cl.ly/items/0A0M3W2x3I1P450z341U/guard-Icon.png" alt="Guard Icon" align="right" />
14
+ Guard automates various tasks by running custom rules whenever file or directories are modified.
18
15
 
19
- * File system changes handled by our awesome [Listen](https://github.com/guard/listen) gem.
20
- * Support for visual system notifications.
21
- * Huge eco-system with [more than 150](https://rubygems.org/search?query=guard-) guard plugins.
22
- * Tested against Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest versions of JRuby & Rubinius.
23
-
24
- Screencast
25
- ----------
26
-
27
- Ryan Bates made an excellent [RailsCast about Guard](http://railscasts.com/episodes/264-guard) and you should definitely
28
- watch it for a nice introduction to Guard.
29
-
30
- Installation
31
- ------------
32
-
33
- The simplest way to install Guard is to use [Bundler](http://gembundler.com/).
34
-
35
- Add Guard to your `Gemfile`:
36
-
37
- ```ruby
38
- group :development do
39
- gem 'guard'
40
- end
41
- ```
16
+ It's frequently used by software developers, web designers, writers and other specialists to avoid mundane, repetitive actions and commands such as "relaunching" tools after changing source files or configurations.
42
17
 
43
- and install it by running Bundler:
18
+ Common use cases include: an IDE replacement, web development tools, designing "smart" and "responsive" build systems/workflows, automating various project tasks and installing/monitoring various system services.
44
19
 
45
- ```bash
46
- $ bundle
47
- ```
20
+ For a full categorized list of known Guard plugins, look here: https://github.com/guard/guard/wiki/Guard-Plugins
48
21
 
49
- Generate an empty `Guardfile` with:
22
+ If you have
23
+ any questions about Guard or want to share some information with the Guard community, please go to one of
24
+ the following places:
50
25
 
51
- ```bash
52
- $ guard init
53
- ```
54
-
55
- **It's important that you always run Guard through Bundler to avoid errors.** If you're getting sick of typing `bundle exec` all
56
- the time, try the [Rubygems Bundler](https://github.com/mpapis/rubygems-bundler).
26
+ * [Guard Wiki](https://github.com/guard/guard/wiki)
27
+ * [Google+ community](https://plus.google.com/communities/110022199336250745477).
28
+ * [Google group](http://groups.google.com/group/guard-dev).
29
+ * [StackOverflow](http://stackoverflow.com/questions/tagged/guard).
30
+ * IRC channel `#guard` (irc.freenode.net) for chatting.
57
31
 
58
- ## OS X
32
+ Before you file an issue, make sure you have read the _[known issues](#issues)_ and _[file an issue](#file-an-issue)_ sections that contains some important information.
59
33
 
60
- You may want to install the [rb-fsevent](https://github.com/thibaudgg/rb-fsevent) gem to make use of file change events
61
- and don't rely on polling by adding the gem to your `Gemfile` and install it with Bundler:
34
+ ## Features
62
35
 
63
- ```ruby
64
- group :development do
65
- gem 'rb-fsevent', :require => false
66
- end
67
- ```
68
-
69
- ## Linux
70
-
71
- You may want to install the [rb-inotify](https://github.com/nex3/rb-inotify) gem to make use of file change events and
72
- don't rely on polling by adding the gem to your `Gemfile` and install it with Bundler:
73
-
74
- ```ruby
75
- group :development do
76
- gem 'rb-inotify', :require => false
77
- end
78
- ```
79
-
80
- ## Windows
81
-
82
- You may want to install the [wdm](https://github.com/Maher4Ever/wdm) gem to make use of file change events and don't
83
- rely on polling by adding the gem to your `Gemfile` and install it with Bundler:
84
-
85
- ```ruby
86
- group :development do
87
- gem 'wdm', :require => false
88
- end
89
- ```
90
-
91
- Please note that you have to use at least on Ruby 1.9.2 for using WDM.
92
-
93
- If you want colors in your terminal, you'll have to add the [win32console](https://rubygems.org/gems/win32console) gem
94
- to your `Gemfile` and install it with Bundler:
95
-
96
- ```ruby
97
- group :development do
98
- gem 'win32console'
99
- end
100
- ```
101
-
102
- ### System notifications
36
+ * File system changes handled by our awesome [Listen](https://github.com/guard/listen) gem.
37
+ * Support for visual system notifications.
38
+ * Huge eco-system with [more than 300](https://rubygems.org/search?query=guard-) Guard plugins.
39
+ * Tested against the latest Ruby 2.4.x, 2.5.x, 2.6.x, JRuby & Rubinius. See [`.travis-ci.yml`](https://github.com/guard/guard/blob/master/.travis.yml) for the exact versions.
103
40
 
104
- You can configure Guard to make use of the following system notification libraries, but it's strongly recommended
105
- to use either Ruby GNTP, Libnotify or Notifu:
41
+ ## Screencast
106
42
 
107
- #### Ruby GNTP
43
+ Two nice screencasts are available to help you get started:
108
44
 
109
- * Runs on Mac OS X, Linux and Windows
110
- * Supports [Growl](http://growl.info/) version >= 1.3, [Growl for Linux](http://mattn.github.com/growl-for-linux/),
111
- [Growl for Windows](http://www.growlforwindows.com/gfw/default.aspx) and
112
- [Snarl](https://sites.google.com/site/snarlapp/home)
45
+ * [Guard](http://railscasts.com/episodes/264-guard) on RailsCast.
46
+ * [Guard is Your Best Friend](http://net.tutsplus.com/tutorials/tools-and-tips/guard-is-your-best-friend) on Net Tuts+.
113
47
 
114
- The [ruby_gntp](https://rubygems.org/gems/ruby_gntp) gem sends system notifications over the network with the
115
- [Growl Notification Transport Protocol](http://www.growlforwindows.com/gfw/help/gntp.aspx) and supports local and
116
- remote notifications. To have the images be displayed, you have to use `127.0.0.1` instead of `localhost` in your GTNP
117
- configuration.
48
+ ## Installation
118
49
 
119
- Guard supports multiple notification channels for customizing each notification type. For Growl on Mac OS X you need
120
- to have at least version 1.3 installed.
50
+ The simplest way to install Guard is to use [Bundler](http://bundler.io).
121
51
 
122
- To use `ruby_gntp` you have to add it to your `Gemfile` and run bundler:
52
+ Add Guard (and any other dependencies) to a `Gemfile` in your project’s root:
123
53
 
124
54
  ```ruby
125
55
  group :development do
126
- gem 'ruby_gntp'
56
+ gem 'guard'
127
57
  end
128
58
  ```
129
59
 
130
- #### Growl
60
+ then install it by running Bundler:
131
61
 
132
- * Runs on Mac OS X
133
- * Supports all [Growl](http://growl.info/) versions
134
-
135
- The [growl](https://rubygems.org/gems/growl) gem is compatible with all versions of Growl and uses a command line tool
136
- [growlnotify](http://growl.info/extras.php#growlnotify) that must be separately downloaded and installed. The version of
137
- the command line tool must match your Growl version. The `growl` gem does **not** support multiple notification
138
- channels.
139
-
140
- You have to download the installer for `growlnotify` from the [Growl download section](http://growl.info/downloads).
141
-
142
- To use `growl` you have to add it to your `Gemfile` and run bundler:
143
-
144
- ```ruby
145
- group :development do
146
- gem 'growl'
147
- end
62
+ ```bash
63
+ $ bundle
148
64
  ```
149
65
 
150
- #### Libnotify
151
-
152
- * Runs on Linux, FreeBSD, OpenBSD and Solaris
153
- * Supports [Libnotify](http://developer.gnome.org/libnotify/)
154
-
155
- The [libnotify](https://rubygems.org/gems/libnotify) gem supports the Gnome libnotify notification daemon, but it can be
156
- used on other window managers as well. You have to install the `libnotify-bin` package with your favorite package
157
- manager.
158
-
159
- To use `libnotify` you have to add it to your `Gemfile` and run bundler:
66
+ Generate an empty `Guardfile` with:
160
67
 
161
- ```ruby
162
- group :development do
163
- gem 'libnotify'
164
- end
68
+ ```bash
69
+ $ bundle exec guard init
165
70
  ```
166
71
 
167
- If you are unable to build the `libnotify` gem on your system, Guard
168
- also has a built in notifier - `notifysend` - that shells out to the
169
- `notify-send` utility that comes with `libnotify-bin`.
170
-
171
- #### Notifu
172
-
173
- * Runs on Windows
174
- * Supports [Notifu](http://www.paralint.com/projects/notifu/)
175
-
176
- The [rb-notifu](https://rubygems.org/gems/rb-notifu) gem supports Windows system tray notifications.
177
-
178
- To use `rb-notifu` you have to add it to your `Gemfile` and run bundler:
72
+ Run Guard through Bundler with:
179
73
 
180
- ```ruby
181
- group :development do
182
- gem 'rb-notifu'
183
- end
74
+ ```bash
75
+ $ bundle exec guard
184
76
  ```
185
77
 
186
- #### GrowlNotify
78
+ If you are on Mac OS X and have problems with either Guard not reacting to file
79
+ changes or Pry behaving strange, then you should [add proper Readline support
80
+ to Ruby on macOS](https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X).
187
81
 
188
- * Runs on Mac OS X
189
- * Supports [Growl](http://growl.info/) version >= 1.3
190
- * Doesn't support JRuby and MacRuby.
191
- * Doesn't work when forking, e.g. with [Spork](https://github.com/sporkrb/spork).
82
+ ## Avoiding gem/dependency problems
192
83
 
193
- The [growl_notify](https://rubygems.org/gems/growl_notify) gem uses AppleScript to send Growl notifications.
194
- The gem needs a native C extension to make use of AppleScript and does not run on JRuby and MacRuby.
84
+ **It's important that you always run Guard through Bundler to avoid errors.**
195
85
 
196
- Guard supports multiple notification channels for customizing each notification type and you need to have at least
197
- Growl version 1.3 installed.
86
+ If you're getting sick of typing `bundle exec` all the time, try one of the following:
198
87
 
199
- To use `growl_notify` you have to add it to your `Gemfile` and run bundler:
88
+ * (Recommended) Running `bundle binstub guard` will create `bin/guard` in your
89
+ project, which means running `bin/guard` (tab completion will save you a key
90
+ stroke or two) will have the exact same result as `bundle exec guard`.
200
91
 
201
- ```ruby
202
- group :development do
203
- gem 'growl_notify'
204
- end
205
- ```
206
-
207
- #### Terminal Notifier
208
-
209
- * Runs on Mac OS X 10.8 only
92
+ * Or, you can `alias be="bundle exec"` in your `.bashrc` or similar and the execute only `be guard`.
93
+ **Protip**: It will work for all comands executed in `bundle exec` context!
210
94
 
211
- The [terminal-notifier-guard](https://github.com/Springest/terminal-notifier-guard) sends notifications to the OS X
212
- Notification Center.
213
-
214
- To use `terminal-notifier-guard` you have to add it to your `Gemfile` and run bundler:
215
-
216
- ```ruby
217
- group :development do
218
- gem 'terminal-notifier-guard'
219
- end
220
- ```
221
95
 
222
- #### Emacs
96
+ * Or, for RubyGems >= 2.2.0 (at least, though the more recent the better),
97
+ simply set the `RUBYGEMS_GEMDEPS` environment variable to `-` (for autodetecting
98
+ the Gemfile in the current or parent directories) or set it to the path of your Gemfile.
223
99
 
224
- * Runs on any platform with Emacs + emacsclient (http://www.emacswiki.org/emacs/EmacsClient)
100
+ (To upgrade RubyGems from RVM, use the `rvm rubygems` command).
225
101
 
226
- ### Tmux
102
+ *NOTE: this Rubygems feature is still under development still lacks many features of bundler*
227
103
 
228
- * To use Tmux notifications, you have to start Guard within a [tmux](http://tmux.sourceforge.net/) session.
104
+ * Or, for RubyGems < 2.2.0 check out the [Rubygems Bundler](https://github.com/rvm/rubygems-bundler).
229
105
 
230
- Add Guard plugins
231
- -----------------
106
+ ## Add Guard plugins
232
107
 
233
108
  Guard is now ready to use and you should add some Guard plugins for your specific use. Start exploring the many Guard
234
109
  plugins available by browsing the [Guard organization](https://github.com/guard) on GitHub or by searching for `guard-`
@@ -245,605 +120,68 @@ end
245
120
  See the init section of the Guard usage below to see how to install the supplied plugin template that you can install and
246
121
  to suit your needs.
247
122
 
248
- Usage
249
- -----
123
+ ## Usage
250
124
 
251
125
  Guard is run from the command line. Please open your terminal and go to your project work directory.
252
126
 
253
- ### Help
254
-
255
- You can always get help on the available tasks with the `help` task:
256
-
257
- ```bash
258
- $ guard help
259
- ```
260
-
261
- To request more detailed help on a specific task is simple: just appending the task name to the help task.
262
- For example, to get help for the `start` task, simply run:
263
-
264
- ```bash
265
- $ guard help start
266
- ```
267
-
268
- ### Init
269
-
270
- You can generate a Guardfile and have all installed plugins be automatically added into
271
- it by running the `init` task without any option:
272
-
273
- ```bash
274
- $ guard init
275
- ```
276
-
277
- You can also specify the name of an installed plugin to only get that plugin template
278
- in the generated Guardfile:
279
-
280
- ```bash
281
- $ guard init <guard-name>
282
- ```
283
-
284
- You can also specify the names of multiple plugins to only get those plugin templates
285
- in the generated Guardfile:
286
-
287
- ```bash
288
- $ guard init <guard1-name> <guard2-name>
289
- ```
290
-
291
- You can also define your own templates in `~/.guard/templates/` which can be appended in the same way to your existing
292
- `Guardfile`:
293
-
294
- ```bash
295
- $ guard init <template-name>
296
- ```
297
-
298
- **Note**: If you already have a `Guardfile` in the current directory, the `init` task can be used
299
- to append a supplied template from an installed plugin to your existing `Guardfile`.
300
-
301
- #### `-b`/`--bare` option
302
-
303
- You can generate an empty `Guardfile` by running the `init` task with the bare
304
- option:
305
-
306
- ```bash
307
- $ guard init --bare
308
- $ guard init -b # shortcut
309
- ```
127
+ Look here for a full [list of Guard commands](https://github.com/guard/guard/wiki/List-of-Guard-Commands)
310
128
 
311
129
  ### Start
312
130
 
313
131
  Just launch Guard inside your Ruby or Rails project with:
314
132
 
315
133
  ```bash
316
- $ guard
317
- ```
318
-
319
- Guard will look for a `Guardfile` in your current directory. If it does not find one, it will look in your `$HOME`
320
- directory for a `.Guardfile`.
321
-
322
- #### `-c`/`--clear` option
323
-
324
- The shell can be cleared after each change:
325
-
326
- ```bash
327
- $ guard --clear
328
- $ guard -c # shortcut
329
- ```
330
-
331
- #### `-n`/`--notify` option
332
-
333
- System notifications can be disabled:
334
-
335
- ```bash
336
- $ guard --notify false
337
- $ guard -n f # shortcut
338
- ```
339
-
340
- Notifications can also be disabled globally by setting a `GUARD_NOTIFY` environment variable to `false`.
341
-
342
- #### `-g`/`--group` option
343
-
344
- Only certain plugin groups can be run:
345
-
346
- ```bash
347
- $ guard --group group_name another_group_name
348
- $ guard -g group_name another_group_name # shortcut
349
- ```
350
-
351
- See the Guardfile DSL below for creating groups.
352
-
353
- #### `-d`/`--debug` option
354
-
355
- Guard can display debug information which can be very usefull for plugins
356
- developers with:
357
-
358
- ```bash
359
- $ guard --debug
360
- $ guard -d # shortcut
361
- ```
362
-
363
- #### `-w`/`--watchdir` option
364
-
365
- Guard can watch any directory instead of the current directory:
366
-
367
- ```bash
368
- $ guard --watchdir ~/your/fancy/project
369
- $ guard -w ~/your/fancy/project # shortcut
370
- ```
371
-
372
- #### `-G`/`--guardfile` option
373
-
374
- Guard can use a `Guardfile` not located in the current directory:
375
-
376
- ```bash
377
- $ guard --guardfile ~/.your_global_guardfile
378
- $ guard -G ~/.your_global_guardfile # shortcut
379
- ```
380
-
381
- #### `-i`/`--no-interactions` option
382
-
383
- Turn off completely any Guard terminal interactions with:
384
-
385
- ```bash
386
- $ guard start -i
387
- $ guard start --no-interactions
388
- ```
389
-
390
- #### `-B`/`--no-bundler-warning` option
391
-
392
- Skip Bundler warning when a Gemfile exists in the project directory but Guard is not run with Bundler.
393
-
394
- ```bash
395
- $ guard start -B
396
- $ guard start --no-bundler-warning
397
- ```
398
-
399
- #### `-l`/`--latency` option
400
-
401
- Overwrite Listen's default latency, useful when your hard-drive / system is slow.
402
-
403
- ```bash
404
- $ guard start -l 1.5
405
- $ guard start --latency 1.5
406
- ```
407
-
408
- #### `-p`/`--force-polling` option
409
-
410
- Force Listen polling listener usage.
411
-
412
- ```bash
413
- $ guard start -p
414
- $ guard start --force-polling
134
+ $ bundle exec guard
415
135
  ```
416
136
 
417
- ### List
137
+ Guard will look for a `Guardfile` or `guardfile.rb` in your current directory. If it does not find one, it will look
138
+ in your `$HOME` directory for a `.Guardfile`.
418
139
 
419
- You can list the available plugins with the `list` task:
140
+ Please look here to see all the [command line options for Guard](https://github.com/guard/guard/wiki/Command-line-options-for-Guard)
420
141
 
421
- ```bash
422
- $ guard list
423
-
424
- Available guards:
425
- coffeescript
426
- compass
427
- cucumber
428
- jammit
429
- ronn
430
- rspec *
431
- spork
432
- yard
433
- See also https://github.com/guard/guard/wiki/List-of-available-Guards
434
- * denotes ones already in your Guardfile
435
- ```
436
-
437
- ### Show
438
-
439
- You can show the structure of the groups and their plugins with the `show` task:
440
-
441
- ```bash
442
- $ guard show
443
-
444
- (global):
445
- shell
446
- Group backend:
447
- bundler
448
- rspec: cli => "--color --format doc"
449
- Group frontend:
450
- coffeescript: output => "public/javascripts/compiled"
451
- livereload
452
- ```
453
-
454
- This shows the internal structure of the evaluated `Guardfile` or `.Guardfile`, with the `.guard.rb` file. You can
455
- read more about these files in the shared configuration section below.
456
-
457
- Interactions
458
- ------------
459
-
460
- You can interact with Guard and enter commands when Guard has nothing to do. Guard understands the following commands:
461
-
462
- * `↩`: Run all plugins.
463
- * `h`, `help`: Show a help of the available interactor commands.
464
- * `r`, `reload`: Reload all plugins.
465
- * `c`, `change`: Trigger a file change to the plugins.
466
- * `s`, `show`: Show the plugin configurations.
467
- * `n`, `notification`: Toggle system notifications on and off.
468
- * `p`, `pause`: Toggles the file modification listener. The prompt will change to `p>` when paused.
469
- This is useful when switching Git branches, rebase Git or change whitespace.
470
- * `e`, `exit`: Stop all plugins and quit Guard.
471
-
472
- Instead of running all plugins with the `↩` key, you can also run a single plugin by entering its name:
473
-
474
- ```bash
475
- > rspec
476
- ```
477
-
478
- It's also possible to run all plugins within a group by entering the group name:
479
-
480
- ```bash
481
- > frontend
482
- ```
483
-
484
- The same applies to reloading. You can reload a plugin with the following command:
485
-
486
- ```bash
487
- > ronn reload
488
- ```
489
-
490
- This will reload only the Ronn plugin. You can also reload all plugins within a group:
491
-
492
- ```bash
493
- > backend reload
494
- ```
495
-
496
- The action and plugin/group name can have any order, so you can also write:
497
-
498
- ```bash
499
- > reload backend
500
- ```
501
-
502
- You can pass a list of filenames to the `change` command to trigger manually a file modification:
503
-
504
- ```bash
505
- > change spec/guard_spec.rb
506
- ```
507
-
508
- ### Readline support
509
-
510
- With Readline enabled, you'll see a command prompt `>` when Guard is ready to accept a command. The command line
511
- supports history navigation with the `↑` and `↓` arrow keys, and command auto-completion with the `⇥` key.
512
-
513
- Unfortunately Readline [does not work on MRI](http://bugs.ruby-lang.org/issues/5539) on Mac OS X by default. You can
514
- work around the issue by installing a pure Ruby implementation:
515
-
516
- ```ruby
517
- platforms :ruby do
518
- gem 'rb-readline'
519
- end
520
- ```
521
-
522
- Guard will automatically enable Readline support if your environment supports it, but you can disable Readline with the
523
- `interactor` DSL method or turn off completely with the `--no-interactions` option.
524
-
525
- ### Coolline support
526
-
527
- With Ruby 1.9.3 you can use a [Coolline](https://github.com/Mon-Ouie/coolline) based interactor, which uses the new
528
- `io/console` from stdlib. Just add it to your `Gemfile`
529
-
530
- ```ruby
531
- gem 'coolline'
532
- ```
533
-
534
- Guard will automatically enable Coolline support if your environment supports it, but you can disable Coolline with the
535
- `interactor` DSL method or turn off completely with the `--no-interactions` option.
536
-
537
- ### Signals
538
-
539
- You can also interact with Guard by sending POSIX signals to the Guard process (all but Windows and JRuby).
540
-
541
- #### Pause watching
542
-
543
- ```bash
544
- $ kill -USR1 <guard_pid>
545
- ```
546
-
547
- #### Continue watching
548
-
549
- ```bash
550
- $ kill -USR2 <guard_pid>
551
- ```
552
-
553
- Guardfile DSL
554
- -------------
555
-
556
- The Guardfile DSL is evaluated as plain Ruby, so you can use normal Ruby code in your `Guardfile`.
557
- Guard itself provides the following DSL methods that can be used for configuration:
558
-
559
- ### guard
560
-
561
- The `guard` method allows you to add a Guard plugin to your toolchain and configure it by passing the
562
- options after the name of the plugin:
563
-
564
- ```ruby
565
- guard :coffeescript, :input => 'coffeescripts', :output => 'javascripts'
566
- ```
567
-
568
- You can define the same plugin more than once:
569
-
570
- ```ruby
571
- guard :coffeescript, :input => 'coffeescripts', :output => 'javascripts'
572
- guard :coffeescript, :input => 'specs', :output => 'specs'
573
- ```
574
-
575
- ### watch
576
-
577
- The `watch` method allows you to define which files are watched by a Guard:
578
-
579
- ```ruby
580
- guard :bundler do
581
- watch('Gemfile')
582
- end
583
- ```
584
-
585
- String watch patterns are matched with [String#==](http://www.ruby-doc.org/core-1.9.2/String.html#method-i-3D-3D).
586
- You can also pass a regular expression to the watch method:
587
-
588
- ```ruby
589
- guard :jessie do
590
- watch(%r{^spec/.+(_spec|Spec)\.(js|coffee)})
591
- end
592
- ```
593
-
594
- This instructs the jessie plugin to watch for file changes in the `spec` folder,
595
- but only for file names that ends with `_spec` or `Spec` and have a file type of `js` or `coffee`.
596
-
597
- You can easily test your watcher regular expressions with [Rubular](http://rubular.com/).
598
-
599
- When you add a block to the watch expression, you can modify the file name that has been
600
- detected before sending it to the plugin for processing:
601
-
602
- ```ruby
603
- guard :rspec do
604
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
605
- end
606
- ```
607
-
608
- In this example the regular expression capture group `(.+)` is used to transform a file change
609
- in the `lib` folder to its test case in the `spec` folder. Regular expression watch patterns
610
- are matched with [Regexp#match](http://www.ruby-doc.org/core-1.9.2/Regexp.html#method-i-match).
611
-
612
- You can also launch any arbitrary command in the supplied block:
613
-
614
- ```ruby
615
- guard :shell do
616
- watch('.*') { `git status` }
617
- end
618
- ```
619
-
620
- ### group
621
-
622
- The `group` method allows you to group several plugins together. This comes in handy especially when you
623
- have a huge `Guardfile` and want to focus your development on a certain part.
624
-
625
- ```ruby
626
- group :specs do
627
- guard :rspec do
628
- watch(%r{^spec/.+_spec\.rb$})
629
- end
630
- end
631
-
632
- group :docs do
633
- guard :ronn do
634
- watch(%r{^man/.+\.ronn?$})
635
- end
636
- end
637
- ```
638
-
639
- Groups to be run can be specified with the Guard DSL option `--group` (or `-g`):
640
-
641
- ```bash
642
- $ guard -g specs
643
- ```
644
-
645
- Guard plugins that don't belong to a group are considered global and are always run.
142
+ ## Interactions
646
143
 
647
- ### notification
648
-
649
- If you don't specify any notification configuration in your `Guardfile`, Guard goes through the list of available
650
- notifiers and takes the first that is available. If you specify your preferred library, auto detection will not take
651
- place:
652
-
653
- ```ruby
654
- notification :growl
655
- ```
656
-
657
- will select the `growl` gem for notifications. You can also set options for a notifier:
658
-
659
- ```ruby
660
- notification :growl, :sticky => true
661
- ```
662
-
663
- Each notifier has a slightly different set of supported options:
664
-
665
- ```ruby
666
- notification :growl, :sticky => true, :host => '192.168.1.5', :password => 'secret'
667
- notification :gntp, :sticky => true, :host => '192.168.1.5', :password => 'secret'
668
- notification :growl_notify, :sticky => true, :priority => 0
669
- notification :libnotify, :timeout => 5, :transient => true, :append => false, :urgency => :critical
670
- notification :notifu, :time => 5, :nosound => true, :xp => true
671
- notification :emacs
672
- ```
673
-
674
- It's possible to use more than one notifier. This allows you to configure different notifiers for different OS if your
675
- project is developed cross-platform or if you like to have local and remote notifications.
676
-
677
- Notifications can also be turned off in the `Guardfile`, in addition to setting the environment variable `GUARD_NOTIFY`
678
- or using the cli switch `-n`:
679
-
680
- ```ruby
681
- notification :off
682
- ```
683
-
684
- ### interactor
685
-
686
- You can disable the interactor auto detection and select a specific implementation:
687
-
688
- ```ruby
689
- interactor :coolline
690
- interactor :readline
691
- interactor :simple
692
- ```
693
-
694
- If you do not need the keyboard interactions with Guard at all, you can turn them off:
695
-
696
- ```ruby
697
- interactor :off
698
- ```
699
-
700
- ### callback
701
-
702
- The `callback` method allows you to execute arbitrary code before or after any of the `start`, `stop`, `reload`,
703
- `run_all`, `run_on_changes`, `run_on_additions`, `run_on_modifications` and `run_on_removals` Guard plugins method.
704
- You can even insert more hooks inside these methods.
705
-
706
- ```ruby
707
- guard :rspec do
708
- watch(%r{^spec/.+_spec\.rb$})
709
-
710
- callback(:start_begin) { `mate .` }
711
- end
712
- ```
713
-
714
- Please see the [hooks and callbacks](https://github.com/guard/guard/wiki/Hooks-and-callbacks) page in the Guard wiki for
715
- more details.
716
-
717
- ### ignore
718
-
719
- The `ignore` method can be used to exclude files and directories from the set of files being watched. Let's say you have
720
- used the `watch` method to monitor a directory, but you are not interested in changes happening to images, you could use
721
- the ignore method to exclude them.
722
-
723
- This comes in handy when you have large amounts of non-source data in you project. By default
724
- [`.rbx`, `.bundle`, `.git`, `.svn`, `log`, `tmp`, `vendor`](https://github.com/guard/listen/blob/master/lib/listen/directory_record.rb#L14)
725
- are ignored.
726
-
727
- Please note that method only accept regexps. More on the
728
- [Listen README](https://github.com/guard/listen#the-patterns-for-filtering-and-ignoring-paths).
729
-
730
- ```ruby
731
- ignore %r{^ignored/path/}, /public/
732
- ```
733
-
734
- ### filter
735
-
736
- The `filter` method allows you to focus by filtering files and directories without having to specify them by hand in the
737
- `watch` method. E.g. if you are watching multiple directories but only interested in changes to the Ruby files, then use
738
- the `filter` method.
739
-
740
- Please note that method only accept regexps. More on the
741
- [Listen README](https://github.com/guard/listen#the-patterns-for-filtering-and-ignoring-paths).
742
-
743
- ```ruby
744
- filter /\.txt$/, /.*\.zip/
745
- ```
746
-
747
- ### Example
748
-
749
- ```ruby
750
- ignore %r{^ignored/path/}, /public/
751
- filter /\.txt$/, /.*\.zip/
752
-
753
- notification :growl_notify
754
- notification :gntp, :host => '192.168.1.5'
755
-
756
- group :backend do
757
- guard :bundler do
758
- watch('Gemfile')
759
- end
760
-
761
- guard :rspec, :cli => '--color --format doc' do
762
- watch(%r{^spec/.+_spec\.rb$})
763
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
764
- watch(%r{^spec/models/.+\.rb$}) { ["spec/models", "spec/acceptance"] }
765
- watch(%r{^spec/.+\.rb$}) { `say hello` }
766
- watch('spec/spec_helper.rb') { "spec" }
767
- end
768
- end
769
-
770
- group :frontend do
771
- guard :coffeescript, :output => 'public/javascripts/compiled' do
772
- watch(%r{^app/coffeescripts/.+\.coffee$})
773
- end
774
-
775
- guard :livereload do
776
- watch(%r{^app/.+\.(erb|haml)$})
777
- end
778
- end
779
- ```
780
-
781
- Shared configurations
782
- ---------------------
783
-
784
- You may optionally place a `.Guardfile` in your home directory to use it across multiple projects. It's evaluated when
785
- you have no `Guardfile` in your current directory.
786
-
787
- If a `.guard.rb` is found in your home directory, it will be appended to the `Guardfile` in your current directory.
788
- This can be used for tasks you want guard to handle but other users probably don't.
789
-
790
- For example, indexing your source tree with [Ctags](http://ctags.sourceforge.net):
791
-
792
- ```ruby
793
- guard :shell do
794
- watch(%r{^(?:app|lib)/.+\.rb$}) { `ctags -R` }
795
- end
796
- ```
144
+ Please read how to [interact with Guard](https://github.com/guard/guard/wiki/Interacting-with-Guard) on the console and which [signals](https://github.com/guard/guard/wiki/Interacting-with-Guard#guard-signals) Guard accepts
797
145
 
798
- File an issue
799
- -------------
800
146
 
801
- You can report bugs and feature requests to [GitHub Issues](https://github.com/guard/guard/issues).
147
+ ## Guardfile DSL
802
148
 
803
- **Please don't ask question in the issue tracker**, instead ask them in our
804
- [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
149
+ For details on extending your `Guardfile` look at [Guardfile examples](https://github.com/guard/guard/wiki/Guardfile-examples) or look at a list of commands [Guardfile-DSL / Configuring-Guard](https://github.com/guard/guard/wiki/Guardfile-DSL---Configuring-Guard)
805
150
 
806
- Try to figure out where the issue belongs to: Is it an issue with Guard itself or with a Guard plugin you're
807
- using?
151
+ ## Issues
808
152
 
809
- When you file a bug, please try to follow these simple rules if applicable:
153
+ Before reporting a problem, please read how to [File an issue](https://github.com/guard/guard/blob/master/CONTRIBUTING.md#file-an-issue).
810
154
 
811
- * Make sure you run Guard with `bundle exec` first.
812
- * Add debug information to the issue by running Guard with the `--debug` option.
813
- * Add your `Guardfile` and `Gemfile` to the issue.
814
- * Make sure that the issue is reproducible with your description.
155
+ ## Development / Contributing
815
156
 
816
- **It's most likely that your bug gets resolved faster if you provide as much information as possible!**
157
+ See the [Contributing Guide](https://github.com/guard/guard/blob/master/CONTRIBUTING.md#development).
817
158
 
818
- Development [![Dependency Status](https://gemnasium.com/guard/guard.png?branch=master)](https://gemnasium.com/guard/guard) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/guard/guard)
819
- -----------
159
+ ## Releasing
820
160
 
821
- * Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard/master/frames).
822
- * Source hosted at [GitHub](https://github.com/guard/guard).
161
+ ### Prerequisites
823
162
 
824
- Pull requests are very welcome! Please try to follow these simple rules if applicable:
163
+ * You must have commit rights to the GitHub repository.
164
+ * You must have push rights for rubygems.org.
825
165
 
826
- * Please create a topic branch for every separate change you make.
827
- * Make sure your patches are well tested. All specs run with `rake spec:portability` must pass.
828
- * Update the [Yard](http://yardoc.org/) documentation.
829
- * Update the [README](https://github.com/guard/guard/blob/master/README.md).
830
- * Update the [CHANGELOG](https://github.com/guard/guard/blob/master/CHANGELOG.md) for noteworthy changes.
831
- * Please **do not change** the version number.
166
+ ### How to release
832
167
 
833
- For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
834
- `#guard` (irc.freenode.net).
168
+ 1. Determine which would be the correct next version number according to [semver](http://semver.org/).
169
+ 1. Update the version in `./lib/guard/version.rb`.
170
+ 1. Commit the version in a single commit, the message should be "Bump VERSION to X.Y.Z".
171
+ 1. Push and open a pull request.
172
+ 1. Once CI is green, merge the pull request.
173
+ 1. Pull the changes locally and run `bundle exec rake release:full`; this will tag, push to GitHub, publish to rubygems.org, and publish the [release notes](https://github.com/guard/guard/releases) .
835
174
 
836
175
  ### Author
837
176
 
838
- [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg))
177
+ [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg))
839
178
 
840
179
  ### Core Team
841
180
 
842
- * [Maher Sallam](https://github.com/Maher4Ever) ([@mahersalam](http://twitter.com/mahersalam))
843
- * [Michael Kessler](https://github.com/netzpirat) ([@netzpirat](http://twitter.com/netzpirat), [mksoft.ch](https://mksoft.ch))
844
- * [Rémy Coutable](https://github.com/rymai) ([@rymai](http://twitter.com/rymai), [rymai.me](http://rymai.me))
845
- * [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg), [thibaud.me](http://thibaud.me/))
181
+ * R.I.P. :broken_heart: [Michael Kessler](https://github.com/netzpirat).
182
+ * [Rémy Coutable](https://github.com/rymai).
183
+ * [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg), [thibaud.gg](https://thibaud.gg/)).
846
184
 
847
185
  ### Contributors
848
186
 
849
- [https://github.com/guard/guard/contributors](https://github.com/guard/guard/contributors)
187
+ [https://github.com/guard/guard/graphs/contributors](https://github.com/guard/guard/graphs/contributors)