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