activesupport 6.0.0.rc2 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f1a531964dc7b93ba5f951990c6aecc97470d1f4cedc602c3b080a25d7a076c
4
- data.tar.gz: d6ff298a19a11b18945cfd5efb271319e488ddd50abf3792a150692f2c4cb838
3
+ metadata.gz: 20a0c971abcca4b9dabec6e28ef72c919a6ffaed5e35b29e4c3e2f359e99341b
4
+ data.tar.gz: e42089cf6ad412ef2fcf772afd6a8e010944b57fde1833c9d495dfb9c5eb3da5
5
5
  SHA512:
6
- metadata.gz: 134bf09fca6daf34f64319c1a283c279c49de42f2dc5958d2b62e7535986e916206831ee37651bcf1d7b819c615b777e07f7d1093ba77bcd9766dd21c2e2ccdf
7
- data.tar.gz: 0eb981e0fa2485636863834524a3081af1f592a8db24e029faff8257c8aa0a17ad89950752cca2f9ea34b41868369cb0389a57a8216b3fbe585b51b647a98ae0
6
+ metadata.gz: 8ff0c3e5feb9bb0dfcf5e0c95b4fb5bb8c6a30d2e276101c8ec949db9ad0895c397dc33cc1a99ec2636b45b3169a495eb8c852440956d8500d95399548b70948
7
+ data.tar.gz: fdf6945ee23e487a9b0403fcac9a7b51551900a6338a4caeb34970656033fd1e62c00eda5d463fb6fc3d0ad880470c7544f2a2108bcc5809520a8436d1bdf360
@@ -1,3 +1,54 @@
1
+ ## Rails 6.0.0 (August 16, 2019) ##
2
+
3
+ * Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
4
+ better backwards compatibility.
5
+
6
+ *Xavier Noria*
7
+
8
+ * Let `require_dependency` in `zeitwerk` mode support arguments that respond
9
+ to `to_path` for better backwards compatibility.
10
+
11
+ *Xavier Noria*
12
+
13
+ * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
14
+
15
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
16
+ to make log level local to Ruby Fibers in addition to Threads.
17
+
18
+ Example:
19
+
20
+ logger = ActiveSupport::Logger.new(STDOUT)
21
+ logger.level = 1
22
+ p "Main is debug? #{logger.debug?}"
23
+
24
+ Fiber.new {
25
+ logger.local_level = 0
26
+ p "Thread is debug? #{logger.debug?}"
27
+ }.resume
28
+
29
+ p "Main is debug? #{logger.debug?}"
30
+
31
+ Before:
32
+
33
+ Main is debug? false
34
+ Thread is debug? true
35
+ Main is debug? true
36
+
37
+ After:
38
+
39
+ Main is debug? false
40
+ Thread is debug? true
41
+ Main is debug? false
42
+
43
+ *Alexander Varnin*
44
+
45
+ * Do not delegate missing `marshal_dump` and `_dump` methods via the
46
+ `delegate_missing_to` extension. This avoids unintentionally adding instance
47
+ variables when calling `Marshal.dump(object)`, should the delegation target of
48
+ `object` be a method which would otherwise add them. Fixes #36522.
49
+
50
+ *Aaron Lipman*
51
+
1
52
  ## Rails 6.0.0.rc2 (July 22, 2019) ##
2
53
 
3
54
  * `truncate` would return the original string if it was too short to be truncated
@@ -275,6 +275,11 @@ class Module
275
275
  #
276
276
  # The delegated method must be public on the target, otherwise it will
277
277
  # raise +NoMethodError+.
278
+ #
279
+ # The <tt>marshal_dump</tt> and <tt>_dump</tt> methods are exempt from
280
+ # delegation due to possible interference when calling
281
+ # <tt>Marshal.dump(object)</tt>, should the delegation target method
282
+ # of <tt>object</tt> add or remove instance variables.
278
283
  def delegate_missing_to(target)
279
284
  target = target.to_s
280
285
  target = "self.#{target}" if DELEGATION_RESERVED_METHOD_NAMES.include?(target)
@@ -284,6 +289,7 @@ class Module
284
289
  # It may look like an oversight, but we deliberately do not pass
285
290
  # +include_private+, because they do not get delegated.
286
291
 
292
+ return false if name == :marshal_dump || name == :_dump
287
293
  #{target}.respond_to?(name) || super
288
294
  end
289
295
 
@@ -20,6 +20,9 @@ module ActiveSupport #:nodoc:
20
20
  module Dependencies #:nodoc:
21
21
  extend self
22
22
 
23
+ UNBOUND_METHOD_MODULE_NAME = Module.instance_method(:name)
24
+ private_constant :UNBOUND_METHOD_MODULE_NAME
25
+
23
26
  mattr_accessor :interlock, default: Interlock.new
24
27
 
25
28
  # :doc:
@@ -659,7 +662,7 @@ module ActiveSupport #:nodoc:
659
662
 
660
663
  # Determine if the given constant has been automatically loaded.
661
664
  def autoloaded?(desc)
662
- return false if desc.is_a?(Module) && desc.anonymous?
665
+ return false if desc.is_a?(Module) && real_mod_name(desc).nil?
663
666
  name = to_constant_name desc
664
667
  return false unless qualified_const_defined?(name)
665
668
  autoloaded_constants.include?(name)
@@ -715,7 +718,7 @@ module ActiveSupport #:nodoc:
715
718
  when String then desc.sub(/^::/, "")
716
719
  when Symbol then desc.to_s
717
720
  when Module
718
- desc.name ||
721
+ real_mod_name(desc) ||
719
722
  raise(ArgumentError, "Anonymous modules have no name to be referenced by")
720
723
  else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}"
721
724
  end
@@ -789,6 +792,14 @@ module ActiveSupport #:nodoc:
789
792
  def log(message)
790
793
  logger.debug("autoloading: #{message}") if logger && verbose
791
794
  end
795
+
796
+ private
797
+
798
+ # Returns the original name of a class or module even if `name` has been
799
+ # overridden.
800
+ def real_mod_name(mod)
801
+ UNBOUND_METHOD_MODULE_NAME.bind(mod).call
802
+ end
792
803
  end
793
804
  end
794
805
 
@@ -28,7 +28,7 @@ module ActiveSupport
28
28
  end
29
29
 
30
30
  def autoloaded?(object)
31
- cpath = object.is_a?(Module) ? object.name : object.to_s
31
+ cpath = object.is_a?(Module) ? real_mod_name(object) : object.to_s
32
32
  Rails.autoloaders.main.unloadable_cpath?(cpath)
33
33
  end
34
34
 
@@ -42,6 +42,17 @@ module ActiveSupport
42
42
  end
43
43
  end
44
44
 
45
+ module RequireDependency
46
+ def require_dependency(filename)
47
+ filename = filename.to_path if filename.respond_to?(:to_path)
48
+ if abspath = ActiveSupport::Dependencies.search_for_file(filename)
49
+ require abspath
50
+ else
51
+ require filename
52
+ end
53
+ end
54
+ end
55
+
45
56
  module Inflector
46
57
  def self.camelize(basename, _abspath)
47
58
  basename.camelize
@@ -91,7 +102,7 @@ module ActiveSupport
91
102
  def decorate_dependencies
92
103
  Dependencies.unhook!
93
104
  Dependencies.singleton_class.prepend(Decorations)
94
- Object.class_eval { alias_method :require_dependency, :require }
105
+ Object.prepend(RequireDependency)
95
106
  end
96
107
  end
97
108
  end
@@ -10,7 +10,7 @@ module ActiveSupport
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "rc2"
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -56,14 +56,40 @@ module ActiveSupport
56
56
  #
57
57
  # transliterate('Jürgen', locale: :de)
58
58
  # # => "Juergen"
59
+ #
60
+ # Transliteration is restricted to UTF-8, US-ASCII and GB18030 strings
61
+ # Other encodings will raise an ArgumentError.
59
62
  def transliterate(string, replacement = "?", locale: nil)
63
+ string = string.dup if string.frozen?
60
64
  raise ArgumentError, "Can only transliterate strings. Received #{string.class.name}" unless string.is_a?(String)
61
65
 
62
- I18n.transliterate(
66
+ allowed_encodings = [Encoding::UTF_8, Encoding::US_ASCII, Encoding::GB18030]
67
+ raise ArgumentError, "Can not transliterate strings with #{string.encoding} encoding" unless allowed_encodings.include?(string.encoding)
68
+
69
+ input_encoding = string.encoding
70
+
71
+ # US-ASCII is a subset of UTF-8 so we'll force encoding as UTF-8 if
72
+ # US-ASCII is given. This way we can let tidy_bytes handle the string
73
+ # in the same way as we do for UTF-8
74
+ string.force_encoding(Encoding::UTF_8) if string.encoding == Encoding::US_ASCII
75
+
76
+ # GB18030 is Unicode compatible but is not a direct mapping so needs to be
77
+ # transcoded. Using invalid/undef :replace will result in loss of data in
78
+ # the event of invalid characters, but since tidy_bytes will replace
79
+ # invalid/undef with a "?" we're safe to do the same beforehand
80
+ string.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace) if string.encoding == Encoding::GB18030
81
+
82
+ transliterated = I18n.transliterate(
63
83
  ActiveSupport::Multibyte::Unicode.tidy_bytes(string).unicode_normalize(:nfc),
64
84
  replacement: replacement,
65
85
  locale: locale
66
86
  )
87
+
88
+ # Restore the string encoding of the input if it was not UTF-8.
89
+ # Apply invalid/undef :replace as tidy_bytes does
90
+ transliterated.encode!(input_encoding, invalid: :replace, undef: :replace) if input_encoding != transliterated.encoding
91
+
92
+ transliterated
67
93
  end
68
94
 
69
95
  # Replaces special characters in a string so that it may be used as part of
@@ -3,6 +3,7 @@
3
3
  require "active_support/concern"
4
4
  require "active_support/core_ext/module/attribute_accessors"
5
5
  require "concurrent"
6
+ require "fiber"
6
7
 
7
8
  module ActiveSupport
8
9
  module LoggerThreadSafeLevel # :nodoc:
@@ -28,7 +29,7 @@ module ActiveSupport
28
29
  end
29
30
 
30
31
  def local_log_id
31
- Thread.current.__id__
32
+ Fiber.current.__id__
32
33
  end
33
34
 
34
35
  def local_level
@@ -110,7 +110,12 @@ module ActiveSupport
110
110
  elsif value.is_a?(Hash)
111
111
  value = call(value, parents, original_params)
112
112
  elsif value.is_a?(Array)
113
- value = value.map { |v| v.is_a?(Hash) ? call(v, parents, original_params) : v }
113
+ # If we don't pop the current parent it will be duplicated as we
114
+ # process each array value.
115
+ parents.pop if deep_regexps
116
+ value = value.map { |v| value_for_key(key, v, parents, original_params) }
117
+ # Restore the parent stack after processing the array.
118
+ parents.push(key) if deep_regexps
114
119
  elsif blocks.any?
115
120
  key = key.dup if key.duplicable?
116
121
  value = value.dup if value.duplicable?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.rc2
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-22 00:00:00.000000000 Z
11
+ date: 2019-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -358,8 +358,8 @@ homepage: https://rubyonrails.org
358
358
  licenses:
359
359
  - MIT
360
360
  metadata:
361
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0.rc2/activesupport
362
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0.rc2/activesupport/CHANGELOG.md
361
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0/activesupport
362
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0/activesupport/CHANGELOG.md
363
363
  post_install_message:
364
364
  rdoc_options:
365
365
  - "--encoding"
@@ -373,9 +373,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
373
373
  version: 2.5.0
374
374
  required_rubygems_version: !ruby/object:Gem::Requirement
375
375
  requirements:
376
- - - ">"
376
+ - - ">="
377
377
  - !ruby/object:Gem::Version
378
- version: 1.3.1
378
+ version: '0'
379
379
  requirements: []
380
380
  rubygems_version: 3.0.1
381
381
  signing_key: