Class: EventMachine::FileWatch

### Home Classes Methods

### In Files

- lib/em/file_watch.rb

### Parent

EventMachine::Connection

### Methods

- #file_deleted
- #file_modified
- #file_moved
- #path
- #receive_data
- #stop_watching

### Files

- ChangeLog
- DEFERRABLES
- EPOLL
- INSTALL
- KEYBOARD
- LEGAL
- LIGHTWEIGHT_CONCURRENCY
- PURE_RUBY
- RELEASE_NOTES
- SMTP
- SPAWNED_PROCESSES
- TODO

### Class/Module Index

Quicksearch

- EventMachine
- EventMachine
- EventMachine::Channel
- EventMachine::Completion
- EventMachine::Connection
- EventMachine::DNS
- EventMachine::DNS::Request
- EventMachine::DNS::RequestIdAlreadyUsed
- EventMachine::DNS::Resolver
- EventMachine::DNS::Socket
- EventMachine::DatagramObject
- EventMachine::DefaultDeferrable
- EventMachine::Deferrable
- EventMachine::DeferrableChildProcess
- EventMachine::Error
- EventMachine::EvmaKeyboard
- EventMachine::EvmaTCPClient
- EventMachine::EvmaTCPServer
- EventMachine::EvmaUDPSocket
- EventMachine::EvmaUNIXClient
- EventMachine::EvmaUNIXServer
- EventMachine::FileNotFoundException
- EventMachine::FileStreamer
- EventMachine::FileWatch
- EventMachine::Iterator
- EventMachine::LoopbreakReader
- EventMachine::PeriodicTimer
- EventMachine::Pool
- EventMachine::ProcessWatch
- EventMachine::Protocols
- EventMachine::Protocols
- EventMachine::Protocols::HeaderAndContentProtocol
- EventMachine::Protocols::HttpClient
- EventMachine::Protocols::HttpClient2
- EventMachine::Protocols::HttpClient2::Request
- EventMachine::Protocols::LineAndTextProtocol
- EventMachine::Protocols::LineProtocol
- EventMachine::Protocols::LineText2
- EventMachine::Protocols::Memcache
- EventMachine::Protocols::Memcache::ParserError
- EventMachine::Protocols::ObjectProtocol
- EventMachine::Protocols::Postgres3
- EventMachine::Protocols::SASLauth
- EventMachine::Protocols::SASLauthclient
- EventMachine::Protocols::SmtpClient
- EventMachine::Protocols::SmtpServer
- EventMachine::Protocols::Socks4
- EventMachine::Protocols::Stomp
- EventMachine::Protocols::Stomp::Message
- EventMachine::Protocols::TcpConnectTester
- EventMachine::Queue
- EventMachine::Reactor
- EventMachine::Selectable
- EventMachine::SpawnedProcess
- EventMachine::StreamObject
- EventMachine::SystemCmd
- EventMachine::ThreadedResource
- EventMachine::TickLoop
- EventMachine::Timer
- EventMachine::UuidGenerator
- EventMachine::YieldBlockFromSpawnedProcess
- Object
- Object::EM
- Object::P
- BufferedTokenizer
- IO
- StringIO
- TestConnection

No matching classes.

# EventMachine::FileWatch

Utility class that is useful for file monitoring. Supported events are

- File is modified

- File is deleted

- File is moved

@note On Mac OS X, file watching only works when kqueue is enabled

@see EventMachine.watch_file

### Constants

Cdeleted

  @private

Cmodified

  @private

Cmoved

  @private

### Public Instance Methods

file_deleted() click to toggle source

Will be called when the file is deleted. Supposed to be redefined by subclasses. When the file is deleted, stop_watching will be called after this to make sure everything is cleaned up correctly.

@note On Linux (with {en.wikipedia.org/wiki/Inotify inotify}), this method will not be called until all open file descriptors to

    the file have been closed.

@abstract

    # File lib/em/file_watch.rb, line 56
    def file_deleted
    end

file_modified() click to toggle source

Will be called when the file is modified. Supposed to be redefined by subclasses.

@abstract

    # File lib/em/file_watch.rb, line 45
    def file_modified
    end

file_moved() click to toggle source

Will be called when the file is moved or renamed. Supposed to be redefined by subclasses.

@abstract

    # File lib/em/file_watch.rb, line 62
    def file_moved
    end

path() click to toggle source

Returns the path that is being monitored.

@note Current implementation does not pick up on the new filename after a rename occurs.

@return [String] @see EventMachine.watch_file

    # File lib/em/file_watch.rb, line 38
    def path
      @path
    end

receive_data(data) click to toggle source

@private

    # File lib/em/file_watch.rb, line 21
    def receive_data(data)
      case data
      when Cmodified
        file_modified
      when Cdeleted
        file_deleted
      when Cmoved
        file_moved
      end
    end

stop_watching() click to toggle source

Discontinue monitoring of the file.

This involves cleaning up the underlying monitoring details with kqueue/inotify, and in turn firing {EventMachine::Connection#unbind}. This will be called automatically when a file is deleted. User code may call it as well.

    # File lib/em/file_watch.rb, line 69
    def stop_watching
      EventMachine::unwatch_filename(@signature)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.