Watches a file so it can tell when it has been updated, and what elements does it contain.
Creates a new Watcher
instance for the file located at
path
.
# File lib/sinatra/reloader.rb, line 166 def initialize(path) @ignore = nil @path, @elements = path, [] update end
Informs that the modifications to the file being watched should be ignored.
# File lib/sinatra/reloader.rb, line 190 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 196 def ignore? !!@ignore end
Indicates whether or not the file being watched has inline templates.
# File lib/sinatra/reloader.rb, line 184 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 201 def removed? !File.exist?(path) end
Updates the mtime of the file being watched.
# File lib/sinatra/reloader.rb, line 178 def update @mtime = File.mtime(path) end
Indicates whether or not the file being watched has been modified.
# File lib/sinatra/reloader.rb, line 173 def updated? !ignore? && !removed? && mtime != File.mtime(path) end