Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

README hacks

  • Loading branch information...
commit 2e01e9e9c546b9543db73631aba9b55b9e1fc580 1 parent 45bb168
Sandro Turriate sandro authored

Showing 1 changed file with 36 additions and 16 deletions. Show diff stats Hide diff stats

  1. +36 16 README.markdown
52 README.markdown
Source Rendered
@@ -6,11 +6,44 @@ A native extension exposing the OS X FSEvent API.
6 6 Register the directories you want to watch, create a custom callback, and your
7 7 callback will fire everytime a change occurs in the registered directories.
8 8
9   -I'm tired of recompiling RubyCocoa just get Rspactor working whenever I switch Ruby versions. Hopefully, this gem will break that dependency.
  9 +Example
  10 +-------
  11 + class PrintChange < FSEvent
  12 + def on_change(directories)
  13 + puts "Detected change in: #{directories.inspect}"
  14 + end
  15 + end
  16 +
  17 + printer = PrintChange.new
  18 + printer.watch_directories %W(#{Dir.pwd} /tmp)
  19 + printer.start
  20 +
  21 +
  22 +Examine ruby-fsevent/examples
  23 +-----------------------------
  24 +1. rake make
  25 +2. ruby examples/print_changes.rb
  26 +3. Notice that the examples directory and the /tmp directory are being
  27 + monitored
  28 +4. Make a change to either directory and watch the callback fire
  29 +
  30 +TODO
  31 +----
  32 +* Documentation
  33 +* Add ability to register a block as a callback handler, on_change would then
  34 + call the block. This removes the need for subclassing.
  35 +* Expose an optional ruby library to show file changes, not just directory
  36 + changes
  37 +* Do more in Ruby, less in C
  38 +
  39 +Reasoning
  40 +---------
  41 +I'm tired of recompiling RubyCocoa just get Rspactor working whenever I switch
  42 +Ruby versions. Hopefully, this gem will break that dependency.
10 43
11 44 Watchr and Kicker have recently grabbed my attention. They allow you to watch
12   -directories for changes and create custom event handlers. Unfortunately, Watchr
13   -has a 4-5 second delay when using it with Rev (recommended) before your
  45 +directories for changes and create custom event handlers. Unfortunately,
  46 +Watchr has a 4-5 second delay when using it with Rev (recommended) before your
14 47 callback is fires. Without Rev, Watchr degrades to a 0.5 second Ruby loop
15 48 which we all know is not resource-friendly. Now, Watchr could easily add native
16 49 FSEvents as a new backend for Mac users.
@@ -22,19 +55,6 @@ and remove the need for RubyCocoa.
22 55 With a generic, native interface to the FSEvent API we, as Rubyists can harness
23 56 the power of OSX FSEvents without depending on RubyCocoa.
24 57
25   -Demo
26   -----
27   -
28   -1. rake make
29   -2. ruby examples/print_changes.rb
30   -3. Notice that the examples directory and the /tmp directory are being monitored
31   -4. Make a change to either directory and watch the callback fire
32   -
33   -TODO
34   -----
35   -
36   -* Add ability to register a block as a callback handler, on_change would then
37   -call the block. This removes the need for subclassing.
38 58
39 59 Note on Patches/Pull Requests
40 60 -----------------------------

0 comments on commit 2e01e9e

Please sign in to comment.
Something went wrong with that request. Please try again.