-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating FSEvents::Event class, mostly to make getting files from the…
… path easier. This is heavily inspired by the Rucola fsevents.rb.
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module FSEvents | ||
class Event | ||
attr_reader :id, :path, :stream | ||
|
||
def initialize(id, path, stream) | ||
@id = id | ||
@path = path | ||
@stream = stream | ||
end | ||
|
||
def files | ||
Dir["#{path}/*"] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'fsevents/event' | ||
|
||
module FSEvents | ||
class Stream | ||
attr_reader :stream | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require File.dirname(__FILE__) + '/spec_helper.rb' | ||
|
||
describe FSEvents::Event do | ||
before :each do | ||
@id = stub('id') | ||
@path = '.' | ||
@stream = stub('stream') | ||
|
||
@event = FSEvents::Event.new(@id, @path, @stream) | ||
end | ||
|
||
describe 'when initialized' do | ||
it 'should accept an id, path, and stream' do | ||
lambda { FSEvents::Event.new(@id, @path, @stream) }.should_not raise_error(ArgumentError) | ||
end | ||
|
||
it 'should require a stream' do | ||
lambda { FSEvents::Event.new(@id, @path) }.should raise_error(ArgumentError) | ||
end | ||
|
||
it 'should require a path' do | ||
lambda { FSEvents::Event.new(@id) }.should raise_error(ArgumentError) | ||
end | ||
|
||
it 'should require an id' do | ||
lambda { FSEvents::Event.new }.should raise_error(ArgumentError) | ||
end | ||
|
||
it 'should store the id' do | ||
FSEvents::Event.new(@id, @path, @stream).id.should == @id | ||
end | ||
|
||
it 'should store 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 | ||
end | ||
|
||
it 'should list files' do | ||
@event.should respond_to(:files) | ||
end | ||
|
||
describe 'listing files' do | ||
it 'should get files from the path' do | ||
@event.files.sort.should == Dir["#{@path}/*"].sort | ||
end | ||
end | ||
end |