aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorJoel Hawksley <joelhawksley@github.com>2019-06-03 08:27:09 -0600
committerGitHub <noreply@github.com>2019-06-03 08:27:09 -0600
commit60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c (patch)
tree99c9199bf71835f18e2c746b04abe70569e5baed /activesupport/lib/active_support
parenta85c372798723b900762c27e62c35689905327aa (diff)
parentc926ca46280aee795b98206dd0707a96b9423cc5 (diff)
downloadrails-60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c.tar.gz
rails-60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c.tar.bz2
rails-60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c.zip
Merge pull request #2 from rails/master
merge master
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb2
-rw-r--r--activesupport/lib/active_support/evented_file_update_checker.rb14
-rw-r--r--activesupport/lib/active_support/notifications.rb14
-rw-r--r--activesupport/lib/active_support/notifications/fanout.rb6
-rw-r--r--activesupport/lib/active_support/testing/parallelization.rb8
6 files changed, 27 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb b/activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb
index 720a1f67c8..18acb1e70c 100644
--- a/activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb
+++ b/activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class Hash
- # Returns a new hash with all keys converted by the block operation.
- # This includes the keys from the root hash and from all
+ # Returns a new hash with all values converted by the block operation.
+ # This includes the values from the root hash and from all
# nested hashes and arrays.
#
# hash = { person: { name: 'Rob', age: '28' } }
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index 2f88010d27..b8996ecb10 100644
--- a/activesupport/lib/active_support/core_ext/module/delegation.rb
+++ b/activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -297,7 +297,7 @@ class Module
rescue NoMethodError
if #{target}.nil?
if #{allow_nil == true}
- return nil
+ nil
else
raise DelegationError, "\#{method} delegated to #{target}, but #{target} is nil"
end
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb
index 3893b0de0e..84caa00b58 100644
--- a/activesupport/lib/active_support/evented_file_update_checker.rb
+++ b/activesupport/lib/active_support/evented_file_update_checker.rb
@@ -107,6 +107,7 @@ module ActiveSupport
private
def boot!
+ normalize_dirs!
Listen.to(*@dtw, &method(:changed)).start
end
@@ -114,6 +115,12 @@ module ActiveSupport
Listen.stop
end
+ def normalize_dirs!
+ @dirs.transform_keys! do |dir|
+ dir.exist? ? dir.realpath : dir
+ end
+ end
+
def changed(modified, added, removed)
unless updated?
@updated.make_true if (modified + added + removed).any? { |f| watching?(f) }
@@ -187,13 +194,6 @@ module ActiveSupport
lcsp
end
- # Returns the deepest existing ascendant, which could be the argument itself.
- def existing_parent(dir)
- dir.ascend do |ascendant|
- break ascendant if ascendant.directory?
- end
- end
-
# Filters out directories which are descendants of others in the collection (stable).
def filter_out_descendants(dirs)
return dirs if dirs.length < 2
diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb
index 555c0ad1d3..a7a6112b0f 100644
--- a/activesupport/lib/active_support/notifications.rb
+++ b/activesupport/lib/active_support/notifications.rb
@@ -231,18 +231,16 @@ module ActiveSupport
# ActiveSupport::Notifications.subscribe(/render/) do |event|
# @event = event
# end
- def subscribe(*args, &block)
- pattern, callback = *args
- notifier.subscribe(pattern, callback, false, &block)
+ def subscribe(pattern = nil, callback = nil, &block)
+ notifier.subscribe(pattern, callback, monotonic: false, &block)
end
- def monotonic_subscribe(*args, &block)
- pattern, callback = *args
- notifier.subscribe(pattern, callback, true, &block)
+ def monotonic_subscribe(pattern = nil, callback = nil, &block)
+ notifier.subscribe(pattern, callback, monotonic: true, &block)
end
- def subscribed(callback, pattern, monotonic: false, &block)
- subscriber = notifier.subscribe(pattern, callback, monotonic)
+ def subscribed(callback, pattern = nil, monotonic: false, &block)
+ subscriber = notifier.subscribe(pattern, callback, monotonic: monotonic)
yield
ensure
unsubscribe(subscriber)
diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb
index c37bec4ee5..aa602329ec 100644
--- a/activesupport/lib/active_support/notifications/fanout.rb
+++ b/activesupport/lib/active_support/notifications/fanout.rb
@@ -20,8 +20,8 @@ module ActiveSupport
super
end
- def subscribe(pattern = nil, callable = nil, monotonic = false, &block)
- subscriber = Subscribers.new(monotonic, pattern, callable || block)
+ def subscribe(pattern = nil, callable = nil, monotonic: false, &block)
+ subscriber = Subscribers.new(pattern, callable || block, monotonic)
synchronize do
if String === pattern
@string_subscribers[pattern] << subscriber
@@ -84,7 +84,7 @@ module ActiveSupport
end
module Subscribers # :nodoc:
- def self.new(monotonic, pattern, listener)
+ def self.new(pattern, listener, monotonic)
subscriber_class = monotonic ? MonotonicTimed : Timed
if listener.respond_to?(:start) && listener.respond_to?(:finish)
diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb
index e760bf5ce3..f50a5e0554 100644
--- a/activesupport/lib/active_support/testing/parallelization.rb
+++ b/activesupport/lib/active_support/testing/parallelization.rb
@@ -27,6 +27,10 @@ module ActiveSupport
@queue << o
end
+ def length
+ @queue.length
+ end
+
def pop; @queue.pop; end
end
@@ -109,6 +113,10 @@ module ActiveSupport
def shutdown
@queue_size.times { @queue << nil }
@pool.each { |pid| Process.waitpid pid }
+
+ if @queue.length > 0
+ raise "Queue not empty, but all workers have finished. This probably means that a worker crashed and #{@queue.length} tests were missed."
+ end
end
private