fsevents 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,8 @@
1
+ == 0.0.2 2008-06-17
2
+
3
+ * 1 tiny enhancement:
4
+ * Extending the events array with #files and #modified_files.
5
+
1
6
  == 0.0.1 2008-06-15
2
7
 
3
8
  * 1 major enhancement:
@@ -7,12 +7,15 @@ config/hoe.rb
7
7
  config/requirements.rb
8
8
  lib/fsevents.rb
9
9
  lib/fsevents/event.rb
10
+ lib/fsevents/ext.rb
11
+ lib/fsevents/ext/array.rb
10
12
  lib/fsevents/stream.rb
11
13
  lib/fsevents/version.rb
12
14
  script/console
13
15
  script/destroy
14
16
  script/generate
15
17
  setup.rb
18
+ spec/event_array_spec.rb
16
19
  spec/event_spec.rb
17
20
  spec/fsevents_spec.rb
18
21
  spec/spec.opts
data/README.txt CHANGED
@@ -39,9 +39,18 @@
39
39
  end
40
40
  stream.run
41
41
 
42
- Try that and make some new files in /tmp. Exciting, isn't it?
43
-
44
- FSEvents::Stream.watch takes some options, most of which I fully admit I don't understand because I have little desire to read the documentation on FSEvents itself. One obvious option is latency, which the number of seconds to wait until an event is reported. A higher number allows FSEvents to bundle events.
42
+ Try that and make some new files in /tmp. Exciting, isn't it?
43
+
44
+ And for the common case of wanting to process every modified file no matter which subdirectory it happens to be under, the events array is extended for your convenience.
45
+
46
+ require 'fsevents'
47
+
48
+ stream = FSEvents::Stream.watch('/tmp') do |events|
49
+ p events.modified_files
50
+ end
51
+ stream.run
52
+
53
+ FSEvents::Stream.watch takes some options, most of which I fully admit I don't understand because I have little desire to read the documentation on FSEvents itself. One obvious option is latency, which the number of seconds to wait until an event is reported. A higher number allows FSEvents to bundle events.
45
54
 
46
55
  stream = FSEvents::Stream.watch('/tmp', :latency => 15) {} # default is 1.0
47
56
 
@@ -72,7 +81,7 @@
72
81
 
73
82
  stream.stop
74
83
 
75
- A stream can also be invalidated and release it.
84
+ A stream can also be invalidated and released.
76
85
 
77
86
  stream.invalidate
78
87
 
@@ -80,7 +89,6 @@
80
89
 
81
90
  stream.shutdown # stops, invalidates, and releases the stream
82
91
 
83
-
84
92
  From what I can tell, entering the run loop requires an interrupt to get back out. Bear that in mind.
85
93
 
86
94
  == REQUIREMENTS:
@@ -4,6 +4,7 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'osx/foundation'
5
5
  OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
6
6
 
7
+ require 'fsevents/ext'
7
8
  require 'fsevents/stream'
8
9
 
9
10
  module FSEvents
@@ -0,0 +1 @@
1
+ require 'fsevents/ext/array'
@@ -0,0 +1,9 @@
1
+ module EventArray
2
+ def files
3
+ collect { |x| x.files }.flatten
4
+ end
5
+
6
+ def modified_files
7
+ collect { |x| x.modified_files }.flatten
8
+ end
9
+ end
@@ -34,6 +34,7 @@ module FSEvents
34
34
  paths.regard_as('*')
35
35
 
36
36
  events = []
37
+ events.extend(EventArray)
37
38
  event_count.times { |i| events << Event.new(event_IDs[i], paths[i], self) }
38
39
 
39
40
  callback.call(events)
@@ -2,7 +2,7 @@ module Fsevents #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe EventArray do
4
+ before :each do
5
+ @event_array = []
6
+ @event_array.extend(EventArray)
7
+ end
8
+
9
+ it 'should return files' do
10
+ @event_array.should respond_to(:files)
11
+ end
12
+
13
+ describe 'returning files' do
14
+ it 'should collect files from its events' do
15
+ events = Array.new(3) { stub('event', :files => Array.new(3) { stub('file') }) }
16
+ files = []
17
+ events.each do |event|
18
+ @event_array << event
19
+ files += event.files
20
+ end
21
+
22
+ @event_array.files.should == files
23
+ end
24
+ end
25
+
26
+ it 'should return modified files' do
27
+ @event_array.should respond_to(:modified_files)
28
+ end
29
+
30
+ describe 'returning modified files' do
31
+ it 'should collect modified files from its events' do
32
+ events = Array.new(3) { stub('event', :modified_files => Array.new(3) { stub('file') }) }
33
+ files = []
34
+ events.each do |event|
35
+ @event_array << event
36
+ files += event.modified_files
37
+ end
38
+
39
+ @event_array.modified_files.should == files
40
+ end
41
+ end
42
+ end
@@ -270,6 +270,12 @@ describe FSEvents::Stream do
270
270
  @proc.call(*@args)
271
271
  end
272
272
 
273
+ it 'should extend the event array' do
274
+ @args = @args_hash.values_at(*@callback_arg_order)
275
+ @callback.expects(:call).with { |events| events.is_a?(EventArray) }
276
+ @proc.call(*@args)
277
+ end
278
+
273
279
  it "should update the stream's last event" do
274
280
  @stream.expects(:update_last_event)
275
281
  @proc.call(*@args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fsevents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yossef Mendelssohn
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-15 00:00:00 -05:00
12
+ date: 2008-06-17 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -35,12 +35,15 @@ files:
35
35
  - config/requirements.rb
36
36
  - lib/fsevents.rb
37
37
  - lib/fsevents/event.rb
38
+ - lib/fsevents/ext.rb
39
+ - lib/fsevents/ext/array.rb
38
40
  - lib/fsevents/stream.rb
39
41
  - lib/fsevents/version.rb
40
42
  - script/console
41
43
  - script/destroy
42
44
  - script/generate
43
45
  - setup.rb
46
+ - spec/event_array_spec.rb
44
47
  - spec/event_spec.rb
45
48
  - spec/fsevents_spec.rb
46
49
  - spec/spec.opts