Class: Sinatra::Reloader::Watcher::List
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/reloader.rb
Overview
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 of the elements defined in the file being watched and if its changes should be ignored.
Class Method Summary collapse
-
.for(app) ⇒ Object
Returns the
List
for the applicationapp
.
Instance Method Summary collapse
-
#ignore(path) ⇒ Object
Tells the
Watcher
for the file located atpath
to ignore the file changes, and adds theWatcher
to theList
, if it isn’t already there. -
#initialize ⇒ List
constructor
Creates a new
List
instance. -
#updated ⇒ Object
Returns an array with all the watchers in the
List
that have been updated. -
#watch(path, element) ⇒ Object
Lets the
Watcher
for the file located atpath
know that theelement
is defined there, and adds theWatcher
to theList
, if it isn’t already there. -
#watcher_for(path) ⇒ Object
(also: #watch_file)
Adds a
Watcher
for the file located atpath
to theList
, if it isn’t already there. -
#watchers ⇒ Object
Returns an array with all the watchers in the
List
.
Constructor Details
Class Method Details
.for(app) ⇒ Object
Returns the List
for the application app
.
128 129 130 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/reloader.rb', line 128 def self.for(app) @app_list_map[app] end |
Instance Method Details
#ignore(path) ⇒ Object
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.
149 150 151 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/reloader.rb', line 149 def ignore(path) watcher_for(path).ignore end |
#updated ⇒ Object
Returns an array with all the watchers in the List
that have been updated.
167 168 169 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/reloader.rb', line 167 def updated watchers.find_all(&:updated?) end |
#watch(path, element) ⇒ Object
Lets the Watcher
for the file located at path
know that the element
is defined there, and adds the Watcher
to the List
, if it isn’t already there.
142 143 144 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/reloader.rb', line 142 def watch(path, element) watcher_for(path).elements << element end |
#watcher_for(path) ⇒ Object Also known as: watch_file
Adds a Watcher
for the file located at path
to the List
, if it isn’t already there.
155 156 157 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/reloader.rb', line 155 def watcher_for(path) @path_watcher_map[File.(path)] end |
#watchers ⇒ Object
Returns an array with all the watchers in the List
.
161 162 163 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/reloader.rb', line 161 def watchers @path_watcher_map.values end |