# File lib/vendor/darwin/lib/rb-fsevent/fsevent.rb, line 62 def options_string @options.join(' ') end
# File lib/vendor/darwin/lib/rb-fsevent/fsevent.rb, line 56 def pipe @pipe ||= IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}") end
# 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
for Ruby 1.8.6 support
# File lib/vendor/darwin/lib/rb-fsevent/fsevent.rb, line 71 def shellescape(str) # An empty argument will be skipped, so return empty quotes. return "''" if str.empty? str = str.dup # Process as a single byte sequence because not all shell # implementations are multibyte aware. str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1") # A LF cannot be escaped with a backslash because a backslash + LF # combo is regarded as line continuation and simply ignored. str.gsub!(/\n/, "'\n'") return str end
# File lib/vendor/darwin/lib/rb-fsevent/fsevent.rb, line 66 def shellescaped_paths @paths.map {|path| shellescape(path)}.join(' ') end
# 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
# File lib/vendor/darwin/lib/rb-fsevent/fsevent.rb, line 17 def watch(watch_paths, options=nil, &block) @paths = watch_paths.kind_of?(Array) ? watch_paths : [watch_paths] @callback = block if options.kind_of?(Hash) @options = parse_options(options) elsif options.kind_of?(Array) @options = options else @options = [] end end
Generated with the Darkfish Rdoc Generator 2.