Class: Middleman::CoreExtensions::FileWatcher
- Defined in:
- middleman-core/lib/middleman-core/core_extensions/file_watcher.rb
Overview
API for watching file change events
Constant Summary collapse
- IGNORES =
The default list of ignores.
{ emacs_files: %r{(^|/)\.?#}, tilde_files: /~$/, ds_store: /\.DS_Store$/, git: %r{(^|/)\.git(ignore|modules|/)} }.freeze
Constants included from Contracts
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Attributes inherited from Extension
Instance Method Summary collapse
- #after_configuration ⇒ Object
-
#Any
After we config, find new files since config can change paths.
- #before_configuration ⇒ Object
-
#initialize(app, options_hash = ::Middleman::EMPTY_HASH, &block) ⇒ FileWatcher
constructor
Setup the extension.
Methods inherited from Extension
activated_extension, #add_exposed_to_context, #after_build, after_extension_activated, #after_extension_activated, #before_build, clear_after_extension_callbacks, config, define_setting, expose_to_application, expose_to_config, expose_to_template, global_config, helpers, #manipulate_resource_list, option, #ready, resources
Methods included from Contracts
Constructor Details
#initialize(app, options_hash = ::Middleman::EMPTY_HASH, &block) ⇒ FileWatcher
Setup the extension.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'middleman-core/lib/middleman-core/core_extensions/file_watcher.rb', line 29 def initialize(app, = ::Middleman::EMPTY_HASH, &block) super # Setup source collection. @sources = ::Middleman::Sources.new(app) # Add default ignores. IGNORES.each do |key, value| @sources.ignore key, :all, value end # Watch current source. start_watching(app.config[:source]) end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
12 13 14 |
# File 'middleman-core/lib/middleman-core/core_extensions/file_watcher.rb', line 12 def sources @sources end |
Instance Method Details
#after_configuration ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'middleman-core/lib/middleman-core/core_extensions/file_watcher.rb', line 56 def after_configuration @watcher.update_config( disable_watcher: app.config[:watcher_disable], force_polling: app.config[:watcher_force_polling], latency: app.config[:watcher_latency], wait_for_delay: app.config[:watcher_wait_for_delay] ) @watcher.update_path(app.config[:source]) if @original_source_dir != app.config[:source] @sources.start! @sources.poll_once! end |
#Any
This method returns an undefined value.
After we config, find new files since config can change paths.
47 |
# File 'middleman-core/lib/middleman-core/core_extensions/file_watcher.rb', line 47 Contract Any |
#before_configuration ⇒ Object
48 49 50 |
# File 'middleman-core/lib/middleman-core/core_extensions/file_watcher.rb', line 48 def before_configuration @sources.poll_once! end |