activesupport 5.2.8 → 6.0.0.beta1

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.

Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +182 -581
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/active_support/backtrace_cleaner.rb +23 -0
  6. data/lib/active_support/cache/file_store.rb +19 -12
  7. data/lib/active_support/cache/mem_cache_store.rb +16 -2
  8. data/lib/active_support/cache/memory_store.rb +5 -0
  9. data/lib/active_support/cache/null_store.rb +5 -0
  10. data/lib/active_support/cache/redis_cache_store.rb +39 -20
  11. data/lib/active_support/cache.rb +40 -18
  12. data/lib/active_support/callbacks.rb +16 -5
  13. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +0 -18
  14. data/lib/active_support/configurable.rb +4 -8
  15. data/lib/active_support/core_ext/array/extract.rb +21 -0
  16. data/lib/active_support/core_ext/array/prepend_and_append.rb +2 -6
  17. data/lib/active_support/core_ext/array.rb +1 -1
  18. data/lib/active_support/core_ext/class/attribute.rb +1 -1
  19. data/lib/active_support/core_ext/class/subclasses.rb +1 -1
  20. data/lib/active_support/core_ext/date/calculations.rb +6 -5
  21. data/lib/active_support/core_ext/date_and_time/calculations.rb +24 -17
  22. data/lib/active_support/core_ext/date_time/calculations.rb +1 -1
  23. data/lib/active_support/core_ext/enumerable.rb +71 -67
  24. data/lib/active_support/core_ext/hash/compact.rb +2 -26
  25. data/lib/active_support/core_ext/hash/keys.rb +0 -29
  26. data/lib/active_support/core_ext/hash/slice.rb +3 -25
  27. data/lib/active_support/core_ext/hash/transform_values.rb +2 -29
  28. data/lib/active_support/core_ext/hash.rb +0 -2
  29. data/lib/active_support/core_ext/integer/multiple.rb +1 -1
  30. data/lib/active_support/core_ext/load_error.rb +1 -1
  31. data/lib/active_support/core_ext/module/attribute_accessors.rb +2 -5
  32. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +8 -14
  33. data/lib/active_support/core_ext/module/delegation.rb +27 -7
  34. data/lib/active_support/core_ext/module/introspection.rb +37 -13
  35. data/lib/active_support/core_ext/module/reachable.rb +1 -6
  36. data/lib/active_support/core_ext/module/redefine_method.rb +8 -17
  37. data/lib/active_support/core_ext/module.rb +0 -1
  38. data/lib/active_support/core_ext/numeric/conversions.rb +124 -128
  39. data/lib/active_support/core_ext/numeric/inquiry.rb +2 -25
  40. data/lib/active_support/core_ext/numeric.rb +0 -1
  41. data/lib/active_support/core_ext/object/blank.rb +1 -2
  42. data/lib/active_support/core_ext/object/duplicable.rb +5 -2
  43. data/lib/active_support/core_ext/object/json.rb +1 -0
  44. data/lib/active_support/core_ext/object/try.rb +15 -7
  45. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  46. data/lib/active_support/core_ext/range/compare_range.rb +1 -1
  47. data/lib/active_support/core_ext/range/conversions.rb +31 -29
  48. data/lib/active_support/core_ext/range/include_range.rb +6 -0
  49. data/lib/active_support/core_ext/regexp.rb +0 -4
  50. data/lib/active_support/core_ext/securerandom.rb +23 -3
  51. data/lib/active_support/core_ext/string/access.rb +8 -0
  52. data/lib/active_support/core_ext/string/filters.rb +41 -0
  53. data/lib/active_support/core_ext/string/multibyte.rb +4 -3
  54. data/lib/active_support/core_ext/string/output_safety.rb +16 -33
  55. data/lib/active_support/core_ext/string/strip.rb +3 -1
  56. data/lib/active_support/core_ext/uri.rb +1 -0
  57. data/lib/active_support/current_attributes.rb +2 -0
  58. data/lib/active_support/dependencies.rb +28 -11
  59. data/lib/active_support/deprecation/behaviors.rb +1 -1
  60. data/lib/active_support/deprecation/method_wrappers.rb +4 -5
  61. data/lib/active_support/deprecation/proxy_wrappers.rb +0 -2
  62. data/lib/active_support/deprecation.rb +1 -1
  63. data/lib/active_support/descendants_tracker.rb +6 -5
  64. data/lib/active_support/duration/iso8601_parser.rb +2 -3
  65. data/lib/active_support/duration/iso8601_serializer.rb +3 -4
  66. data/lib/active_support/duration.rb +12 -14
  67. data/lib/active_support/encrypted_configuration.rb +0 -4
  68. data/lib/active_support/evented_file_update_checker.rb +25 -7
  69. data/lib/active_support/execution_wrapper.rb +14 -16
  70. data/lib/active_support/gem_version.rb +4 -4
  71. data/lib/active_support/hash_with_indifferent_access.rb +16 -28
  72. data/lib/active_support/i18n.rb +1 -0
  73. data/lib/active_support/i18n_railtie.rb +8 -1
  74. data/lib/active_support/inflector/inflections.rb +1 -4
  75. data/lib/active_support/inflector/methods.rb +15 -27
  76. data/lib/active_support/inflector/transliterate.rb +6 -6
  77. data/lib/active_support/json/decoding.rb +23 -23
  78. data/lib/active_support/json/encoding.rb +6 -2
  79. data/lib/active_support/key_generator.rb +0 -32
  80. data/lib/active_support/lazy_load_hooks.rb +5 -1
  81. data/lib/active_support/locale/en.rb +31 -0
  82. data/lib/active_support/log_subscriber.rb +31 -8
  83. data/lib/active_support/logger.rb +0 -15
  84. data/lib/active_support/logger_silence.rb +28 -12
  85. data/lib/active_support/logger_thread_safe_level.rb +27 -6
  86. data/lib/active_support/message_encryptor.rb +2 -4
  87. data/lib/active_support/message_verifier.rb +2 -2
  88. data/lib/active_support/multibyte/chars.rb +29 -48
  89. data/lib/active_support/multibyte/unicode.rb +44 -281
  90. data/lib/active_support/notifications/fanout.rb +42 -4
  91. data/lib/active_support/notifications/instrumenter.rb +73 -2
  92. data/lib/active_support/notifications.rb +32 -4
  93. data/lib/active_support/number_helper/number_to_currency_converter.rb +2 -2
  94. data/lib/active_support/number_helper/number_to_delimited_converter.rb +3 -1
  95. data/lib/active_support/number_helper/number_to_human_converter.rb +3 -1
  96. data/lib/active_support/number_helper/number_to_human_size_converter.rb +3 -1
  97. data/lib/active_support/number_helper/number_to_percentage_converter.rb +3 -1
  98. data/lib/active_support/number_helper/number_to_phone_converter.rb +2 -0
  99. data/lib/active_support/number_helper/number_to_rounded_converter.rb +5 -3
  100. data/lib/active_support/number_helper.rb +7 -0
  101. data/lib/active_support/ordered_options.rb +1 -1
  102. data/lib/active_support/parameter_filter.rb +124 -0
  103. data/lib/active_support/rails.rb +0 -6
  104. data/lib/active_support/reloader.rb +5 -6
  105. data/lib/active_support/subscriber.rb +16 -26
  106. data/lib/active_support/tagged_logging.rb +13 -4
  107. data/lib/active_support/test_case.rb +91 -0
  108. data/lib/active_support/testing/assertions.rb +15 -1
  109. data/lib/active_support/testing/deprecation.rb +0 -1
  110. data/lib/active_support/testing/file_fixtures.rb +2 -0
  111. data/lib/active_support/testing/isolation.rb +2 -2
  112. data/lib/active_support/testing/method_call_assertions.rb +28 -1
  113. data/lib/active_support/testing/parallelization.rb +109 -0
  114. data/lib/active_support/testing/stream.rb +1 -1
  115. data/lib/active_support/testing/time_helpers.rb +7 -7
  116. data/lib/active_support/time_with_zone.rb +15 -5
  117. data/lib/active_support/values/time_zone.rb +12 -7
  118. data/lib/active_support/xml_mini/jdom.rb +2 -2
  119. data/lib/active_support/xml_mini/libxml.rb +2 -2
  120. data/lib/active_support/xml_mini/libxmlsax.rb +4 -4
  121. data/lib/active_support/xml_mini/nokogiri.rb +2 -2
  122. data/lib/active_support/xml_mini/nokogirisax.rb +3 -3
  123. data/lib/active_support/xml_mini/rexml.rb +2 -2
  124. data/lib/active_support/xml_mini.rb +2 -9
  125. data/lib/active_support.rb +1 -1
  126. metadata +12 -10
  127. data/lib/active_support/core_ext/digest.rb +0 -3
  128. data/lib/active_support/values/unicode_tables.dat +0 -0
data/CHANGELOG.md CHANGED
@@ -1,148 +1,27 @@
1
- ## Rails 5.2.8 (May 09, 2022) ##
1
+ ## Rails 6.0.0.beta1 (January 18, 2019) ##
2
2
 
3
- * No changes.
3
+ * Remove deprecated `Module#reachable?` method.
4
4
 
5
+ *Rafael Mendonça França*
5
6
 
6
- ## Rails 5.2.7.1 (April 26, 2022) ##
7
-
8
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
9
-
10
- Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
11
- in names of tags and names of attributes, following the specification of XML.
12
-
13
- *Álvaro Martín Fraguas*
14
-
15
-
16
- ## Rails 5.2.7 (March 10, 2022) ##
17
-
18
- * Restore support to Ruby 2.2.
19
-
20
- *ojab*
21
-
22
-
23
- ## Rails 5.2.6.3 (March 08, 2022) ##
24
-
25
- * No changes.
26
-
27
-
28
- ## Rails 5.2.6.2 (February 11, 2022) ##
29
-
30
- * Fix Reloader method signature to work with the new Executor signature
31
-
32
-
33
- ## Rails 5.2.6.1 (February 11, 2022) ##
34
-
35
- * No changes.
36
-
37
-
38
- ## Rails 5.2.6 (May 05, 2021) ##
39
-
40
- * No changes.
41
-
42
-
43
- ## Rails 5.2.5 (March 26, 2021) ##
44
-
45
- * No changes.
46
-
47
-
48
- ## Rails 5.2.4.6 (May 05, 2021) ##
49
-
50
- * No changes.
51
-
52
-
53
- ## Rails 5.2.4.5 (February 10, 2021) ##
54
-
55
- * No changes.
56
-
57
-
58
- ## Rails 5.2.4.4 (September 09, 2020) ##
59
-
60
- * No changes.
61
-
62
-
63
- ## Rails 5.2.4.3 (May 18, 2020) ##
64
-
65
- * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
66
-
67
- * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
68
-
69
- ## Rails 5.2.4.2 (March 19, 2020) ##
70
-
71
- * No changes.
72
-
73
-
74
- ## Rails 5.2.4.1 (December 18, 2019) ##
75
-
76
- * No changes.
77
-
78
-
79
- ## Rails 5.2.4 (November 27, 2019) ##
80
-
81
- * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
82
-
83
- Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
84
- to make log level local to Ruby Fibers in addition to Threads.
85
-
86
- Example:
87
-
88
- logger = ActiveSupport::Logger.new(STDOUT)
89
- logger.level = 1
90
- p "Main is debug? #{logger.debug?}"
91
-
92
- Fiber.new {
93
- logger.local_level = 0
94
- p "Thread is debug? #{logger.debug?}"
95
- }.resume
96
-
97
- p "Main is debug? #{logger.debug?}"
98
-
99
- Before:
100
-
101
- Main is debug? false
102
- Thread is debug? true
103
- Main is debug? true
104
-
105
- After:
106
-
107
- Main is debug? false
108
- Thread is debug? true
109
- Main is debug? false
110
-
111
- *Alexander Varnin*
112
-
113
-
114
- ## Rails 5.2.3 (March 27, 2019) ##
115
-
116
- * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
117
-
118
- `assoc` can now be called with either a string or a symbol.
7
+ * Remove deprecated `#acronym_regex` method from `Inflections`.
119
8
 
120
- *Stefan Schüßler*
9
+ *Rafael Mendonça França*
121
10
 
122
11
  * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
123
12
 
124
13
  *Keenan Brock*
125
14
 
126
- * Allow Range#=== and Range#cover? on Range
15
+ * Preserve key order passed to `ActiveSupport::CacheStore#fetch_multi`.
127
16
 
128
- `Range#cover?` can now accept a range argument like `Range#include?` and
129
- `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
130
- into a new file, with these two methods.
17
+ `fetch_multi(*names)` now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
131
18
 
132
- *utilum*
19
+ *Gannon McGibbon*
133
20
 
134
21
  * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
135
22
 
136
23
  *Mark J. Titorenko*, *Vlad Bokov*
137
24
 
138
-
139
- ## Rails 5.2.2.1 (March 11, 2019) ##
140
-
141
- * No changes.
142
-
143
-
144
- ## Rails 5.2.2 (December 04, 2018) ##
145
-
146
25
  * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
147
26
  would not act as alias for `#symbolize_keys`.
148
27
 
@@ -152,564 +31,286 @@
152
31
 
153
32
  *Jan Habermann*, *Xavier Noria*
154
33
 
155
- * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
156
-
157
- URI.unescape("\xe3\x83\x90") # => "バ"
158
- URI.unescape("%E3%83%90") # => "バ"
159
- URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
160
-
161
- *Ashe Connor*, *Aaron Patterson*
162
-
163
-
164
- ## Rails 5.2.1.1 (November 27, 2018) ##
165
-
166
- * No changes.
167
-
168
-
169
- ## Rails 5.2.1 (August 07, 2018) ##
170
-
171
- * Redis cache store: `delete_matched` no longer blocks the Redis server.
172
- (Switches from evaled Lua to a batched SCAN + DEL loop.)
173
-
174
- *Gleb Mazovetskiy*
175
-
176
- * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
177
- any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
178
-
179
- *Dominik Sander*
180
-
181
- * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
182
- size when compression is enabled (which is true by default). This patch
183
- does not attempt to repair existing data: please manually flush the cache
184
- to clear out the problematic entries.
185
-
186
- *Godfrey Chan*
187
-
188
- * Fix `ActiveSupport::Cache#read_multi` bug with local cache enabled that was
189
- returning instances of `ActiveSupport::Cache::Entry` instead of the raw values.
190
-
191
- *Jason Lee*
192
-
193
-
194
- ## Rails 5.2.0 (April 09, 2018) ##
195
-
196
- * Caching: MemCache and Redis `read_multi` and `fetch_multi` speedup.
197
- Read from the local in-memory cache before consulting the backend.
198
-
199
- *Gabriel Sobrinho*
200
-
201
- * Return all mappings for a timezone identifier in `country_zones`.
202
-
203
- Some timezones like `Europe/London` have multiple mappings in
204
- `ActiveSupport::TimeZone::MAPPING` so return all of them instead
205
- of the first one found by using `Hash#value`. e.g:
206
-
207
- # Before
208
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]
209
-
210
- # After
211
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]
212
-
213
- Fixes #31668.
214
-
215
- *Andrew White*
216
-
217
- * Add support for connection pooling on RedisCacheStore.
218
-
219
- *fatkodima*
220
-
221
- * Support hash as first argument in `assert_difference`. This allows to specify multiple
222
- numeric differences in the same assertion.
223
-
224
- assert_difference ->{ Article.count } => 1, ->{ Post.count } => 2
34
+ * Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSuppport::Multibyte::Unicode#unpack_graphemes(string)`
35
+ in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
225
36
 
226
- *Julien Meichelbeck*
37
+ *Francesco Rodríguez*
227
38
 
228
- * Add missing instrumentation for `read_multi` in `ActiveSupport::Cache::Store`.
39
+ * Deprecate `ActiveSupport::Multibyte::Chars.consumes?` in favor of `String#is_utf8?`.
229
40
 
230
- *Ignatius Reza Lesmana*
231
-
232
- * `assert_changes` will always assert that the expression changes,
233
- regardless of `from:` and `to:` argument combinations.
234
-
235
- *Daniel Ma*
236
-
237
- * Use SHA-1 to generate non-sensitive digests, such as the ETag header.
238
-
239
- Enabled by default for new apps; upgrading apps can opt in by setting
240
- `config.active_support.use_sha1_digests = true`.
241
-
242
- *Dmitri Dolguikh*, *Eugene Kenny*
243
-
244
- * Changed default behaviour of `ActiveSupport::SecurityUtils.secure_compare`,
245
- to make it not leak length information even for variable length string.
246
-
247
- Renamed old `ActiveSupport::SecurityUtils.secure_compare` to `fixed_length_secure_compare`,
248
- and started raising `ArgumentError` in case of length mismatch of passed strings.
249
-
250
- *Vipul A M*
251
-
252
- * Make `ActiveSupport::TimeZone.all` return only time zones that are in
253
- `ActiveSupport::TimeZone::MAPPING`.
254
-
255
- Fixes #7245.
256
-
257
- *Chris LaRose*
258
-
259
- * MemCacheStore: Support expiring counters.
260
-
261
- Pass `expires_in: [seconds]` to `#increment` and `#decrement` options
262
- to set the Memcached TTL (time-to-live) if the counter doesn't exist.
263
- If the counter exists, Memcached doesn't extend its expiry when it's
264
- incremented or decremented.
41
+ *Francesco Rodríguez*
265
42
 
43
+ * Fix duration being rounded to a full second.
266
44
  ```
267
- Rails.cache.increment("my_counter", 1, expires_in: 2.minutes)
45
+ time = DateTime.parse("2018-1-1")
46
+ time += 0.51.seconds
268
47
  ```
48
+ Will now correctly add 0.51 second and not 1 full second.
269
49
 
270
- *Takumasa Ochi*
50
+ *Edouard Chin*
271
51
 
272
- * Handle `TZInfo::AmbiguousTime` errors.
52
+ * Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSuppport::Multibyte::Chars#normalize`
53
+ in favor of `String#unicode_normalize`
273
54
 
274
- Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous
275
- times by choosing the later period, e.g.
55
+ *Francesco Rodríguez*
276
56
 
277
- Ruby:
278
- ```
279
- ENV["TZ"] = "Europe/Moscow"
280
- Time.local(2014, 10, 26, 1, 0, 0) # => 2014-10-26 01:00:00 +0300
281
- ```
57
+ * Deprecate `ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase` in favor of
58
+ `String#downcase/upcase/swapcase`.
282
59
 
283
- Before:
284
- ```
285
- >> "2014-10-26 01:00:00".in_time_zone("Moscow")
286
- TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time.
287
- ```
60
+ *Francesco Rodríguez*
288
61
 
289
- After:
290
- ```
291
- >> "2014-10-26 01:00:00".in_time_zone("Moscow")
292
- => Sun, 26 Oct 2014 01:00:00 MSK +03:00
293
- ```
62
+ * Add `ActiveSupport::ParameterFilter`.
294
63
 
295
- Fixes #17395.
64
+ *Yoshiyuki Kinjo*
296
65
 
297
- *Andrew White*
66
+ * Rename `Module#parent`, `Module#parents`, and `Module#parent_name` to
67
+ `module_parent`, `module_parents`, and `module_parent_name`.
298
68
 
299
- * Redis cache store.
300
-
301
- ```
302
- # Defaults to `redis://localhost:6379/0`. Only use for dev/test.
303
- config.cache_store = :redis_cache_store
304
-
305
- # Supports all common cache store options (:namespace, :compress,
306
- # :compress_threshold, :expires_in, :race_condition_ttl) and all
307
- # Redis options.
308
- cache_password = Rails.application.secrets.redis_cache_password
309
- config.cache_store = :redis_cache_store, driver: :hiredis,
310
- namespace: 'myapp-cache', compress: true, timeout: 1,
311
- url: "redis://:#{cache_password}@myapp-cache-1:6379/0"
312
-
313
- # Supports Redis::Distributed with multiple hosts
314
- config.cache_store = :redis_cache_store, driver: :hiredis
315
- namespace: 'myapp-cache', compress: true,
316
- url: %w[
317
- redis://myapp-cache-1:6379/0
318
- redis://myapp-cache-1:6380/0
319
- redis://myapp-cache-2:6379/0
320
- redis://myapp-cache-2:6380/0
321
- redis://myapp-cache-3:6379/0
322
- redis://myapp-cache-3:6380/0
323
- ]
324
-
325
- # Or pass a builder block
326
- config.cache_store = :redis_cache_store,
327
- namespace: 'myapp-cache', compress: true,
328
- redis: -> { Redis.new … }
329
- ```
69
+ *Gannon McGibbon*
330
70
 
331
- Deployment note: Take care to use a *dedicated Redis cache* rather
332
- than pointing this at your existing Redis server. It won't cope well
333
- with mixed usage patterns and it won't expire cache entries by default.
71
+ * Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence`
334
72
 
335
- Redis cache server setup guide: https://redis.io/topics/lru-cache
73
+ *Edouard Chin*
336
74
 
337
- *Jeremy Daer*
75
+ * Deprecate using negative limits in `String#first` and `String#last`.
338
76
 
339
- * Cache: Enable compression by default for values > 1kB.
77
+ *Gannon McGibbon*, *Eric Turner*
340
78
 
341
- Compression has long been available, but opt-in and at a 16kB threshold.
342
- It wasn't enabled by default due to CPU cost. Today it's cheap and typical
343
- cache data is eminently compressible, such as HTML or JSON fragments.
344
- Compression dramatically reduces Memcached/Redis mem usage, which means
345
- the same cache servers can store more data, which means higher hit rates.
79
+ * Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
80
+ with symbol arguments
346
81
 
347
- To disable compression, pass `compress: false` to the initializer.
82
+ *Abraham Chan*
348
83
 
349
- *Jeremy Daer*
84
+ * Treat `#delete_prefix`, `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
85
+ Ensure safety of arguments for `#insert`, `#[]=` and `#replace` calls on `html_safe` Strings.
350
86
 
351
- * Allow `Range#include?` on TWZ ranges.
87
+ *Janosch Müller*
352
88
 
353
- In #11474 we prevented TWZ ranges being iterated over which matched
354
- Ruby's handling of Time ranges and as a consequence `include?`
355
- stopped working with both Time ranges and TWZ ranges. However in
356
- ruby/ruby@b061634 support was added for `include?` to use `cover?`
357
- for 'linear' objects. Since we have no way of making Ruby consider
358
- TWZ instances as 'linear' we have to override `Range#include?`.
89
+ * Changed `ActiveSupport::TaggedLogging.new` to return a new logger instance instead
90
+ of mutating the one received as parameter.
359
91
 
360
- Fixes #30799.
92
+ *Thierry Joyal*
361
93
 
362
- *Andrew White*
94
+ * Define `unfreeze_time` as an alias of `travel_back` in `ActiveSupport::Testing::TimeHelpers`.
363
95
 
364
- * Fix acronym support in `humanize`.
96
+ The alias is provided for symmetry with `freeze_time`.
365
97
 
366
- Acronym inflections are stored with lowercase keys in the hash but
367
- the match wasn't being lowercased before being looked up in the hash.
368
- This shouldn't have any performance impact because before it would
369
- fail to find the acronym and perform the `downcase` operation anyway.
98
+ *Ryan Davidson*
370
99
 
371
- Fixes #31052.
100
+ * Add support for tracing constant autoloads. Just throw
372
101
 
373
- *Andrew White*
102
+ ActiveSupport::Dependencies.logger = Rails.logger
103
+ ActiveSupport::Dependencies.verbose = true
374
104
 
375
- * Add same method signature for `Time#prev_year` and `Time#next_year`
376
- in accordance with `Date#prev_year`, `Date#next_year`.
105
+ in an initializer.
377
106
 
378
- Allows pass argument for `Time#prev_year` and `Time#next_year`.
107
+ *Xavier Noria*
379
108
 
380
- Before:
381
- ```
382
- Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
383
- Time.new(2017, 9, 16, 17, 0).prev_year(1)
384
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
109
+ * Maintain `html_safe?` on html_safe strings when sliced.
385
110
 
386
- Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
387
- Time.new(2017, 9, 16, 17, 0).next_year(1)
388
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
389
- ```
111
+ string = "<div>test</div>".html_safe
112
+ string[-1..1].html_safe? # => true
390
113
 
391
- After:
392
- ```
393
- Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
394
- Time.new(2017, 9, 16, 17, 0).prev_year(1) # => 2016-09-16 17:00:00 +0300
114
+ *Elom Gomez*, *Yumin Wong*
395
115
 
396
- Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
397
- Time.new(2017, 9, 16, 17, 0).next_year(1) # => 2018-09-16 17:00:00 +0300
398
- ```
116
+ * Add `Array#extract!`.
399
117
 
400
- *bogdanvlviv*
118
+ The method removes and returns the elements for which the block returns a true value.
119
+ If no block is given, an Enumerator is returned instead.
401
120
 
402
- * Add same method signature for `Time#prev_month` and `Time#next_month`
403
- in accordance with `Date#prev_month`, `Date#next_month`.
404
-
405
- Allows pass argument for `Time#prev_month` and `Time#next_month`.
406
-
407
- Before:
408
- ```
409
- Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
410
- Time.new(2017, 9, 16, 17, 0).prev_month(1)
411
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
412
-
413
- Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
414
- Time.new(2017, 9, 16, 17, 0).next_month(1)
415
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
416
- ```
417
-
418
- After:
419
- ```
420
- Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
421
- Time.new(2017, 9, 16, 17, 0).prev_month(1) # => 2017-08-16 17:00:00 +0300
422
-
423
- Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
424
- Time.new(2017, 9, 16, 17, 0).next_month(1) # => 2017-10-16 17:00:00 +0300
425
- ```
426
-
427
- *bogdanvlviv*
428
-
429
- * Add same method signature for `Time#prev_day` and `Time#next_day`
430
- in accordance with `Date#prev_day`, `Date#next_day`.
431
-
432
- Allows pass argument for `Time#prev_day` and `Time#next_day`.
433
-
434
- Before:
435
- ```
436
- Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
437
- Time.new(2017, 9, 16, 17, 0).prev_day(1)
438
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
439
-
440
- Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
441
- Time.new(2017, 9, 16, 17, 0).next_day(1)
442
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
443
- ```
444
-
445
- After:
446
- ```
447
- Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
448
- Time.new(2017, 9, 16, 17, 0).prev_day(1) # => 2017-09-15 17:00:00 +0300
449
-
450
- Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
451
- Time.new(2017, 9, 16, 17, 0).next_day(1) # => 2017-09-17 17:00:00 +0300
452
- ```
121
+ numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
122
+ odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
123
+ numbers # => [0, 2, 4, 6, 8]
453
124
 
454
125
  *bogdanvlviv*
455
126
 
456
- * `IO#to_json` now returns the `to_s` representation, rather than
457
- attempting to convert to an array. This fixes a bug where `IO#to_json`
458
- would raise an `IOError` when called on an unreadable object.
459
-
460
- Fixes #26132.
461
-
462
- *Paul Kuruvilla*
463
-
464
- * Remove deprecated `halt_callback_chains_on_return_false` option.
465
-
466
- *Rafael Mendonça França*
467
-
468
- * Remove deprecated `:if` and `:unless` string filter for callbacks.
469
-
470
- *Rafael Mendonça França*
471
-
472
- * `Hash#slice` now falls back to Ruby 2.5+'s built-in definition if defined.
473
-
474
- *Akira Matsuda*
475
-
476
- * Deprecate `secrets.secret_token`.
127
+ * Support not to cache `nil` for `ActiveSupport::Cache#fetch`.
477
128
 
478
- The architecture for secrets had a big upgrade between Rails 3 and Rails 4,
479
- when the default changed from using `secret_token` to `secret_key_base`.
129
+ cache.fetch('bar', skip_nil: true) { nil }
130
+ cache.exist?('bar') # => false
480
131
 
481
- `secret_token` has been soft deprecated in documentation for four years
482
- but is still in place to support apps created before Rails 4.
483
- Deprecation warnings have been added to help developers upgrade their
484
- applications to `secret_key_base`.
132
+ *Martin Hong*
485
133
 
486
- *claudiob*, *Kasper Timm Hansen*
134
+ * Add "event object" support to the notification system.
135
+ Before this change, end users were forced to create hand made artisanal
136
+ event objects on their own, like this:
487
137
 
488
- * Return an instance of `HashWithIndifferentAccess` from `HashWithIndifferentAccess#transform_keys`.
138
+ ActiveSupport::Notifications.subscribe('wait') do |*args|
139
+ @event = ActiveSupport::Notifications::Event.new(*args)
140
+ end
489
141
 
490
- *Yuji Yaginuma*
142
+ ActiveSupport::Notifications.instrument('wait') do
143
+ sleep 1
144
+ end
491
145
 
492
- * Add key rotation support to `MessageEncryptor` and `MessageVerifier`.
146
+ @event.duration # => 1000.138
493
147
 
494
- This change introduces a `rotate` method to both the `MessageEncryptor` and
495
- `MessageVerifier` classes. This method accepts the same arguments and
496
- options as the given classes' constructor. The `encrypt_and_verify` method
497
- for `MessageEncryptor` and the `verified` method for `MessageVerifier` also
498
- accept an optional keyword argument `:on_rotation` block which is called
499
- when a rotated instance is used to decrypt or verify the message.
500
-
501
- *Michael J Coyne*
502
-
503
- * Deprecate `Module#reachable?` method.
504
-
505
- *bogdanvlviv*
148
+ After this change, if the block passed to `subscribe` only takes one
149
+ parameter, the framework will yield an event object to the block. Now
150
+ end users are no longer required to make their own:
506
151
 
507
- * Add `config/credentials.yml.enc` to store production app secrets.
152
+ ActiveSupport::Notifications.subscribe('wait') do |event|
153
+ @event = event
154
+ end
508
155
 
509
- Allows saving any authentication credentials for third party services
510
- directly in repo encrypted with `config/master.key` or `ENV["RAILS_MASTER_KEY"]`.
156
+ ActiveSupport::Notifications.instrument('wait') do
157
+ sleep 1
158
+ end
511
159
 
512
- This will eventually replace `Rails.application.secrets` and the encrypted
513
- secrets introduced in Rails 5.1.
160
+ p @event.allocations # => 7
161
+ p @event.cpu_time # => 0.256
162
+ p @event.idle_time # => 1003.2399
514
163
 
515
- *DHH*, *Kasper Timm Hansen*
164
+ Now you can enjoy event objects without making them yourself. Neat!
516
165
 
517
- * Add `ActiveSupport::EncryptedFile` and `ActiveSupport::EncryptedConfiguration`.
166
+ *Aaron "t.lo" Patterson*
518
167
 
519
- Allows for stashing encrypted files or configuration directly in repo by
520
- encrypting it with a key.
168
+ * Add cpu_time, idle_time, and allocations to Event.
521
169
 
522
- Backs the new credentials setup above, but can also be used independently.
170
+ *Eileen M. Uchitelle*, *Aaron Patterson*
523
171
 
524
- *DHH*, *Kasper Timm Hansen*
172
+ * RedisCacheStore: support key expiry in increment/decrement.
525
173
 
526
- * `Module#delegate_missing_to` now raises `DelegationError` if target is nil,
527
- similar to `Module#delegate`.
174
+ Pass `:expires_in` to `#increment` and `#decrement` to set a Redis EXPIRE on the key.
528
175
 
529
- *Anton Khamets*
176
+ If the key is already set to expire, RedisCacheStore won't extend its expiry.
530
177
 
531
- * Update `String#camelize` to provide feedback when wrong option is passed.
178
+ Rails.cache.increment("some_key", 1, expires_in: 2.minutes)
532
179
 
533
- `String#camelize` was returning nil without any feedback when an
534
- invalid option was passed as a parameter.
535
-
536
- Previously:
537
-
538
- 'one_two'.camelize(true)
539
- # => nil
540
-
541
- Now:
542
-
543
- 'one_two'.camelize(true)
544
- # => ArgumentError: Invalid option, use either :upper or :lower.
180
+ *Jason Lee*
545
181
 
546
- *Ricardo Díaz*
182
+ * Allow `Range#===` and `Range#cover?` on Range.
547
183
 
548
- * Fix modulo operations involving durations.
184
+ `Range#cover?` can now accept a range argument like `Range#include?` and
185
+ `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
186
+ into a new file, with these two methods.
549
187
 
550
- Rails 5.1 introduced `ActiveSupport::Duration::Scalar` as a wrapper
551
- around numeric values as a way of ensuring a duration was the outcome of
552
- an expression. However, the implementation was missing support for modulo
553
- operations. This support has now been added and should result in a duration
554
- being returned from expressions involving modulo operations.
188
+ *Requiring active_support/core_ext/range/include_range is now deprecated.*
189
+ *Use `require "active_support/core_ext/range/compare_range"` instead.*
555
190
 
556
- Prior to Rails 5.1:
191
+ *utilum*
557
192
 
558
- 5.minutes % 2.minutes
559
- # => 60
193
+ * Add `index_with` to Enumerable.
560
194
 
561
- Now:
195
+ Allows creating a hash from an enumerable with the value from a passed block
196
+ or a default argument.
562
197
 
563
- 5.minutes % 2.minutes
564
- # => 1 minute
198
+ %i( title body ).index_with { |attr| post.public_send(attr) }
199
+ # => { title: "hey", body: "what's up?" }
565
200
 
566
- Fixes #29603 and #29743.
201
+ %i( title body ).index_with(nil)
202
+ # => { title: nil, body: nil }
567
203
 
568
- *Sayan Chakraborty*, *Andrew White*
204
+ Closely linked with `index_by`, which creates a hash where the keys are extracted from a block.
569
205
 
570
- * Fix division where a duration is the denominator.
206
+ *Kasper Timm Hansen*
571
207
 
572
- PR #29163 introduced a change in behavior when a duration was the denominator
573
- in a calculation - this was incorrect as dividing by a duration should always
574
- return a `Numeric`. The behavior of previous versions of Rails has been restored.
208
+ * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
209
+ any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
575
210
 
576
- Fixes #29592.
211
+ *Dominik Sander*
577
212
 
578
- *Andrew White*
213
+ * Redis cache store: `delete_matched` no longer blocks the Redis server.
214
+ (Switches from evaled Lua to a batched SCAN + DEL loop.)
579
215
 
580
- * Add purpose and expiry support to `ActiveSupport::MessageVerifier` and
581
- `ActiveSupport::MessageEncryptor`.
216
+ *Gleb Mazovetskiy*
582
217
 
583
- For instance, to ensure a message is only usable for one intended purpose:
218
+ * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
219
+ size when compression is enabled (which is true by default). This patch
220
+ does not attempt to repair existing data: please manually flush the cache
221
+ to clear out the problematic entries.
584
222
 
585
- token = @verifier.generate("x", purpose: :shipping)
223
+ *Godfrey Chan*
586
224
 
587
- @verifier.verified(token, purpose: :shipping) # => "x"
588
- @verifier.verified(token) # => nil
225
+ * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
589
226
 
590
- Or make it expire after a set time:
227
+ URI.unescape("\xe3\x83\x90") # => "バ"
228
+ URI.unescape("%E3%83%90") # => "バ"
229
+ URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
591
230
 
592
- @verifier.generate("x", expires_in: 1.month)
593
- @verifier.generate("y", expires_at: Time.now.end_of_year)
231
+ *Ashe Connor*, *Aaron Patterson*
594
232
 
595
- Showcased with `ActiveSupport::MessageVerifier`, but works the same for
596
- `ActiveSupport::MessageEncryptor`'s `encrypt_and_sign` and `decrypt_and_verify`.
233
+ * Add `before?` and `after?` methods to `Date`, `DateTime`,
234
+ `Time`, and `TimeWithZone`.
597
235
 
598
- Pull requests: #29599, #29854
236
+ *Nick Holden*
599
237
 
600
- *Assain Jaleel*
238
+ * `ActiveSupport::Inflector#ordinal` and `ActiveSupport::Inflector#ordinalize` now support
239
+ translations through I18n.
601
240
 
602
- * Make the order of `Hash#reverse_merge!` consistent with `HashWithIndifferentAccess`.
241
+ # locale/fr.rb
603
242
 
604
- *Erol Fornoles*
243
+ {
244
+ fr: {
245
+ number: {
246
+ nth: {
247
+ ordinals: lambda do |_key, number:, **_options|
248
+ if number.to_i.abs == 1
249
+ 'er'
250
+ else
251
+ 'e'
252
+ end
253
+ end,
605
254
 
606
- * Add `freeze_time` helper which freezes time to `Time.now` in tests.
255
+ ordinalized: lambda do |_key, number:, **_options|
256
+ "#{number}#{ActiveSupport::Inflector.ordinal(number)}"
257
+ end
258
+ }
259
+ }
260
+ }
261
+ }
607
262
 
608
- *Prathamesh Sonpatki*
609
263
 
610
- * Default `ActiveSupport::MessageEncryptor` to use AES 256 GCM encryption.
264
+ *Christian Blais*
611
265
 
612
- On for new Rails 5.2 apps. Upgrading apps can find the config as a new
613
- framework default.
266
+ * Add `:private` option to ActiveSupport's `Module#delegate`
267
+ in order to delegate methods as private:
614
268
 
615
- *Assain Jaleel*
269
+ class User < ActiveRecord::Base
270
+ has_one :profile
271
+ delegate :date_of_birth, to: :profile, private: true
616
272
 
617
- * Cache: `write_multi`.
273
+ def age
274
+ Date.today.year - date_of_birth.year
275
+ end
276
+ end
618
277
 
619
- Rails.cache.write_multi foo: 'bar', baz: 'qux'
278
+ # User.new.age # => 29
279
+ # User.new.date_of_birth
280
+ # => NoMethodError: private method `date_of_birth' called for #<User:0x00000008221340>
620
281
 
621
- Plus faster fetch_multi with stores that implement `write_multi_entries`.
622
- Keys that aren't found may be written to the cache store in one shot
623
- instead of separate writes.
282
+ *Tomas Valent*
624
283
 
625
- The default implementation simply calls `write_entry` for each entry.
626
- Stores may override if they're capable of one-shot bulk writes, like
627
- Redis `MSET`.
284
+ * `String#truncate_bytes` to truncate a string to a maximum bytesize without
285
+ breaking multibyte characters or grapheme clusters like 👩‍👩‍👦‍👦.
628
286
 
629
287
  *Jeremy Daer*
630
288
 
631
- * Add default option to module and class attribute accessors.
632
-
633
- mattr_accessor :settings, default: {}
634
-
635
- Works for `mattr_reader`, `mattr_writer`, `cattr_accessor`, `cattr_reader`,
636
- and `cattr_writer` as well.
637
-
638
- *Genadi Samokovarov*
639
-
640
- * Add `Date#prev_occurring` and `Date#next_occurring` to return specified next/previous occurring day of week.
641
-
642
- *Shota Iguchi*
643
-
644
- * Add default option to `class_attribute`.
645
-
646
- Before:
647
-
648
- class_attribute :settings
649
- self.settings = {}
650
-
651
- Now:
652
-
653
- class_attribute :settings, default: {}
289
+ * `String#strip_heredoc` preserves frozenness.
654
290
 
655
- *DHH*
291
+ "foo".freeze.strip_heredoc.frozen? # => true
656
292
 
657
- * `#singularize` and `#pluralize` now respect uncountables for the specified locale.
293
+ Fixes that frozen string literals would inadvertently become unfrozen:
658
294
 
659
- *Eilis Hamilton*
295
+ # frozen_string_literal: true
660
296
 
661
- * Add `ActiveSupport::CurrentAttributes` to provide a thread-isolated attributes singleton.
662
- Primary use case is keeping all the per-request attributes easily available to the whole system.
297
+ foo = <<-MSG.strip_heredoc
298
+ la la la
299
+ MSG
663
300
 
664
- *DHH*
301
+ foo.frozen? # => false !??
665
302
 
666
- * Fix implicit coercion calculations with scalars and durations.
667
-
668
- Previously, calculations where the scalar is first would be converted to a duration
669
- of seconds, but this causes issues with dates being converted to times, e.g:
670
-
671
- Time.zone = "Beijing" # => Asia/Shanghai
672
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
673
- 2 * 1.day # => 172800 seconds
674
- date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00
675
-
676
- Now, the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain
677
- the part structure of the duration where possible, e.g:
678
-
679
- Time.zone = "Beijing" # => Asia/Shanghai
680
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
681
- 2 * 1.day # => 2 days
682
- date + 2 * 1.day # => Mon, 22 May 2017
683
-
684
- Fixes #29160, #28970.
685
-
686
- *Andrew White*
687
-
688
- * Add support for versioned cache entries. This enables the cache stores to recycle cache keys, greatly saving
689
- on storage in cases with frequent churn. Works together with the separation of `#cache_key` and `#cache_version`
690
- in Active Record and its use in Action Pack's fragment caching.
691
-
692
- *DHH*
693
-
694
- * Pass gem name and deprecation horizon to deprecation notifications.
695
-
696
- *Willem van Bergen*
697
-
698
- * Add support for `:offset` and `:zone` to `ActiveSupport::TimeWithZone#change`.
699
-
700
- *Andrew White*
701
-
702
- * Add support for `:offset` to `Time#change`.
303
+ *Jeremy Daer*
703
304
 
704
- Fixes #28723.
305
+ * Rails 6 requires Ruby 2.5.0 or newer.
705
306
 
706
- *Andrew White*
307
+ *Jeremy Daer*, *Kasper Timm Hansen*
707
308
 
708
- * Add `fetch_values` for `HashWithIndifferentAccess`.
309
+ * Adds parallel testing to Rails.
709
310
 
710
- The method was originally added to `Hash` in Ruby 2.3.0.
311
+ Parallelize your test suite with forked processes or threads.
711
312
 
712
- *Josh Pencheon*
313
+ *Eileen M. Uchitelle*, *Aaron Patterson*
713
314
 
714
315
 
715
- Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activesupport/CHANGELOG.md) for previous changes.
316
+ Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activesupport/CHANGELOG.md) for previous changes.