lazy load listen in core

See the rationale in the comment present in this patch.
This commit is contained in:
Xavier Noria 2015-12-13 18:59:34 +01:00
parent 7223596259
commit a94d404510
2 changed files with 5 additions and 2 deletions

View File

@ -45,7 +45,7 @@ end
# Active Support.
gem 'dalli', '>= 2.2.1'
gem 'listen', '~> 3.0.5'
gem 'listen', '~> 3.0.5', require: false
# Active Job.
group :job do

View File

@ -1,4 +1,3 @@
require 'listen'
require 'set'
require 'pathname'
require 'concurrent/atomic/atomic_boolean'
@ -19,6 +18,10 @@ module ActiveSupport
@lcsp = @ph.longest_common_subpath(@dirs.keys)
if (dtw = directories_to_watch).any?
# Loading listen triggers warnings. These are originated by a legit
# usage of attr_* macros for private attributes, but adds a lot of noise
# to our test suite. Thus, we lazy load it and disable warnings locally.
silence_warnings { require 'listen' }
Listen.to(*dtw, &method(:changed)).start
end
end