Watches a file so it can tell when it has been updated, and what elements contains.
Creates a new Watcher
instance for the file located at
path
.
# File lib/sinatra/reloader.rb, line 152 def initialize(path) @path, @elements = path, [] update end
Informs that the modifications to the file being watched should be ignored.
# File lib/sinatra/reloader.rb, line 175 def ignore @ignore = true end
Indicates whether or not the modifications to the file being watched should be ignored.
# File lib/sinatra/reloader.rb, line 181 def ignore? !!@ignore end
Indicates whether or not the file being watched has inline templates.
# File lib/sinatra/reloader.rb, line 169 def inline_templates? elements.any? { |element| element.type == :inline_templates } end
Indicates whether or not the file being watched has been removed.
# File lib/sinatra/reloader.rb, line 186 def removed? !File.exist?(path) end
Updates the file being watched mtime.
# File lib/sinatra/reloader.rb, line 163 def update @mtime = File.mtime(path) end
Indicates whether or not the file being watched has been modified.
# File lib/sinatra/reloader.rb, line 158 def updated? !ignore? && !removed? && mtime != File.mtime(path) end