From 94e04ec7e0c16e533be91b5769af1c84e0045a40 Mon Sep 17 00:00:00 2001 From: slavic Date: Sat, 30 Apr 2011 13:38:57 +0300 Subject: [PATCH 1/8] add support for Windows using rb-fchange. Specs fail because of k32WaitForMultipleObjects blocks all threads --- Gemfile | 1 + lib/guard/listener.rb | 7 +++ lib/guard/listeners/windows.rb | 35 ++++++++++++ spec/guard/listener_spec.rb | 6 +-- spec/guard/listeners/windows_spec.rb | 79 ++++++++++++++++++++++++++++ spec/support/platform_helper.rb | 4 ++ 6 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 lib/guard/listeners/windows.rb create mode 100644 spec/guard/listeners/windows_spec.rb diff --git a/Gemfile b/Gemfile index 180543c..8b676d9 100644 --- a/Gemfile +++ b/Gemfile @@ -14,4 +14,5 @@ if Config::CONFIG['target_os'] =~ /linux/i end if Config::CONFIG['target_os'] =~ /mswin|mingw/i gem 'win32console' + gem 'rb-fchange', :git => 'git://github.com/stereobooster/rb-fchange.git' end diff --git a/lib/guard/listener.rb b/lib/guard/listener.rb index 3675489..0021c6b 100644 --- a/lib/guard/listener.rb +++ b/lib/guard/listener.rb @@ -4,6 +4,7 @@ module Guard autoload :Darwin, 'guard/listeners/darwin' autoload :Linux, 'guard/listeners/linux' + autoload :Windows, 'guard/listeners/windows' autoload :Polling, 'guard/listeners/polling' class Listener @@ -14,6 +15,8 @@ module Guard Darwin.new elsif linux? && Linux.usable? Linux.new + elsif windows? && Windows.usable? + Windows.new else UI.info "Using polling (Please help us to support your system better than that.)" Polling.new @@ -54,6 +57,10 @@ module Guard Config::CONFIG['target_os'] =~ /linux/i end + def self.windows? + Config::CONFIG['target_os'] =~ /mswin|mingw/i + end + end end diff --git a/lib/guard/listeners/windows.rb b/lib/guard/listeners/windows.rb new file mode 100644 index 0000000..7fd5299 --- /dev/null +++ b/lib/guard/listeners/windows.rb @@ -0,0 +1,35 @@ +module Guard + class Windows < Listener + attr_reader :fchange + + def initialize + super + @fchange = FChange::Notifier.new + end + + def on_change(&callback) + @fchange.watch Dir.pwd, :all_events do |event| + files = modified_files([event.watcher.path]) + update_last_event + callback.call(files) + end + end + + def start + @fchange.run + end + + def stop + @fchange.stop + end + + def self.usable? + require 'rb-fchange' + true + rescue LoadError + UI.info "Please install rb-fchange gem for Windows file events support" + false + end + + end +end diff --git a/spec/guard/listener_spec.rb b/spec/guard/listener_spec.rb index dfbface..a5454aa 100644 --- a/spec/guard/listener_spec.rb +++ b/spec/guard/listener_spec.rb @@ -14,10 +14,10 @@ describe Guard::Listener do subject.select_and_init end - it "uses polling listener on Windows" do + it "uses windows listener on Windows" do Config::CONFIG['target_os'] = 'win32' - Guard::Polling.stub(:usable?).and_return(true) - Guard::Polling.should_receive(:new) + Guard::Windows.stub(:usable?).and_return(true) + Guard::Windows.should_receive(:new) subject.select_and_init end diff --git a/spec/guard/listeners/windows_spec.rb b/spec/guard/listeners/windows_spec.rb new file mode 100644 index 0000000..d161b1f --- /dev/null +++ b/spec/guard/listeners/windows_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper' +require 'guard/listeners/windows' + +describe Guard::Windows do + subject { Guard::Windows } + + if linux? + it "isn't usable on linux" do + subject.should_not be_usable + end + end + + if mac? + it "isn't usable on Mac" do + subject.should_not be_usable + end + end + + if windows? + it "is usable on Windows 2000 and later" do + subject.should be_usable + end + + describe "#on_change" do + before(:each) do + @results = [] + @listener = Guard::Windows.new + @listener.on_change do |files| + @results += files + end + end + + it "catches new file" do + file = @fixture_path.join("newfile.rb") + File.exists?(file).should be_false + start + FileUtils.touch file + stop + File.delete file + @results.should == ['spec/fixtures/newfile.rb'] + end + + it "catches file update" do + file = @fixture_path.join("folder1/file1.txt") + File.exists?(file).should be_true + start + FileUtils.touch file + stop + @results.should == ['spec/fixtures/folder1/file1.txt'] + end + + it "catches files update" do + file1 = @fixture_path.join("folder1/file1.txt") + file2 = @fixture_path.join("folder1/folder2/file2.txt") + File.exists?(file1).should be_true + File.exists?(file2).should be_true + start + FileUtils.touch file1 + FileUtils.touch file2 + stop + @results.should == ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt'] + end + end + end + +private + + def start + sleep 0.6 + Thread.new { @listener.start } + sleep 0.6 + end + + def stop + sleep 0.6 + @listener.stop + end + +end diff --git a/spec/support/platform_helper.rb b/spec/support/platform_helper.rb index 2b8bfb5..c1acf10 100644 --- a/spec/support/platform_helper.rb +++ b/spec/support/platform_helper.rb @@ -4,4 +4,8 @@ end def linux? Config::CONFIG['target_os'] =~ /linux/i +end + +def windows? + Config::CONFIG['target_os'] =~ /mswin|mingw/i end \ No newline at end of file From 0f7bca7bbd5bbcffee41645f488c538a4e84fb44 Mon Sep 17 00:00:00 2001 From: slavic Date: Sun, 1 May 2011 21:49:16 +0300 Subject: [PATCH 2/8] now all specs work --- lib/guard/listeners/windows.rb | 5 +++-- spec/guard/listener_spec.rb | 2 +- spec/guard/listeners/windows_spec.rb | 11 ++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/guard/listeners/windows.rb b/lib/guard/listeners/windows.rb index 7fd5299..e6d888a 100644 --- a/lib/guard/listeners/windows.rb +++ b/lib/guard/listeners/windows.rb @@ -8,8 +8,9 @@ module Guard end def on_change(&callback) - @fchange.watch Dir.pwd, :all_events do |event| - files = modified_files([event.watcher.path]) + @fchange.watch(Dir.pwd, :all_events, :recursive) do |event| + paths = [File.expand_path(event.watcher.path) + '/'] + files = modified_files(paths, {:all => true}) update_last_event callback.call(files) end diff --git a/spec/guard/listener_spec.rb b/spec/guard/listener_spec.rb index a5454aa..5d09104 100644 --- a/spec/guard/listener_spec.rb +++ b/spec/guard/listener_spec.rb @@ -15,7 +15,7 @@ describe Guard::Listener do end it "uses windows listener on Windows" do - Config::CONFIG['target_os'] = 'win32' + Config::CONFIG['target_os'] = 'mingw' Guard::Windows.stub(:usable?).and_return(true) Guard::Windows.should_receive(:new) subject.select_and_init diff --git a/spec/guard/listeners/windows_spec.rb b/spec/guard/listeners/windows_spec.rb index d161b1f..4cc1c6b 100644 --- a/spec/guard/listeners/windows_spec.rb +++ b/spec/guard/listeners/windows_spec.rb @@ -32,11 +32,20 @@ describe Guard::Windows do it "catches new file" do file = @fixture_path.join("newfile.rb") + if File.exists?(file) + begin + File.delete file + rescue + end + end File.exists?(file).should be_false start FileUtils.touch file stop - File.delete file + begin + File.delete file + rescue + end @results.should == ['spec/fixtures/newfile.rb'] end From 5c93116d6f069bbbc76596db3d9d4ac11b343e63 Mon Sep 17 00:00:00 2001 From: slavic Date: Sat, 7 May 2011 13:40:45 +0300 Subject: [PATCH 3/8] Update documentation for windows support --- README.rdoc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index dfeee74..8eeb123 100644 --- a/README.rdoc +++ b/README.rdoc @@ -6,11 +6,12 @@ Guard is a command line tool that easily handle events on files modifications. - {FSEvent}[http://en.wikipedia.org/wiki/FSEvents] support on Mac OS X 10.5+ (without RubyCocoa!, {rb-fsevent gem, >= 0.3.5}[https://rubygems.org/gems/rb-fsevent] required). - {Inotify}[http://en.wikipedia.org/wiki/Inotify] support on Linux ({rb-inotify gem, >= 0.5.1}[https://rubygems.org/gems/rb-inotify] required). +- {Directory Change Notification}[http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx] suuport on Windows ({rb-fchange, >= 0.0.2}[https://github.com/stereobooster/rb-fchange] required) - Polling on the other operating systems (help us to support more OS). - 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.6, 1.8.7 & 1.9.2. +- Tested on Ruby 1.8.7 & 1.9.2. == Install @@ -56,6 +57,12 @@ And add it to you Gemfile: gem 'libnotify' +=== On Windows + +Install the rb-fchange gem for {Directory Change Notification}[http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx] support: + + $ gem install rb-fchange + == Usage Just launch Guard inside your Ruby / Rails project with: From 29069cdeb7a5fb6cf704e16d733cb6c0ff4bf7e5 Mon Sep 17 00:00:00 2001 From: slavic Date: Sat, 7 May 2011 15:18:32 +0300 Subject: [PATCH 4/8] Update documentation for windows support --- Gemfile | 4 ++-- README.markdown | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 00c598c..bd1d194 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,6 @@ if Config::CONFIG['target_os'] =~ /linux/i gem 'libnotify', '~> 0.1.3', :require => false end if Config::CONFIG['target_os'] =~ /mswin|mingw/i - gem 'win32console' - gem 'rb-fchange', :git => 'git://github.com/stereobooster/rb-fchange.git' + gem 'win32console', :require => false + gem 'rb-fchange', '>= 0.0.2', :require => false end diff --git a/README.markdown b/README.markdown index 1a8d72a..60bb66b 100644 --- a/README.markdown +++ b/README.markdown @@ -10,6 +10,7 @@ Features * [FSEvent](http://en.wikipedia.org/wiki/FSEvents) support on Mac OS X 10.5+ (without RubyCocoa!, [rb-fsevent gem, >= 0.3.5](https://rubygems.org/gems/rb-fsevent) required). * [Inotify](http://en.wikipedia.org/wiki/Inotify) support on Linux ([rb-inotify gem, >= 0.5.1](https://rubygems.org/gems/rb-inotify) required). +* [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) suuport on Windows ([rb-fchange, >= 0.0.2](https://rubygems.org/gems/rb-fchange) required) * Polling on the other operating systems (help us to support more OS). * 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). @@ -67,6 +68,13 @@ And add it to you Gemfile: gem 'libnotify' ``` +### On Windows + +Install the rb-fchange gem for [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) support: + + $ gem install rb-fchange + + Usage ----- From 9cfe8d3635586bca37281b433e20048a4ad1dd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Sat, 7 May 2011 18:40:13 +0200 Subject: [PATCH 5/8] Don't modify a frozen hash. --- lib/guard.rb | 7 +++---- spec/guard/notifier_spec.rb | 6 +++--- spec/guard_spec.rb | 8 +++++++- spec/spec_helper.rb | 1 - 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/guard.rb b/lib/guard.rb index 12c35a9..c5fee7d 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -16,8 +16,7 @@ module Guard @listener = Listener.select_and_init @guards = [] - options[:notify] = false if ENV["GUARD_NOTIFY"] == 'false' - options[:notify] ? Notifier.turn_on : Notifier.turn_off + !@options[:notify] || ENV["GUARD_NOTIFY"] == 'false' ? Notifier.turn_off : Notifier.turn_on self end @@ -61,7 +60,7 @@ module Guard guard.send(task_to_supervise, *args) rescue Exception UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{$!}") - ::Guard.guards.delete guard + guards.delete guard UI.info("Guard #{guard.class.name} has just been fired") return $! end @@ -83,7 +82,7 @@ module Guard def get_guard_class(name) try_to_load_gem name - self.const_get(self.constants.find{|klass_name| klass_name.to_s.downcase == name.downcase }) + self.const_get(self.constants.find{ |klass_name| klass_name.to_s.downcase == name.downcase }) rescue TypeError UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}" end diff --git a/spec/guard/notifier_spec.rb b/spec/guard/notifier_spec.rb index e09622c..5a228e1 100644 --- a/spec/guard/notifier_spec.rb +++ b/spec/guard/notifier_spec.rb @@ -38,14 +38,14 @@ describe Guard::Notifier do end describe ".turn_off" do + before(:each) { subject.turn_off } + if mac? && growl_installed? it "does nothing" do Growl.should_not_receive(:notify) subject.notify 'great', :title => 'Guard' end - end - - if linux? && libnotify_installed? + elsif linux? && libnotify_installed? it "does nothing" do Libnotify.should_not_receive(:show) subject.notify 'great', :title => 'Guard' diff --git a/spec/guard_spec.rb b/spec/guard_spec.rb index bf3faa8..c5b6a49 100644 --- a/spec/guard_spec.rb +++ b/spec/guard_spec.rb @@ -4,6 +4,12 @@ describe Guard do describe "Class Methods" do describe ".setup" do + before(:each) do + # set ENV["GUARD_NOTIFY"] to nil in case the user has ENV["GUARD_NOTIFY"] = 'false' set + @old_env_guard_notify = ENV["GUARD_NOTIFY"] + ENV["GUARD_NOTIFY"] = nil + end + after(:each) { ENV["GUARD_NOTIFY"] = @old_env_guard_notify } subject { ::Guard.setup } it "should retrieve itself for chaining" do @@ -36,7 +42,7 @@ describe Guard do it "should turn off notifier if env[GUARD_NOTIFY] is false" do ::Guard::Notifier.should_receive(:turn_off) ENV["GUARD_NOTIFY"] = 'false' - ::Guard.setup(:notify => true) + ::Guard.setup({ :notify => true }.freeze) ENV["GUARD_NOTIFY"] = nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f69ed16..1520849 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,7 +15,6 @@ RSpec.configure do |config| config.run_all_when_everything_filtered = true config.before(:each) do - Guard::Notifier.turn_off @fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__)) end From 057549a84d8af796d4eb1044001585bd517116cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Sat, 7 May 2011 19:00:21 +0200 Subject: [PATCH 6/8] Readme cleanup --- README.markdown | 58 +++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/README.markdown b/README.markdown index 60bb66b..b584f40 100644 --- a/README.markdown +++ b/README.markdown @@ -10,7 +10,7 @@ Features * [FSEvent](http://en.wikipedia.org/wiki/FSEvents) support on Mac OS X 10.5+ (without RubyCocoa!, [rb-fsevent gem, >= 0.3.5](https://rubygems.org/gems/rb-fsevent) required). * [Inotify](http://en.wikipedia.org/wiki/Inotify) support on Linux ([rb-inotify gem, >= 0.5.1](https://rubygems.org/gems/rb-inotify) required). -* [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) suuport on Windows ([rb-fchange, >= 0.0.2](https://rubygems.org/gems/rb-fchange) required) +* [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) support on Windows ([rb-fchange, >= 0.0.2](https://rubygems.org/gems/rb-fchange) required). * Polling on the other operating systems (help us to support more OS). * 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). @@ -22,9 +22,9 @@ Install Install the gem: - $ gem install guard +`$ gem install guard` -Add it to your Gemfile (inside the test group): +Add it to your Gemfile (inside the `test` group): ``` ruby gem 'guard' @@ -32,7 +32,7 @@ gem 'guard' Generate an empty Guardfile with: - $ guard init +`$ guard init` Add the guards you need to your Guardfile (see the existing guards below). @@ -40,11 +40,11 @@ Add the guards you need to your Guardfile (see the existing guards below). Install the rb-fsevent gem for [FSEvent](http://en.wikipedia.org/wiki/FSEvents) support: - $ gem install rb-fsevent +`$ gem install rb-fsevent` Install the Growl gem if you want notification support: - $ gem install growl +`$ gem install growl` And add it to you Gemfile: @@ -56,11 +56,11 @@ gem 'growl' Install the rb-inotify gem for [inotify](http://en.wikipedia.org/wiki/Inotify) support: - $ gem install rb-inotify +`$ gem install rb-inotify` Install the Libnotify gem if you want notification support: - $ gem install libnotify +`$ gem install libnotify` And add it to you Gemfile: @@ -72,19 +72,18 @@ gem 'libnotify' Install the rb-fchange gem for [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) support: - $ gem install rb-fchange - +`$ gem install rb-fchange` Usage ----- Just launch Guard inside your Ruby / Rails project with: - $ guard [start] +`$ guard [start]` or if you use Bundler, to run the Guard executable specific to your bundle: - $ bundle exec guard +`$ bundle exec guard` Command line options -------------------- @@ -101,23 +100,23 @@ Notifications (growl/libnotify) can be disabled with: Notifications can also be disabled by setting a `GUARD_NOTIFY` environment variable to `false` -The guards to start can be specified by group (see the Guardfile DSL below) specifying the --group (or -g) option: +The guards to start can be specified by group (see the Guardfile DSL below) specifying the `--group` (or `-g`) option: $ guard --group group_name another_group_name $ guard -g group_name another_group_name # shortcut Options list is available with: - $ guard help [TASK] +`$ guard help [TASK]` Signal handlers --------------- Signal handlers are used to interact with Guard: -* Ctrl-C - Calls each guard's stop method, in the same order they are declared in the Guardfile, and then quits Guard itself. -* Ctrl-\\ - Calls each guard's run_all method, in the same order they are declared in the Guardfile. -* Ctrl-Z - Calls each guard's reload method, in the same order they are declared in the Guardfile. +* `Ctrl-C` - Calls each guard's `stop` method, in the same order they are declared in the Guardfile, and then quits Guard itself. +* `Ctrl-\` - Calls each guard's `run_all` method, in the same order they are declared in the Guardfile. +* `Ctrl-Z` - Calls each guard's `reload` method, in the same order they are declared in the Guardfile. Available Guards ---------------- @@ -126,7 +125,7 @@ Available Guards ### Add a guard to your Guardfile -Add it to your Gemfile (inside the test group): +Add it to your Gemfile (inside the `test` group): ``` ruby gem '' @@ -134,21 +133,23 @@ gem '' Insert default guard's definition to your Guardfile by running this command: - $ guard init +`$ guard init ` You are good to go! Guardfile DSL ------------- -The Guardfile DSL consists of just three simple methods: guard, watch & group. +The Guardfile DSL consists of just three simple methods: `guard`, `watch` & `group`. Required: -* The guard method allows you to add a guard with an optional hash of options. -* 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. + +* The `guard` method allows you to add a guard with an optional hash of options. +* 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. Optional: -* 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. Example: @@ -184,7 +185,7 @@ end Create a new guard ------------------ -Creating a new guard is very easy, just create a new gem (bundle gem if you use Bundler) with this basic structure: +Creating a new guard is very easy, just create a new gem (`bundle gem` if you use Bundler) with this basic structure: lib/ guard/ @@ -193,7 +194,7 @@ Creating a new guard is very easy, just create a new gem (bundle gem if Guardfile (needed for guard init ) guard-name.rb -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: +`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: ``` ruby require 'guard' @@ -254,7 +255,7 @@ Alternatively, a new guard can be added inline to a Guardfile with this basic st require 'guard/guard' module ::Guard - class Example < ::Guard::Guard + class InlineGuard < ::Guard::Guard def run_all true end @@ -279,3 +280,8 @@ Author ------ [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) + +Contributors +------ + +https://github.com/guard/guard/contributors \ No newline at end of file From b7137bbf0c7f73c9efcf667d9c208e24188d580d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Sat, 7 May 2011 19:09:43 +0200 Subject: [PATCH 7/8] Made the README even more gorgeous! --- README.markdown | 62 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/README.markdown b/README.markdown index b584f40..94e87ea 100644 --- a/README.markdown +++ b/README.markdown @@ -22,7 +22,9 @@ Install Install the gem: -`$ gem install guard` +``` bash +$ gem install guard` +``` Add it to your Gemfile (inside the `test` group): @@ -32,7 +34,9 @@ gem 'guard' Generate an empty Guardfile with: -`$ guard init` +``` bash +$ guard init` +``` Add the guards you need to your Guardfile (see the existing guards below). @@ -40,11 +44,15 @@ Add the guards you need to your Guardfile (see the existing guards below). Install the rb-fsevent gem for [FSEvent](http://en.wikipedia.org/wiki/FSEvents) support: -`$ gem install rb-fsevent` +``` bash +$ gem install rb-fsevent` +``` Install the Growl gem if you want notification support: -`$ gem install growl` +``` bash +$ gem install growl` +``` And add it to you Gemfile: @@ -56,11 +64,15 @@ gem 'growl' Install the rb-inotify gem for [inotify](http://en.wikipedia.org/wiki/Inotify) support: -`$ gem install rb-inotify` +``` bash +$ gem install rb-inotify` +``` Install the Libnotify gem if you want notification support: -`$ gem install libnotify` +``` bash +$ gem install libnotify` +``` And add it to you Gemfile: @@ -72,42 +84,56 @@ gem 'libnotify' Install the rb-fchange gem for [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) support: -`$ gem install rb-fchange` +``` bash +$ gem install rb-fchange` +``` Usage ----- Just launch Guard inside your Ruby / Rails project with: -`$ guard [start]` +``` bash +$ guard [start]` +``` or if you use Bundler, to run the Guard executable specific to your bundle: -`$ bundle exec guard` +``` bash +$ bundle exec guard` +``` Command line options -------------------- Shell can be cleared after each change with: - $ guard --clear - $ guard -c # shortcut +``` bash +$ guard --clear +$ guard -c # shortcut +``` Notifications (growl/libnotify) can be disabled with: - $ guard --notify false - $ guard -n false # shortcut +``` bash +$ guard --notify false +$ guard -n false # shortcut +``` Notifications can also be disabled by setting a `GUARD_NOTIFY` environment variable to `false` The guards to start can be specified by group (see the Guardfile DSL below) specifying the `--group` (or `-g`) option: - $ guard --group group_name another_group_name - $ guard -g group_name another_group_name # shortcut +``` bash +$ guard --group group_name another_group_name +$ guard -g group_name another_group_name # shortcut +``` Options list is available with: -`$ guard help [TASK]` +``` bash +$ guard help [TASK]` +``` Signal handlers --------------- @@ -133,7 +159,9 @@ gem '' Insert default guard's definition to your Guardfile by running this command: -`$ guard init ` +``` bash +$ guard init +``` You are good to go! From 6d5cb96eef59d8d0531776e87c55a8ca77dfb7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Sat, 7 May 2011 15:58:19 -0700 Subject: [PATCH 8/8] Removed unexpected "`" in README --- README.markdown | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index 94e87ea..fd09da1 100644 --- a/README.markdown +++ b/README.markdown @@ -23,7 +23,7 @@ Install Install the gem: ``` bash -$ gem install guard` +$ gem install guard ``` Add it to your Gemfile (inside the `test` group): @@ -35,7 +35,7 @@ gem 'guard' Generate an empty Guardfile with: ``` bash -$ guard init` +$ guard init ``` Add the guards you need to your Guardfile (see the existing guards below). @@ -45,13 +45,13 @@ Add the guards you need to your Guardfile (see the existing guards below). Install the rb-fsevent gem for [FSEvent](http://en.wikipedia.org/wiki/FSEvents) support: ``` bash -$ gem install rb-fsevent` +$ gem install rb-fsevent ``` Install the Growl gem if you want notification support: ``` bash -$ gem install growl` +$ gem install growl ``` And add it to you Gemfile: @@ -65,13 +65,13 @@ gem 'growl' Install the rb-inotify gem for [inotify](http://en.wikipedia.org/wiki/Inotify) support: ``` bash -$ gem install rb-inotify` +$ gem install rb-inotify ``` Install the Libnotify gem if you want notification support: ``` bash -$ gem install libnotify` +$ gem install libnotify ``` And add it to you Gemfile: @@ -85,7 +85,7 @@ gem 'libnotify' Install the rb-fchange gem for [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) support: ``` bash -$ gem install rb-fchange` +$ gem install rb-fchange ``` Usage @@ -94,13 +94,13 @@ Usage Just launch Guard inside your Ruby / Rails project with: ``` bash -$ guard [start]` +$ guard [start] ``` or if you use Bundler, to run the Guard executable specific to your bundle: ``` bash -$ bundle exec guard` +$ bundle exec guard ``` Command line options @@ -132,7 +132,7 @@ $ guard -g group_name another_group_name # shortcut Options list is available with: ``` bash -$ guard help [TASK]` +$ guard help [TASK] ``` Signal handlers