From 785adabc4b8d892b6e06fca2f259e9c5147e9ca5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 12 Oct 2015 20:41:14 +0200 Subject: implements an evented file update checker [Puneet Agarwal] This is the implementation of the file update checker written by Puneet Agarwal for GSoC 2015 (except for the tiny version of the listen gem, which was 3.0.2 in the original patch). Puneet's branch became too out of sync with upstream. This is the final work in one single clean commit. Credit goes in the first line using a convention understood by the contrib app. --- railties/lib/rails/application/configuration.rb | 2 +- railties/lib/rails/generators/rails/app/templates/Gemfile | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 785671f70b..6d68eea220 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 = ActiveSupport::FileUpdateChecker + @file_watcher = (defined?(Listen) && Listen::Adapter.select()!=Listen::Adapter::Polling)? ActiveSupport::FileEventedUpdateChecker : ActiveSupport::FileUpdateChecker @exceptions_app = nil @autoflush_log = true @log_formatter = ActiveSupport::Logger::SimpleFormatter.new diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 975be07622..87ef60288d 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -53,3 +53,6 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +# Uncomment this, to increase the performance +# gem 'listen', '~> 3.0.3' -- cgit v1.2.3 From c27caeecb693ddbc575302751479b4bdedf28634 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 19 Oct 2015 22:24:36 +0200 Subject: move the listen gem in the Gemfile to the development group --- railties/lib/rails/generators/rails/app/templates/Gemfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 87ef60288d..ef23bc23a7 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -48,11 +48,12 @@ 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.3' end <% end -%> # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] - -# Uncomment this, to increase the performance -# gem 'listen', '~> 3.0.3' -- cgit v1.2.3 From d47b98226827e52bc182b6b22b50a1834b45e7e4 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 4 Nov 2015 15:57:31 +0100 Subject: upgrade listen to 3.0.4 3.0.3 has a bug in OS X. --- railties/lib/rails/generators/rails/app/templates/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index ef23bc23a7..4f3f59cc22 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -51,7 +51,7 @@ group :development do # 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.3' + # gem 'listen', '~> 3.0.4' end <% end -%> -- cgit v1.2.3 From bf4532dfdfa06f6fb00e2ce33cfb4f5b5dc43d50 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 10 Nov 2015 07:27:46 -0800 Subject: encapsulates the logic to choose the file monitor in app config --- railties/lib/rails/application/configuration.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 6d68eea220..6d89caf514 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 = (defined?(Listen) && Listen::Adapter.select()!=Listen::Adapter::Polling)? ActiveSupport::FileEventedUpdateChecker : ActiveSupport::FileUpdateChecker + @file_watcher = file_update_checker @exceptions_app = nil @autoflush_log = true @log_formatter = ActiveSupport::Logger::SimpleFormatter.new @@ -181,6 +181,14 @@ module Rails end private + def file_update_checker + if defined?(Listen) && Listen::Adapter.select() != Listen::Adapter::Polling + ActiveSupport::FileEventedUpdateChecker + else + ActiveSupport::FileUpdateChecker + end + end + class Custom #:nodoc: def initialize @configurations = Hash.new -- cgit v1.2.3 From 59be32b572cdff24da64ca6fd82db53a075c8bb6 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 11 Nov 2015 05:54:12 +0100 Subject: registers these changes in the CHANGELOGs --- railties/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 6980ba94e2..2fedeac292 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,8 @@ +* 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`. -- cgit v1.2.3