From 043d28589422a357064ae0340b104918a184392f Mon Sep 17 00:00:00 2001 From: Yann Lugrin Date: Mon, 20 Jun 2011 10:08:32 +0200 Subject: [PATCH] don't return directories when requesting files --- lib/guard/listener.rb | 5 ++--- spec/guard/listener_spec.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/guard/listener.rb b/lib/guard/listener.rb index d01cb10..4b5742a 100644 --- a/lib/guard/listener.rb +++ b/lib/guard/listener.rb @@ -47,7 +47,7 @@ module Guard end def modified_files(dirs, options = {}) - files = potentially_modified_files(dirs, options).select { |path| File.file?(path) && file_modified?(path) } + files = potentially_modified_files(dirs, options).select { |path| file_modified?(path) } relativate_paths files end @@ -77,12 +77,11 @@ module Guard !!@relativate_paths end - private def potentially_modified_files(dirs, options = {}) match = options[:all] ? "**/*" : "*" - Dir.glob(dirs.map { |dir| "#{dir}#{match}" }, File::FNM_DOTMATCH).select { |file| file !~ /\.\.?$/ } + Dir.glob(dirs.map { |dir| "#{dir}#{match}" }, File::FNM_DOTMATCH).select { |file| File.file?(file) } end # Depending on the filesystem, mtime is probably only precise to the second, so round diff --git a/spec/guard/listener_spec.rb b/spec/guard/listener_spec.rb index 2809856..68c9dac 100644 --- a/spec/guard/listener_spec.rb +++ b/spec/guard/listener_spec.rb @@ -42,7 +42,7 @@ describe Guard::Listener do subject { described_class.new(@fixture_path) } it "should return all files" do - subject.all_files.should =~ Dir.glob("#{@fixture_path}/**/*", File::FNM_DOTMATCH).select { |file| file !~ /\.\.?$/ } + subject.all_files.should =~ Dir.glob("#{@fixture_path}/**/*", File::FNM_DOTMATCH).select { |file| File.file?(file) } end end