Collection of file Watcher that can be associated with a Sinatra application. That way, we can
know which files belong to a given application and which files have been
modified. It also provides a mechanism to inform a Watcher the elements defined in the file being
watched and if it changes should be ignored.
Returns the List for the application app.
# File lib/sinatra/reloader.rb, line 105 def self.for(app) @app_list_map[app] end
Creates a new List instance.
# File lib/sinatra/reloader.rb, line 110 def initialize @path_watcher_map = Hash.new do |hash, key| hash[key] = Watcher.new(key) end end
Tells the Watcher for the file located at path to
ignore the file changes, and adds the Watcher to the
List, if it isn't already there.
# File lib/sinatra/reloader.rb, line 126 def ignore(path) watcher_for(path).ignore end
Returns an array with all the watchers in the List that have
been updated.
# File lib/sinatra/reloader.rb, line 144 def updated watchers.find_all(&:updated?) end
Lets the Watcher for the file localted at path
know that the element is defined there, and adds the
Watcher to the List, if it isn't already there.
# File lib/sinatra/reloader.rb, line 119 def watch(path, element) watcher_for(path).elements << element end
Adds a Watcher for the file located at path to
the List, if it isn't already there.
# File lib/sinatra/reloader.rb, line 132 def watcher_for(path) @path_watcher_map[File.expand_path(path)] end
Returns an array with all the watchers in the List.
# File lib/sinatra/reloader.rb, line 138 def watchers @path_watcher_map.values end