Initializes the directories listener.
@param [String] directory the directories to listen to @param [Hash] options the listen options (see Listen::Listener::Options)
@yield [modified, added, removed] the changed files @yieldparam [Array<String>] modified the list of modified files @yieldparam [Array<String>] added the list of added files @yieldparam [Array<String>] removed the list of removed files
# File lib/listen/listener.rb, line 23 def initialize(*args, &block) @options = _init_options(args.last.is_a?(Hash) ? args.pop : {}) @directories = args.flatten.map { |path| Pathname.new(path).realpath } @changes = [] @block = block @registry = Celluloid::Registry.new _init_debug end
Adds ignore patterns to the existing one
@see DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in
Listen::Silencer)
@param [Regexp, Array<Regexp>] new ignoring patterns.
# File lib/listen/listener.rb, line 87 def ignore(regexps) @options[:ignore] = [options[:ignore], regexps] registry[:silencer] = Silencer.new(self) end
Overwrites ignore patterns
@see DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in
Listen::Silencer)
@param [Regexp, Array<Regexp>] new ignoring patterns.
# File lib/listen/listener.rb, line 99 def ignore!(regexps) @options.delete(:ignore) @options[:ignore!] = regexps registry[:silencer] = Silencer.new(self) end
Returns true if Listener is neither paused nor stopped
@return [Boolean]
# File lib/listen/listener.rb, line 76 def listen? @paused == false && @stopping == false end
Sets only patterns, to listen only to specific regexps
@param [Regexp, Array<Regexp>] new ignoring patterns.
# File lib/listen/listener.rb, line 109 def only(regexps) @options[:only] = regexps registry[:silencer] = Silencer.new(self) end
Pauses listening callback (adapter still running)
# File lib/listen/listener.rb, line 53 def pause @paused = true end
Returns true if Listener is paused
@return [Boolean]
# File lib/listen/listener.rb, line 68 def paused? @paused == true end
Starts the listener by initializing the adapter and building the directory record concurrently, then it starts the adapter to watch for changes. The current thread is not blocked after starting.
# File lib/listen/listener.rb, line 36 def start _init_actors unpause @stopping = false registry[:adapter].async.start Thread.new { _wait_for_changes } end
Terminates all Listen actors and kill the adapter.
# File lib/listen/listener.rb, line 46 def stop @stopping = true supervisor.terminate end
Generated with the Darkfish Rdoc Generator 2.