diff --git a/lib/guard/listener.rb b/lib/guard/listener.rb index 8d14c1a..6fba4e7 100644 --- a/lib/guard/listener.rb +++ b/lib/guard/listener.rb @@ -26,6 +26,7 @@ module Guard def initialize(directory=Dir.pwd) @directory = directory.to_s @sha1_checksums_hash = {} + @relativate_paths = true update_last_event end @@ -64,11 +65,17 @@ module Guard # scopes all given paths to the current #directory def relativate_paths(paths) + return paths unless relativate_paths? paths.map do |path| path.gsub(%r~^#{directory}/~, '') end end + attr_writer :relativate_paths + def relativate_paths? + !!@relativate_paths + end + private diff --git a/spec/guard/listener_spec.rb b/spec/guard/listener_spec.rb index 90f5da2..a2cc1f7 100644 --- a/spec/guard/listener_spec.rb +++ b/spec/guard/listener_spec.rb @@ -38,10 +38,18 @@ describe Guard::Listener do end describe "#relativate_paths" do - subject { described_class.new } - it "should relavate paths to the configured directory" do - subject.stub!(:directory).and_return('/tmp') - subject.relativate_paths(%w( /tmp/a /tmp/a/b /tmp/a.b/c.d )).should =~ %w( a a/b a.b/c.d ) + subject { described_class.new('/tmp') } + before :each do + @paths = %w( /tmp/a /tmp/a/b /tmp/a.b/c.d ) + end + + it "should relativate paths to the configured directory" do + subject.relativate_paths(@paths).should =~ %w( a a/b a.b/c.d ) + end + + it "can be disabled" do + subject.relativate_paths = false + subject.relativate_paths(@paths).should == @paths end end