From 87375c7a1ffdfcab1b10015ca6bb7706c41368ae Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sun, 14 Aug 2011 15:16:16 +0700 Subject: [PATCH 1/9] evaluate_guardfile uses all groups if none specified. Fixes #118 --- lib/guard/dsl.rb | 3 ++- spec/guard/dsl_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/guard/dsl.rb b/lib/guard/dsl.rb index aa78735..12ca379 100644 --- a/lib/guard/dsl.rb +++ b/lib/guard/dsl.rb @@ -104,7 +104,8 @@ module Guard end def group(name, &guard_definition) - guard_definition.call if guard_definition && (@@options[:group].empty? || @@options[:group].include?(name.to_s)) + @groups = @@options[:group] || [] + guard_definition.call if guard_definition && (@groups.empty? || @groups.include?(name.to_s)) end def guard(name, options = {}, &watch_definition) diff --git a/spec/guard/dsl_spec.rb b/spec/guard/dsl_spec.rb index f50c707..740d8ed 100644 --- a/spec/guard/dsl_spec.rb +++ b/spec/guard/dsl_spec.rb @@ -213,6 +213,11 @@ describe Guard::Dsl do ::Guard.should_receive(:add_guard).with('another', anything, {}) lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => ['x','y']) }.should_not raise_error end + it "should evaluate all groups when no group option is specified" do + ::Guard.should_receive(:add_guard).with('test', anything, {}).twice + ::Guard.should_receive(:add_guard).with('another', anything, {}).twice + lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error + end end # TODO: not sure if each seperate quoting/call type needs its own test From ca2a4fa1be2a0a1de98e31b566554cddae5484fe Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sun, 14 Aug 2011 15:16:59 +0700 Subject: [PATCH 2/9] Don't fail specs because of blasted vim swapfiles --- spec/support/listener_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/support/listener_helper.rb b/spec/support/listener_helper.rb index 03bc21b..85c9d78 100644 --- a/spec/support/listener_helper.rb +++ b/spec/support/listener_helper.rb @@ -8,9 +8,11 @@ private end def record_results + noise = %r|\.sw.$| # don't fail specs due to editor swap files, etc. + @results = [] @listener.on_change do |files| - @results += files + @results += files.reject { |f| f =~ noise } end end From e375d2f3271d94fdbae7b427453854bb60f72f9c Mon Sep 17 00:00:00 2001 From: Michael Kessler Date: Sun, 14 Aug 2011 14:17:48 +0200 Subject: [PATCH 3/9] Explain what happens with guards without a group. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f749661..e73b177 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ Required: Optional: * 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. -* 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. +* 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. Guards that don't belong to a group are considered global and are always run. Example: From 820501bf15b32ad6dbcebc73a45e3a2c3b613c63 Mon Sep 17 00:00:00 2001 From: mordaroso Date: Sun, 14 Aug 2011 18:41:05 +0200 Subject: [PATCH 4/9] remove guardfile_contents when re-evaluating so that the Guardfile gets reloaded correctly --- lib/guard/dsl.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/guard/dsl.rb b/lib/guard/dsl.rb index aa78735..abea392 100644 --- a/lib/guard/dsl.rb +++ b/lib/guard/dsl.rb @@ -14,6 +14,7 @@ module Guard def reevaluate_guardfile ::Guard.guards.clear + @@options.delete(:guardfile_contents) Dsl.evaluate_guardfile(@@options) msg = "Guardfile has been re-evaluated." UI.info(msg) From e9cef8809b6c77a4aa1c390929cf358e41c96d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Sun, 14 Aug 2011 21:25:57 +0300 Subject: [PATCH 5/9] [ci skip] Added a link to the screencast on Guard by Ryan Bates (idea taken from the guard-process's README!). :) --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e73b177..06bd4a0 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,12 @@ Features * Automatic & Super fast (when polling is not used) files modifications detection (even new files are detected). * Growl notifications ([growlnotify](http://growl.info/documentation/growlnotify.php) & [growl gem](https://rubygems.org/gems/growl) required). * Libnotify notifications ([libnotify gem](https://rubygems.org/gems/libnotify) required). -* Tested on Ruby 1.8.7, 1.9.2 && ree. +* Tested against Ruby 1.8.7, 1.9.2 and REE. + +Screencast +---------- + +Ryan Bates made a screencast on Guard, you can view it here: http://railscasts.com/episodes/264-guard Install ------- From ec7ba3cda101b12c9cc068105122198f556c15d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Coutable?= Date: Mon, 15 Aug 2011 09:15:29 +0200 Subject: [PATCH 6/9] Use fuubar formatter --- Gemfile | 6 +++++- Guardfile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 3a8f317..d5494f6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source "http://rubygems.org" +source :rubygems gemspec @@ -8,6 +8,10 @@ group :guard do gem 'guard-ronn' end +group :test do + gem 'fuubar' +end + require 'rbconfig' if RbConfig::CONFIG['target_os'] =~ /darwin/i diff --git a/Guardfile b/Guardfile index f32757d..3febef2 100644 --- a/Guardfile +++ b/Guardfile @@ -1,4 +1,4 @@ -guard 'rspec', :version => 2, :keep_failed => false, :cli => '-f doc' do +guard 'rspec', :version => 2, :keep_failed => false, :cli => '--format Fuubar' do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } From 59bb373fa7b6c60de6d0c212eefd43f04a2886f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Coutable?= Date: Mon, 15 Aug 2011 09:19:32 +0200 Subject: [PATCH 7/9] Update CHANGELOG --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e57b83..2a14a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.6.1 - August 15, 2011 + +### Bugs fixes: + +- Pull request [#120](https://github.com/guard/guard/pull/120): remove guardfile_contents when re-evaluating so that the Guardfile gets reloaded correctly. ([@mordaroso][]) +- Pull request [#119](https://github.com/guard/guard/pull/119): Dsl.evaluate_guardfile uses all groups if none specified. ([@ches][]) + ## 0.6.0 - August 13, 2011 ### Bugs fixes: @@ -194,8 +201,10 @@ [@brainopia]: https://github.com/brainopia [@bronson]: https://github.com/bronson [@capotej]: https://github.com/capotej +[@ches]: https://github.com/ches [@chrisberkhout]: https://github.com/chrisberkhout [@dnagir]: https://github.com/dnagir +[@docwhat]: https://github.com/docwhat [@etehtsea]: https://github.com/etehtsea [@fnichol]: https://github.com/fnichol [@Gazer]: https://github.com/Gazer @@ -208,6 +217,7 @@ [@koshigoe]: https://github.com/koshigoe [@mcmire]: https://github.com/mcmire [@mislav]: https://github.com/mislav +[@mordaroso]: https://github.com/mordaroso [@nestegg]: https://github.com/nestegg [@netzpirat]: https://github.com/netzpirat [@nicksieger]: https://github.com/nicksieger From 1ee70fbe2eb189900286ac1d7ce1f242f6aa3fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Coutable?= Date: Mon, 15 Aug 2011 09:49:21 +0200 Subject: [PATCH 8/9] Updates manual --- Guardfile | 10 ++--- man/guard.1 | 101 ++++++++++++----------------------------------- man/guard.1.html | 73 ++++++++++++++++------------------ man/guard.md | 77 ------------------------------------ man/guard.ronn | 93 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 195 deletions(-) delete mode 100644 man/guard.md create mode 100644 man/guard.ronn diff --git a/Guardfile b/Guardfile index 3febef2..106cadf 100644 --- a/Guardfile +++ b/Guardfile @@ -1,9 +1,13 @@ -guard 'rspec', :version => 2, :keep_failed => false, :cli => '--format Fuubar' do +guard :rspec, :version => 2, :keep_failed => false, :cli => '--format Fuubar' do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end +guard :ronn do + watch(%r{^man/.+\.ronn?$}) +end + # require 'guard/guard' # # module ::Guard @@ -17,7 +21,3 @@ end # group "exceptional" do # guard :breaking # end - -guard 'ronn' do - watch(%r{^man/.+\.m(ark)?d(own)?$}) -end diff --git a/man/guard.1 b/man/guard.1 index a6d51fa..ea54ba5 100644 --- a/man/guard.1 +++ b/man/guard.1 @@ -10,7 +10,7 @@ Guard is a command line tool that easily handle events on files modifications\. . .SH "SYNOPSIS" -guard \fIcommand\fR \fIoptions\fR +\fBguard \fR . .SH "COMMANDS" . @@ -21,103 +21,54 @@ Starts Guard\. This is the default command if none is provided\. The following options are available: . .P -\fB\-c\fR/\fB\-\-clear\fR -. -.IP "" 4 -. -.nf - - Clears the Shell after each change\. -. -.fi -. -.IP "" 0 +\fB\-c\fR, \fB\-\-clear\fR Clears the Shell after each change\. . .P -\fB\-n\fR/\fB\-\-notify\fR \fIflag\fR -. -.IP "" 4 -. -.nf - - Disable notifications (Growl or Libnotify depending on your system)\. - Note that notifications can also be disabled globally by setting a GUARD_NOTIFY environment variable to false\. - The part can be passed to guard using true/false or t/f\. -. -.fi -. -.IP "" 0 +\fB\-n\fR, \fB\-\-notify\fR \fIFLAG\fR Disable notifications (Growl or Libnotify depending on your system)\. Notifications can be disabled globally by setting a GUARD_NOTIFY environment variable to false\. FLAG can be \fBtrue\fR/\fBfalse\fR or \fBt\fR/\fBf\fR\. . .P -\fB\-d\fR/\fB\-\-debug\fR -. -.IP "" 4 -. -.nf - - Runs Guard in debug mode\. -. -.fi -. -.IP "" 0 +\fB\-d\fR, \fB\-\-debug\fR Runs Guard in debug mode\. . .P -\fB\-g\fR/\fB\-\-group\fR \fIgroup\fR \.\.\. -. -.IP "" 4 -. -.nf - - Runs only the groups specified\. -. -.fi -. -.IP "" 0 +\fB\-g\fR, \fB\-\-group\fR \fIGROUP1\fR \fIGROUP2\fR\.\.\. Runs only the groups specified by GROUP1, GROUP2 etc\. Groups name should be separated by spaces\. Guards that don\'t belong to a group are considered global and are always run\. . .P -\fB\-w\fR/\fB\-\-watchdir\fR \fIfolder\fR -. -.IP "" 4 -. -.nf - - Specify the directory to watch\. -. -.fi -. -.IP "" 0 +\fB\-w\fR, \fB\-\-watchdir\fR \fIPATH\fR . .P -\fB\-G\fR/\fB\-\-guardfile\fR \fIfile\fR +Tells Guard to watch PATH instead of \fB\./\fR\. . -.IP "" 4 +.P +\fB\-G\fR, \fB\-\-guardfile\fR \fIFILE\fR Tells Guard to use FILE as its Guardfile instead of \fB\./Guardfile\fR or \fB~/\.Guardfile\fR\. . -.nf - - Specify a Guardfile by giving its path\. +.SS "init [GUARD]" +If no Guardfile is present in the current directory, creates an empty Guardfile\. . -.fi -. -.IP "" 0 -. -.SS "init [guard]" -Add the requested guard\'s default Guardfile configuration to the current Guardfile\. +.P +If \fIGUARD\fR is present, add its default Guardfile configuration to the current Guardfile\. Note that \fIGUARD\fR is the guard\'s name without the \fBguard\-\fR prefix\. For instance to initialize guard\-rspec, run \fBguard init rspec\fR\. . .SS "list" Lists guards that can be used with the \fBinit\fR command\. . -.SS "\-T/show" +.SS "\-T, show" List defined groups and guards for the current Guardfile\. . -.SH "OPTIONS" -. -.TP -\fB\-h\fR +.SS "\-h, help [COMMAND]" List all of Guard\'s available commands\. . -.SS "start" +.P +If \fICOMMAND\fR is given, displays a specific help for \fITASK\fR\. . .SH "EXAMPLES" +Initialize Guard and a specific guard at the same time: +. +.P +\fB[bundle exec] guard init [rspec]\fR +. +.P +Run Guard: +. +.P \fB[bundle exec] guard [start] \-\-watchdir ~/dev \-\-guardfile ~/env/Guardfile \-\-clear \-\-group backend frontend \-\-notify false \-\-debug\fR . .P diff --git a/man/guard.1.html b/man/guard.1.html index 81d3956..95d230f 100644 --- a/man/guard.1.html +++ b/man/guard.1.html @@ -57,7 +57,6 @@ DESCRIPTION SYNOPSIS COMMANDS - OPTIONS EXAMPLES AUTHORS / CONTRIBUTORS WWW @@ -80,71 +79,69 @@

SYNOPSIS

-

guard command options

+

guard <COMMAND> <OPTIONS>

COMMANDS

start

-

Starts Guard. This is the default command if none is provided.

+

Starts Guard. This is the default command if none is provided.

The following options are available:

-

-c/--clear

+

-c, --clear + Clears the Shell after each change.

-
    Clears the Shell after each change.
-
+

-n, --notify FLAG + Disable notifications (Growl or Libnotify depending on your system). + Notifications can be disabled globally by setting a GUARD_NOTIFY environment variable to false. + FLAG can be true/false or t/f.

-

-n/--notify flag

+

-d, --debug + Runs Guard in debug mode.

-
    Disable notifications (Growl or Libnotify depending on your system).
-    Note that notifications can also be disabled globally by setting a GUARD_NOTIFY environment variable to false.
-    The <flag> part can be passed to guard using true/false or t/f.
-
+

-g, --group GROUP1 GROUP2... + Runs only the groups specified by GROUP1, GROUP2 etc. + Groups name should be separated by spaces. + Guards that don't belong to a group are considered global and are always run.

-

-d/--debug

+

-w, --watchdir PATH

-
    Runs Guard in debug mode.
-
+

Tells Guard to watch PATH instead of ./.

-

-g/--group group ...

+

-G, --guardfile FILE + Tells Guard to use FILE as its Guardfile instead of ./Guardfile or ~/.Guardfile.

-
    Runs only the groups specified.
-
+

init [GUARD]

-

-w/--watchdir folder

+

If no Guardfile is present in the current directory, creates an empty Guardfile.

-
    Specify the directory to watch.
-
- -

-G/--guardfile file

- -
    Specify a Guardfile by giving its path.
-
- -

init [guard]

- -

Add the requested guard's default Guardfile configuration to the current Guardfile.

+

If GUARD is present, add its default Guardfile configuration to the current Guardfile. +Note that GUARD is the guard's name without the guard- prefix. +For instance to initialize guard-rspec, run guard init rspec.

list

-

Lists guards that can be used with the init command.

+

Lists guards that can be used with the init command.

-

-T/show

+

-T, show

-

List defined groups and guards for the current Guardfile.

+

List defined groups and guards for the current Guardfile.

-

OPTIONS

+

-h, help [COMMAND]

-
-
-h
List all of Guard's available commands.
-
+

List all of Guard's available commands.

- -

start

+

If COMMAND is given, displays a specific help for TASK.

EXAMPLES

+

Initialize Guard and a specific guard at the same time:

+ +

[bundle exec] guard init [rspec]

+ +

Run Guard:

+

[bundle exec] guard [start] --watchdir ~/dev --guardfile ~/env/Guardfile --clear --group backend frontend --notify false --debug

or in a more concise way:

diff --git a/man/guard.md b/man/guard.md deleted file mode 100644 index f61dd1d..0000000 --- a/man/guard.md +++ /dev/null @@ -1,77 +0,0 @@ -guard(1) -- Guard keeps an eye on your file modifications. -======================================================== - -## DESCRIPTION - -Guard is a command line tool that easily handle events on files modifications. - -## SYNOPSIS - -guard - -## COMMANDS - -### start - Starts Guard. This is the default command if none is provided. - -The following options are available: - - `-c`/`--clear` - Clears the Shell after each change. - - `-n`/`--notify` - Disable notifications (Growl or Libnotify depending on your system). - Note that notifications can also be disabled globally by setting a GUARD_NOTIFY environment variable to false. - The part can be passed to guard using true/false or t/f. - - `-d`/`--debug` - Runs Guard in debug mode. - - `-g`/`--group` ... - Runs only the groups specified. - - `-w`/`--watchdir` - Specify the directory to watch. - - `-G`/`--guardfile` - Specify a Guardfile by giving its path. - -### init [guard] - Add the requested guard's default Guardfile configuration to the current Guardfile. - -### list - Lists guards that can be used with the `init` command. - -### -T/show - List defined groups and guards for the current Guardfile. - -## OPTIONS - -* `-h`: - List all of Guard's available commands. - -### start - -## EXAMPLES - -`[bundle exec] guard [start] --watchdir ~/dev --guardfile ~/env/Guardfile --clear --group backend frontend --notify false --debug` - -or in a more concise way: - -`[bundle exec] guard [start] -w ~/dev -G ~/env/Guardfile -c -g backend frontend -n f -d` - -## AUTHORS / CONTRIBUTORS - -Thibaud Guillaume-Gentil is the main author. - -A list of contributors based on all commits can be found here: -https://github.com/guard/guard/contributors - -For an exhaustive list of all the contributors, please see the CHANGELOG: -https://github.com/guard/guard/blob/master/CHANGELOG.md - -This manual has been written by Remy Coutable. - -## WWW - -https://github.com/guard/guard \ No newline at end of file diff --git a/man/guard.ronn b/man/guard.ronn new file mode 100644 index 0000000..412284a --- /dev/null +++ b/man/guard.ronn @@ -0,0 +1,93 @@ +guard(1) -- Guard keeps an eye on your file modifications. +======================================================== + +## DESCRIPTION + +Guard is a command line tool that easily handle events on files modifications. + +## SYNOPSIS + +`guard ` + +## COMMANDS + +### start + +Starts Guard. This is the default command if none is provided. + +The following options are available: + +`-c`, `--clear` + Clears the Shell after each change. + +`-n`, `--notify` + Disable notifications (Growl or Libnotify depending on your system). + Notifications can be disabled globally by setting a GUARD_NOTIFY environment variable to false. + FLAG can be `true`/`false` or `t`/`f`. + +`-d`, `--debug` + Runs Guard in debug mode. + +`-g`, `--group` ... + Runs only the groups specified by GROUP1, GROUP2 etc. + Groups name should be separated by spaces. + Guards that don't belong to a group are considered global and are always run. + +`-w`, `--watchdir` + +Tells Guard to watch PATH instead of `./`. + +`-G`, `--guardfile` + Tells Guard to use FILE as its Guardfile instead of `./Guardfile` or `~/.Guardfile`. + +### init [GUARD] + +If no Guardfile is present in the current directory, creates an empty Guardfile. + +If is present, add its default Guardfile configuration to the current Guardfile. +Note that is the guard's name without the `guard-` prefix. +For instance to initialize guard-rspec, run `guard init rspec`. + +### list + +Lists guards that can be used with the `init` command. + +### -T, show + +List defined groups and guards for the current Guardfile. + +### -h, help [COMMAND] + +List all of Guard's available commands. + +If is given, displays a specific help for . + +## EXAMPLES + +Initialize Guard and a specific guard at the same time: + +`[bundle exec] guard init [rspec]` + +Run Guard: + +`[bundle exec] guard [start] --watchdir ~/dev --guardfile ~/env/Guardfile --clear --group backend frontend --notify false --debug` + +or in a more concise way: + +`[bundle exec] guard [start] -w ~/dev -G ~/env/Guardfile -c -g backend frontend -n f -d` + +## AUTHORS / CONTRIBUTORS + +Thibaud Guillaume-Gentil is the main author. + +A list of contributors based on all commits can be found here: +https://github.com/guard/guard/contributors + +For an exhaustive list of all the contributors, please see the CHANGELOG: +https://github.com/guard/guard/blob/master/CHANGELOG.md + +This manual has been written by Remy Coutable. + +## WWW + +https://github.com/guard/guard \ No newline at end of file From d268f236bf0f859a0c8729b44e605612e7031851 Mon Sep 17 00:00:00 2001 From: Thibaud Guillaume-Gentil Date: Mon, 15 Aug 2011 09:53:10 +0200 Subject: [PATCH 9/9] Version 0.6.1 --- lib/guard/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/guard/version.rb b/lib/guard/version.rb index b1df99c..6b73f67 100644 --- a/lib/guard/version.rb +++ b/lib/guard/version.rb @@ -1,3 +1,3 @@ module Guard - VERSION = "0.6.0" unless defined? Guard::VERSION + VERSION = "0.6.1" unless defined? Guard::VERSION end