can disable relativation of paths
This commit is contained in:
parent
2f0870abfc
commit
a3cf121111
@ -26,6 +26,7 @@ module Guard
|
|||||||
def initialize(directory=Dir.pwd)
|
def initialize(directory=Dir.pwd)
|
||||||
@directory = directory.to_s
|
@directory = directory.to_s
|
||||||
@sha1_checksums_hash = {}
|
@sha1_checksums_hash = {}
|
||||||
|
@relativate_paths = true
|
||||||
update_last_event
|
update_last_event
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -64,11 +65,17 @@ module Guard
|
|||||||
|
|
||||||
# scopes all given paths to the current #directory
|
# scopes all given paths to the current #directory
|
||||||
def relativate_paths(paths)
|
def relativate_paths(paths)
|
||||||
|
return paths unless relativate_paths?
|
||||||
paths.map do |path|
|
paths.map do |path|
|
||||||
path.gsub(%r~^#{directory}/~, '')
|
path.gsub(%r~^#{directory}/~, '')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr_writer :relativate_paths
|
||||||
|
def relativate_paths?
|
||||||
|
!!@relativate_paths
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -38,10 +38,18 @@ describe Guard::Listener do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#relativate_paths" do
|
describe "#relativate_paths" do
|
||||||
subject { described_class.new }
|
subject { described_class.new('/tmp') }
|
||||||
it "should relavate paths to the configured directory" do
|
before :each do
|
||||||
subject.stub!(:directory).and_return('/tmp')
|
@paths = %w( /tmp/a /tmp/a/b /tmp/a.b/c.d )
|
||||||
subject.relativate_paths(%w( /tmp/a /tmp/a/b /tmp/a.b/c.d )).should =~ %w( a a/b 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user