rb-fsevent 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,258 +0,0 @@
1
- {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/thibaudgg/rb-fsevent]
2
-
3
-
4
- = rb-fsevent
5
-
6
- Very simple & usable Mac OSX FSEvents API
7
-
8
- - RubyCocoa not required!
9
- - Signals are working (really)
10
- - Tested on MRI 1.8.7 & 1.9.2, JRuby 1.6.3
11
- - Tested on 10.6 & 10.7 (though 10.5 should work just as well)
12
- - Tested with XCode 3.2.6, 4.0.2, 4.1, 4.2b5
13
-
14
- == Install
15
-
16
- gem install rb-fsevent
17
-
18
- == Usage
19
-
20
- === Singular path
21
-
22
- require 'rb-fsevent'
23
-
24
- fsevent = FSEvent.new
25
- fsevent.watch Dir.pwd do |directories|
26
- puts "Detected change inside: #{directories.inspect}"
27
- end
28
- fsevent.run
29
-
30
- === Multiple paths
31
-
32
- require 'rb-fsevent'
33
-
34
- paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
35
-
36
- fsevent = FSEvent.new
37
- fsevent.watch paths do |directories|
38
- puts "Detected change inside: #{directories.inspect}"
39
- end
40
- fsevent.run
41
-
42
- === Multiple paths and additional options as a Hash
43
-
44
- require 'rb-fsevent'
45
-
46
- paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
47
- options = {:latency => 1.5, :no_defer => true }
48
-
49
- fsevent = FSEvent.new
50
- fsevent.watch paths, options do |directories|
51
- puts "Detected change inside: #{directories.inspect}"
52
- end
53
- fsevent.run
54
-
55
- === Multiple paths and additional options as an Array
56
-
57
- require 'rb-fsevent'
58
-
59
- paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
60
- options = ['--latency', 1.5, '--no-defer']
61
-
62
- fsevent = FSEvent.new
63
- fsevent.watch paths, options do |directories|
64
- puts "Detected change inside: #{directories.inspect}"
65
- end
66
- fsevent.run
67
-
68
- == Options
69
-
70
- When defining options using a hash or hash-like object, it gets checked for validity and converted to the appropriate fsevent_watch commandline arguments array when the FSEvent class is instantiated. This is obviously the safest and preferred method of passing in options.
71
-
72
- You may, however, choose to pass in an array of commandline arguments as your options value and it will be passed on, unmodified, to the fsevent_watch binary when called.
73
-
74
- So far, the following options are supported...
75
-
76
- - :latency => 0.5 # in seconds
77
- - :no_defer => true
78
- - :watch_root => true
79
- - :since_when => 18446744073709551615 # an FSEventStreamEventId
80
-
81
- === Latency
82
-
83
- The :latency parameter determines how long the service should wait after the first event before passing that information along to the client. If your latency is set to 4 seconds, and 300 changes occur in the first three, then the callback will be fired only once. If latency is set to 0.1 in the exact same scenario, you will see that callback fire somewhere closer to between 25 and 30 times.
84
-
85
- Setting a higher latency value allows for more effective temporal coalescing, resulting in fewer callbacks and greater overall efficiency... at the cost of apparent responsiveness. Setting this to a reasonably high value (and NOT setting :no_defer) is particularly well suited for background, daemon, or batch processing applications.
86
-
87
- Implementation note: It appears that FSEvents will only coalesce events from a maximum of 32 distinct subpaths, making the above completely accurate only when events are to fewer than 32 subpaths. Creating 300 files in one directory, for example, or 30 files in 10 subdirectories, but not 300 files within 300 subdirectories. In the latter case, you may receive 31 callbacks in one go after the latency period. As this appears to be an implementation detail, the number could potentially differ across OS revisions. It is entirely possible that this number is somehow configurable, but I have not yet discovered an accepted method of doing so.
88
-
89
- === NoDefer
90
-
91
- The :no_defer option changes the behavior of the latency parameter completely. Rather than waiting for $latency period of time before sending along events in an attempt to coalesce a potential deluge ahead of time, that first event is sent along to the client immediately and is followed by a $latency period of silence before sending along any additional events that occurred within that period.
92
-
93
- This behavior is particularly useful for interactive applications where that feeling of apparent responsiveness is most important, but you still don't want to get overwhelmed by a series of events that occur in rapid succession.
94
-
95
- === WatchRoot
96
-
97
- The :watch_root option allows for catching the scenario where you start watching "~/src/demo_project" and either it is later renamed to "~/src/awesome_sauce_3000" or the path changes in such a manner that the original directory is now at "~/clients/foo/iteration4/demo_project".
98
-
99
- Unfortunately, while this behavior is somewhat supported in the fsevent_watch binary built as part of this project, support for passing across detailed metadata is not (yet). As a result, you would not receive the appropriate RootChanged event and be able to react appropriately. Also, since the C code doesn't open watched directories and retain that file descriptor as part of path-specific callback metadata, we are unable to issue an F_GETPATH fcntl() to determine the directory's new path.
100
-
101
- Please do not use this option until proper support is added in an upcoming (planned) release.
102
-
103
- === SinceWhen
104
-
105
- The FSEventStreamEventId passed in to :since_when is used as a base for reacting to historic events. Unfortunately, not only is the metadata for transitioning from historic to live events not currently passed along, but it is incorrectly passed as a change event on the root path, and only per-host event streams are currently supported. When using per-host event streams, the event IDs are not guaranteed to be unique or contiguous when shared volumes (firewire/USB/net/etc) are used on multiple macs.
106
-
107
- Please do not use this option until proper support is added in an upcoming (planned) release, unless it's acceptable for you to receive that one fake event that's handled incorrectly when events transition from historical to live. Even in that scenario, there's no metadata available for determining the FSEventStreamEventId of the last received event.
108
-
109
- WARNING: passing in 0 as the parameter to :since_when will return events for every directory modified since "the beginning of time".
110
-
111
- == Debugging output
112
-
113
- If the gem is installed with the environment variable FWDEBUG set to the string "true", then fsevent_watch will be built with its various DEBUG sections defined, and the output to STDERR is truly verbose (and hopefully helpful in debugging your application and not just fsevent_watch itself). If enough people find this to be directly useful when developing code that makes use of rb-fsevent, then it wouldn't be hard to clean this up and make it a feature enabled by a commandline argument instead. Until somebody files an issue, however, I will assume otherwise.
114
-
115
- append_path called for: /tmp/moo/cow/
116
- resolved path to: /private/tmp/moo/cow
117
-
118
- config.sinceWhen 18446744073709551615
119
- config.latency 0.300000
120
- config.flags 00000000
121
- config.paths
122
- /private/tmp/moo/cow
123
-
124
- FSEventStreamRef @ 0x100108540:
125
- allocator = 0x7fff705a4ee0
126
- callback = 0x10000151e
127
- context = {0, 0x0, 0x0, 0x0, 0x0}
128
- numPathsToWatch = 1
129
- pathsToWatch = 0x7fff705a4ee0
130
- pathsToWatch[0] = '/private/tmp/moo/cow'
131
- latestEventId = -1
132
- latency = 300000 (microseconds)
133
- flags = 0x00000000
134
- runLoop = 0x0
135
- runLoopMode = 0x0
136
-
137
-
138
- FSEventStreamCallback fired!
139
- numEvents: 32
140
- event path: /private/tmp/moo/cow/1/a/
141
- event flags: 00000000
142
- event ID: 1023767
143
- event path: /private/tmp/moo/cow/1/b/
144
- event flags: 00000000
145
- event ID: 1023782
146
- event path: /private/tmp/moo/cow/1/c/
147
- event flags: 00000000
148
- event ID: 1023797
149
- event path: /private/tmp/moo/cow/1/d/
150
- event flags: 00000000
151
- event ID: 1023812
152
- event path: /private/tmp/moo/cow/1/e/
153
- event flags: 00000000
154
- event ID: 1023827
155
- event path: /private/tmp/moo/cow/1/f/
156
- event flags: 00000000
157
- event ID: 1023842
158
- event path: /private/tmp/moo/cow/1/g/
159
- event flags: 00000000
160
- event ID: 1023857
161
- event path: /private/tmp/moo/cow/1/h/
162
- event flags: 00000000
163
- event ID: 1023872
164
- event path: /private/tmp/moo/cow/1/i/
165
- event flags: 00000000
166
- event ID: 1023887
167
- event path: /private/tmp/moo/cow/1/j/
168
- event flags: 00000000
169
- event ID: 1023902
170
- event path: /private/tmp/moo/cow/1/k/
171
- event flags: 00000000
172
- event ID: 1023917
173
- event path: /private/tmp/moo/cow/1/l/
174
- event flags: 00000000
175
- event ID: 1023932
176
- event path: /private/tmp/moo/cow/1/m/
177
- event flags: 00000000
178
- event ID: 1023947
179
- event path: /private/tmp/moo/cow/1/n/
180
- event flags: 00000000
181
- event ID: 1023962
182
- event path: /private/tmp/moo/cow/1/o/
183
- event flags: 00000000
184
- event ID: 1023977
185
- event path: /private/tmp/moo/cow/1/p/
186
- event flags: 00000000
187
- event ID: 1023992
188
- event path: /private/tmp/moo/cow/1/q/
189
- event flags: 00000000
190
- event ID: 1024007
191
- event path: /private/tmp/moo/cow/1/r/
192
- event flags: 00000000
193
- event ID: 1024022
194
- event path: /private/tmp/moo/cow/1/s/
195
- event flags: 00000000
196
- event ID: 1024037
197
- event path: /private/tmp/moo/cow/1/t/
198
- event flags: 00000000
199
- event ID: 1024052
200
- event path: /private/tmp/moo/cow/1/u/
201
- event flags: 00000000
202
- event ID: 1024067
203
- event path: /private/tmp/moo/cow/1/v/
204
- event flags: 00000000
205
- event ID: 1024082
206
- event path: /private/tmp/moo/cow/1/w/
207
- event flags: 00000000
208
- event ID: 1024097
209
- event path: /private/tmp/moo/cow/1/x/
210
- event flags: 00000000
211
- event ID: 1024112
212
- event path: /private/tmp/moo/cow/1/y/
213
- event flags: 00000000
214
- event ID: 1024127
215
- event path: /private/tmp/moo/cow/1/z/
216
- event flags: 00000000
217
- event ID: 1024142
218
- event path: /private/tmp/moo/cow/1/
219
- event flags: 00000000
220
- event ID: 1024145
221
- event path: /private/tmp/moo/cow/2/a/
222
- event flags: 00000000
223
- event ID: 1024160
224
- event path: /private/tmp/moo/cow/2/b/
225
- event flags: 00000000
226
- event ID: 1024175
227
- event path: /private/tmp/moo/cow/2/c/
228
- event flags: 00000000
229
- event ID: 1024190
230
- event path: /private/tmp/moo/cow/2/d/
231
- event flags: 00000000
232
- event ID: 1024205
233
- event path: /private/tmp/moo/cow/2/e/
234
- event flags: 00000000
235
- event ID: 1024220
236
-
237
- == Note about FFI
238
-
239
- rb-fsevent doesn't use {ruby-ffi}[http://github.com/ffi/ffi] anymore because it sadly doesn't allow for catching Signals. You can still see the code in the {ffi branch}[http://github.com/thibaudgg/rb-fsevent/tree/ffi].
240
-
241
- == Development
242
-
243
- - Source hosted at {GitHub}[http://github.com/thibaudgg/rb-fsevent]
244
- - Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/thibaudgg/rb-fsevent/issues]
245
-
246
- Pull requests are quite welcome! Please ensure that your commits are in a topic branch for each individual changeset than can be reasonably isolated. It is also important to ensure that your changes are well tested... whether that means new tests, modified tests, or fixing a scenario where the existing tests currently fail. If you have rvm and the required rubies currently installed, we have a helper task for running the testsuite in all of them:
247
-
248
- rake spec:portability
249
-
250
- The list of tested RVM targets is currently:
251
-
252
- %w[1.8.6 1.8.7 1.9.2 jruby-head]
253
-
254
- == Authors
255
-
256
- - {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg]
257
- - {Travis Tilley}[http://github.com/ttilley]
258
-