Class: Sinatra::Reloader::Watcher
- Inherits:
-
Object
- Object
- Sinatra::Reloader::Watcher
- Defined in:
- lib/sinatra/reloader.rb
Overview
Watches a file so it can tell when it has been updated. It also knows the routes defined and if it contains inline templates.
Defined Under Namespace
Classes: List
Instance Attribute Summary (collapse)
-
- (Object) mtime
readonly
Returns the value of attribute mtime.
-
- (Object) path
readonly
Returns the value of attribute path.
-
- (Object) routes
readonly
Returns the value of attribute routes.
Instance Method Summary (collapse)
-
- (Object) ignore
Informs that the modifications to the file being watched should be ignored.
-
- (Boolean) ignore?
Indicates whether or not the modifications to the file being watched should be ignored.
-
- (Watcher) initialize(path)
constructor
Creates a new Watcher instance for the file located at path.
-
- (Object) inline_templates
Informs that the file being watched has inline templates.
-
- (Boolean) inline_templates?
Indicates whether or not the file being watched has inline templates.
-
- (Boolean) removed?
Indicates whether or not the file being watched has been removed.
-
- (Object) update
Updates the file being watched mtime.
-
- (Boolean) updated?
Indicates whether or not the file being watched has been modified.
Constructor Details
- (Watcher) initialize(path)
Creates a new Watcher instance for the file located at path.
97 98 99 100 |
# File 'lib/sinatra/reloader.rb', line 97 def initialize(path) @path, @routes = path, [] update end |
Instance Attribute Details
- (Object) mtime (readonly)
Returns the value of attribute mtime
93 94 95 |
# File 'lib/sinatra/reloader.rb', line 93 def mtime @mtime end |
- (Object) path (readonly)
Returns the value of attribute path
93 94 95 |
# File 'lib/sinatra/reloader.rb', line 93 def path @path end |
- (Object) routes (readonly)
Returns the value of attribute routes
93 94 95 |
# File 'lib/sinatra/reloader.rb', line 93 def routes @routes end |
Instance Method Details
- (Object) ignore
Informs that the modifications to the file being watched should be ignored.
126 127 128 |
# File 'lib/sinatra/reloader.rb', line 126 def ignore @ignore = true end |
- (Boolean) ignore?
Indicates whether or not the modifications to the file being watched should be ignored.
132 133 134 |
# File 'lib/sinatra/reloader.rb', line 132 def ignore? !!@ignore end |
- (Object) inline_templates
Informs that the file being watched has inline templates.
114 115 116 |
# File 'lib/sinatra/reloader.rb', line 114 def inline_templates @inline_templates = true end |
- (Boolean) inline_templates?
Indicates whether or not the file being watched has inline templates.
120 121 122 |
# File 'lib/sinatra/reloader.rb', line 120 def inline_templates? !!@inline_templates end |
- (Boolean) removed?
Indicates whether or not the file being watched has been removed.
138 139 140 |
# File 'lib/sinatra/reloader.rb', line 138 def removed? !File.exist?(path) end |
- (Object) update
Updates the file being watched mtime.
109 110 111 |
# File 'lib/sinatra/reloader.rb', line 109 def update @mtime = File.mtime(path) end |
- (Boolean) updated?
Indicates whether or not the file being watched has been modified.
104 105 106 |
# File 'lib/sinatra/reloader.rb', line 104 def updated? !ignore? && !removed? && mtime != File.mtime(path) end |