aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2015-12-13 18:37:24 +0100
committerXavier Noria <fxn@hashref.com>2015-12-13 18:47:42 +0100
commit722359625903a1432e1f6197885ae5862608cba5 (patch)
tree400093b27d94d34a5bdbbf9fe01f74d8ac281ddd
parent6be27016dff19fc7509d3668aba375fd332d6822 (diff)
downloadrails-722359625903a1432e1f6197885ae5862608cba5.tar.gz
rails-722359625903a1432e1f6197885ae5862608cba5.tar.bz2
rails-722359625903a1432e1f6197885ae5862608cba5.zip
let config.file_watcher be the way to enable the evented file watcher
Before this commit, the sole presence of the Listen constant enabled the evented file watcher (unless listen resorted to the polling backend). This way, applications may depend on listen for other stuff independently of this feature. Also, allows teams with mixed setups to decide at boot time whether the evented watcher should be enabled for each particular instance.
-rw-r--r--activesupport/CHANGELOG.md13
-rw-r--r--guides/source/configuring.md2
-rw-r--r--railties/CHANGELOG.md10
-rw-r--r--railties/lib/rails/application/configuration.rb29
-rw-r--r--railties/lib/rails/generators/rails/app/templates/Gemfile4
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt4
6 files changed, 31 insertions, 31 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index d946fc1bbd..88558cde1c 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -7,13 +7,18 @@
*Michael Grosser*
-* Implements an evented file system monitor to asynchronously detect changes
- in the application source code, routes, locales, etc.
+* Implements an evented file watcher to asynchronously detect changes in the
+ application source code, routes, locales, etc.
- To opt-in load the [listen](https://github.com/guard/listen) gem in `Gemfile`:
+ This watcher is disabled by default, applications my enable it in the configuration:
+
+ # config/environments/development.rb
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+
+ This feature depends on the [listen](https://github.com/guard/listen) gem:
group :development do
- gem 'listen', '~> 3.0.4'
+ gem 'listen', '~> 3.0.5'
end
*Puneet Agarwal* and *Xavier Noria*
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index a286a7c5d2..ba2fb4c1cf 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -98,7 +98,7 @@ application. Accepts a valid week day symbol (e.g. `:monday`).
* `config.exceptions_app` sets the exceptions application invoked by the ShowException middleware when an exception happens. Defaults to `ActionDispatch::PublicExceptions.new(Rails.public_path)`.
-* `config.file_watcher` the class used to detect file updates in the filesystem when `config.reload_classes_only_on_change` is true. Must conform to `ActiveSupport::FileUpdateChecker` API.
+* `config.file_watcher` is the class used to detect file updates in the file system when `config.reload_classes_only_on_change` is true. Rails ships with `ActiveSupport::FileUpdateChecker`, the default, and `ActiveSupport::EventedFileUpdateChecker` (this one depends on the [listen](https://github.com/guard/listen) gem). Custom classes must conform to the `ActiveSupport::FileUpdateChecker` API.
* `config.filter_parameters` used for filtering out the parameters that
you don't want shown in the logs, such as passwords or credit card
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index e5ab31005e..b9d2db773a 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,8 @@
+* The generated config file for the development environment includes a new
+ config line, commented out, showing how to enable the evented file watcher.
+
+ *Xavier Noria*
+
* `config.debug_exception_response_format` configures the format used
in responses when errors occur in development mode.
@@ -38,11 +43,6 @@
*Yuki Nishijima*
-* Generated `Gemfile`s for new applications include a new dependency on
- [listen](https://github.com/guard/listen) commented out.
-
- *Puneet Agarwal* and *Xavier Noria*
-
* Deprecate `serve_static_files` in favor of `public_file_server.enabled`.
Unifies the static asset options under `public_file_server`.
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index a5550df0de..65cff1561a 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -44,7 +44,7 @@ module Rails
@railties_order = [:all]
@relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
@reload_classes_only_on_change = true
- @file_watcher = file_update_checker
+ @file_watcher = ActiveSupport::FileUpdateChecker
@exceptions_app = nil
@autoflush_log = true
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
@@ -191,26 +191,21 @@ module Rails
SourceAnnotationExtractor::Annotation
end
- private
- def file_update_checker
- ActiveSupport::FileUpdateChecker
+ class Custom #:nodoc:
+ def initialize
+ @configurations = Hash.new
end
- class Custom #:nodoc:
- def initialize
- @configurations = Hash.new
- end
-
- def method_missing(method, *args)
- if method =~ /=$/
- @configurations[$`.to_sym] = args.first
- else
- @configurations.fetch(method) {
- @configurations[method] = ActiveSupport::OrderedOptions.new
- }
- end
+ def method_missing(method, *args)
+ if method =~ /=$/
+ @configurations[$`.to_sym] = args.first
+ else
+ @configurations.fetch(method) {
+ @configurations[method] = ActiveSupport::OrderedOptions.new
+ }
end
end
+ end
end
end
end
diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile
index a0880d5166..975be07622 100644
--- a/railties/lib/rails/generators/rails/app/templates/Gemfile
+++ b/railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -48,10 +48,6 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
<% end -%>
-
- # Loading the listen gem enables an evented file system monitor. Check
- # https://github.com/guard/listen#listen-adapters if on Windows or *BSD.
- # gem 'listen', '~> 3.0.5'
end
<% end -%>
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
index 2778dd8247..65c6aeb694 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
@@ -55,4 +55,8 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end