Skip to content

Commit

Permalink
Stripping trailing slash from paths.
Browse files Browse the repository at this point in the history
This was originally just a minor visual annoyance, but it became something that messed up the caching.
  • Loading branch information
ymendel committed Jun 30, 2008
1 parent 5da4969 commit 6d6e3d9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fsevents/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Event

def initialize(id, path, stream)
@id = id
@path = path
@path = path.sub(%r%/$%, '')
@stream = stream
end

Expand Down
3 changes: 2 additions & 1 deletion lib/fsevents/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def initialize(*paths, &callback)
@dirs = {}

paths = Dir.pwd if paths.empty?
paths = [paths].flatten.collect { |path| path.sub(%r%/$%, '') }

@allocator = options[:allocator] || OSX::KCFAllocatorDefault
@context = options[:context] || nil
@paths = [paths].flatten
@paths = paths
@since = options[:since] || OSX::KFSEventStreamEventIdSinceNow
@latency = options[:latency] || 1.0
@flags = options[:flags] || 0
Expand Down
4 changes: 4 additions & 0 deletions spec/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
FSEvents::Event.new(@id, @path, @stream).path.should == @path
end

it 'should strip a trailing / from the path' do
FSEvents::Event.new(@id, "#{@path}/", @stream).path.should == @path
end

it 'should store the stream' do
FSEvents::Event.new(@id, @path, @stream).stream.should == @stream
end
Expand Down
4 changes: 4 additions & 0 deletions spec/stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
FSEvents::Stream.new(@options) {}.paths.should == [Dir.pwd]
end

it 'should strip a trailing slash from the path' do
FSEvents::Stream.new("#{@path}/", "#{@other_path}/", @options) {}.paths.should == [@path, @other_path]
end

it "should store 'since' (event ID)" do
FSEvents::Stream.new(@path, @options) {}.since.should == @options[:since]
end
Expand Down

0 comments on commit 6d6e3d9

Please sign in to comment.