Class: FSEvent
- Inherits:
-
Object
- Object
- FSEvent
- Defined in:
- lib/vendor/darwin/lib/rb-fsevent/fsevent.rb,
lib/vendor/darwin/lib/rb-fsevent/version.rb
Constant Summary collapse
- VERSION =
"0.4.3.1"
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
15 16 17 |
# File 'lib/vendor/darwin/lib/rb-fsevent/fsevent.rb', line 15 def callback @callback end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
15 16 17 |
# File 'lib/vendor/darwin/lib/rb-fsevent/fsevent.rb', line 15 def paths @paths end |
Instance Method Details
#pipe ⇒ Object
56 57 58 |
# File 'lib/vendor/darwin/lib/rb-fsevent/fsevent.rb', line 56 def pipe @pipe ||= IO.popen("#{self.class.watcher_path} #{} #{shellescaped_paths}") end |
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vendor/darwin/lib/rb-fsevent/fsevent.rb', line 30 def run @running = true # please note the use of IO::select() here, as it is used specifically to # preserve correct signal handling behavior in ruby 1.8. while @running && IO::select([pipe], nil, nil, nil) if line = pipe.readline modified_dir_paths = line.split(":").select { |dir| dir != "\n" } callback.call(modified_dir_paths) end end rescue Interrupt, IOError ensure stop end |
#stop ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/vendor/darwin/lib/rb-fsevent/fsevent.rb', line 45 def stop if pipe Process.kill("KILL", pipe.pid) pipe.close end rescue IOError ensure @pipe = @running = nil end |
#watch(watch_paths, options = nil, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vendor/darwin/lib/rb-fsevent/fsevent.rb', line 17 def watch(watch_paths, =nil, &block) @paths = watch_paths.kind_of?(Array) ? watch_paths : [watch_paths] @callback = block if .kind_of?(Hash) @options = () elsif .kind_of?(Array) @options = else @options = [] end end |