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 _init_debug end
Adds ignore patterns to the existing one (See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer)
@param [Regexp, Hash<Regexp>] new ignoring patterns.
# File lib/listen/listener.rb, line 86 def ignore(regexps) options[:ignore] = [options[:ignore], regexps] Celluloid::Actor[:listen_silencer] = Silencer.new(options) end
Overwrites ignore patterns (See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer)
@param [Regexp, Hash<Regexp>] new ignoring patterns.
# File lib/listen/listener.rb, line 95 def ignore!(regexps) options.delete(:ignore) options[:ignore!] = regexps Celluloid::Actor[:listen_silencer] = Silencer.new(options) end
Returns true if Listener is not paused
@return [Boolean]
# File lib/listen/listener.rb, line 78 def listen? @paused == false end
Pauses listening callback (adapter still running)
# File lib/listen/listener.rb, line 55 def pause @paused = true end
Returns true if Listener is paused
@return [Boolean]
# File lib/listen/listener.rb, line 70 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 35 def start _signals_trap _init_actors unpause Celluloid::Actor[:listen_adapter].async.start @thread = Thread.new { _wait_for_changes } end
Terminates all Listen actors and kill the adapter.
# File lib/listen/listener.rb, line 45 def stop thread.kill Celluloid::Actor.kill(Celluloid::Actor[:listen_adapter]) Celluloid::Actor[:listen_silencer].terminate Celluloid::Actor[:listen_change_pool].terminate Celluloid::Actor[:listen_record].terminate end
Generated with the Darkfish Rdoc Generator 2.