activesupport 6.0.0.beta1 → 6.0.1.rc1

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +302 -1
  3. data/README.rdoc +2 -1
  4. data/lib/active_support.rb +1 -0
  5. data/lib/active_support/actionable_error.rb +48 -0
  6. data/lib/active_support/backtrace_cleaner.rb +5 -1
  7. data/lib/active_support/cache.rb +5 -5
  8. data/lib/active_support/cache/file_store.rb +3 -10
  9. data/lib/active_support/cache/memory_store.rb +4 -2
  10. data/lib/active_support/cache/redis_cache_store.rb +9 -6
  11. data/lib/active_support/concern.rb +24 -1
  12. data/lib/active_support/configurable.rb +3 -3
  13. data/lib/active_support/core_ext/array/access.rb +18 -6
  14. data/lib/active_support/core_ext/class/attribute.rb +10 -15
  15. data/lib/active_support/core_ext/date_and_time/calculations.rb +0 -30
  16. data/lib/active_support/core_ext/digest.rb +3 -0
  17. data/lib/active_support/core_ext/enumerable.rb +24 -4
  18. data/lib/active_support/core_ext/hash.rb +1 -0
  19. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  20. data/lib/active_support/core_ext/hash/except.rb +1 -1
  21. data/lib/active_support/core_ext/kernel.rb +0 -1
  22. data/lib/active_support/core_ext/module/attribute_accessors.rb +5 -5
  23. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +5 -5
  24. data/lib/active_support/core_ext/module/delegation.rb +6 -0
  25. data/lib/active_support/core_ext/object/duplicable.rb +7 -117
  26. data/lib/active_support/core_ext/range/compare_range.rb +27 -12
  27. data/lib/active_support/core_ext/range/include_time_with_zone.rb +2 -2
  28. data/lib/active_support/core_ext/string/filters.rb +1 -1
  29. data/lib/active_support/core_ext/string/inflections.rb +7 -2
  30. data/lib/active_support/core_ext/string/output_safety.rb +51 -4
  31. data/lib/active_support/core_ext/time/calculations.rb +31 -2
  32. data/lib/active_support/current_attributes.rb +6 -0
  33. data/lib/active_support/dependencies.rb +41 -5
  34. data/lib/active_support/dependencies/zeitwerk_integration.rb +118 -0
  35. data/lib/active_support/deprecation/method_wrappers.rb +7 -18
  36. data/lib/active_support/deprecation/proxy_wrappers.rb +24 -3
  37. data/lib/active_support/descendants_tracker.rb +52 -6
  38. data/lib/active_support/duration.rb +2 -3
  39. data/lib/active_support/encrypted_file.rb +2 -1
  40. data/lib/active_support/evented_file_update_checker.rb +14 -2
  41. data/lib/active_support/gem_version.rb +2 -2
  42. data/lib/active_support/hash_with_indifferent_access.rb +19 -3
  43. data/lib/active_support/i18n_railtie.rb +2 -1
  44. data/lib/active_support/inflector/transliterate.rb +43 -14
  45. data/lib/active_support/logger_thread_safe_level.rb +2 -1
  46. data/lib/active_support/message_encryptor.rb +1 -1
  47. data/lib/active_support/message_verifier.rb +1 -1
  48. data/lib/active_support/notifications.rb +9 -0
  49. data/lib/active_support/notifications/fanout.rb +60 -13
  50. data/lib/active_support/notifications/instrumenter.rb +11 -10
  51. data/lib/active_support/ordered_hash.rb +1 -1
  52. data/lib/active_support/ordered_options.rb +1 -1
  53. data/lib/active_support/parameter_filter.rb +6 -1
  54. data/lib/active_support/security_utils.rb +1 -1
  55. data/lib/active_support/subscriber.rb +55 -6
  56. data/lib/active_support/testing/parallelization.rb +21 -2
  57. metadata +27 -7
  58. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e983c5003fc2a5e0407ce1c167bd223b633cd8a99f2ac41e220d28ca66e153f3
4
- data.tar.gz: 1e7910b6401c6f5a6f61ee1d24f0ad29a5d0f4d89ac064d7c6e6bf9c7d1becf0
3
+ metadata.gz: d3c9f64a0fa571b426006ded74ceecc254256afa6bbea8d9e649cf34d664cb57
4
+ data.tar.gz: 64ade9a0efc8f6dc95247de518d84cbf1402a44532e189d982baf323190b7810
5
5
  SHA512:
6
- metadata.gz: caa53fcafc4583b3642f3e95dd7f0829779a52dec8035a55f8f3e64f965de73c48268b8fb8819cb6b523dd23da28e7a35d008851dd4f65abd16e1f17c287c874
7
- data.tar.gz: 9ded7b685c180132fbd34950ac9313cb7399bc524e3e3c531f0142fc7c83b9f92ef5dce01e950adff90152561c4132a6fe48f4e55bce1b71fb45da064d2facc1
6
+ metadata.gz: 62adb7ae6be4bf4ceac08aa3d518568b77b642fe4ac16c5c69369402f8b274c1903a4b750b2c4b78b3873ad1a10388099c9435250e1fa25eaa3fadee3ba2743a
7
+ data.tar.gz: 94305170cdb8f4532cf1c7b2c986680c860f7519f7ff40706ae8137d06bb067bea1e5065c3bb05251b8c657b3065bcc27982a57430b8c47020ea60ee88c498ae
@@ -1,3 +1,304 @@
1
+ ## Rails 6.0.1.rc1 (October 31, 2019) ##
2
+
3
+ * `ActiveSupport::SafeBuffer` supports `Enumerator` methods.
4
+
5
+ *Shugo Maeda*
6
+
7
+ * The Redis cache store fails gracefully when the server returns a "max number
8
+ of clients reached" error.
9
+
10
+ *Brandon Medenwald*
11
+
12
+ * Fixed that mutating a value returned by a memory cache store would
13
+ unexpectedly change the cached value.
14
+
15
+ *Jonathan Hyman*
16
+
17
+ * The default inflectors in `zeitwerk` mode support overrides:
18
+
19
+ ```ruby
20
+ # config/initializers/zeitwerk.rb
21
+ Rails.autoloaders.each do |autoloader|
22
+ autoloader.inflector.inflect(
23
+ "html_parser" => "HTMLParser",
24
+ "ssl_error" => "SSLError"
25
+ )
26
+ end
27
+ ```
28
+
29
+ That way, you can tweak how individual basenames are inflected without touching Active Support inflection rules, which are global. These inflectors fallback to `String#camelize`, so existing inflection rules are still taken into account for non-overridden basenames.
30
+
31
+ Please, check the [autoloading guide for `zeitwerk` mode](https://guides.rubyonrails.org/v6.0/autoloading_and_reloading_constants.html#customizing-inflections) if you prefer not to depend on `String#camelize` at all.
32
+
33
+ *Xavier Noria*
34
+
35
+ * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
36
+ and endless range targets.
37
+
38
+ *Allen Hsu*, *Andrew Hodgkinson*
39
+
40
+ * Don't use `Process#clock_gettime(CLOCK_PROCESS_CPUTIME_ID)` on Solaris
41
+
42
+ *Iain Beeston*
43
+
44
+
45
+ ## Rails 6.0.0 (August 16, 2019) ##
46
+
47
+ * Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
48
+ better backwards compatibility.
49
+
50
+ *Xavier Noria*
51
+
52
+ * Let `require_dependency` in `zeitwerk` mode support arguments that respond
53
+ to `to_path` for better backwards compatibility.
54
+
55
+ *Xavier Noria*
56
+
57
+ * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
58
+
59
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
60
+ to make log level local to Ruby Fibers in addition to Threads.
61
+
62
+ Example:
63
+
64
+ logger = ActiveSupport::Logger.new(STDOUT)
65
+ logger.level = 1
66
+ p "Main is debug? #{logger.debug?}"
67
+
68
+ Fiber.new {
69
+ logger.local_level = 0
70
+ p "Thread is debug? #{logger.debug?}"
71
+ }.resume
72
+
73
+ p "Main is debug? #{logger.debug?}"
74
+
75
+ Before:
76
+
77
+ Main is debug? false
78
+ Thread is debug? true
79
+ Main is debug? true
80
+
81
+ After:
82
+
83
+ Main is debug? false
84
+ Thread is debug? true
85
+ Main is debug? false
86
+
87
+ *Alexander Varnin*
88
+
89
+ * Do not delegate missing `marshal_dump` and `_dump` methods via the
90
+ `delegate_missing_to` extension. This avoids unintentionally adding instance
91
+ variables when calling `Marshal.dump(object)`, should the delegation target of
92
+ `object` be a method which would otherwise add them. Fixes #36522.
93
+
94
+ *Aaron Lipman*
95
+
96
+
97
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
98
+
99
+ * `truncate` would return the original string if it was too short to be truncated
100
+ and a frozen string if it were long enough to be truncated. Now truncate will
101
+ consistently return an unfrozen string regardless. This behavior is consistent
102
+ with `gsub` and `strip`.
103
+
104
+ Before:
105
+
106
+ 'foobar'.truncate(5).frozen?
107
+ # => true
108
+ 'foobar'.truncate(6).frozen?
109
+ # => false
110
+
111
+ After:
112
+
113
+ 'foobar'.truncate(5).frozen?
114
+ # => false
115
+ 'foobar'.truncate(6).frozen?
116
+ # => false
117
+
118
+ *Jordan Thomas*
119
+
120
+
121
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
122
+
123
+ * Introduce `ActiveSupport::ActionableError`.
124
+
125
+ Actionable errors let's you dispatch actions from Rails' error pages. This
126
+ can help you save time if you have a clear action for the resolution of
127
+ common development errors.
128
+
129
+ The de-facto example are pending migrations. Every time pending migrations
130
+ are found, a middleware raises an error. With actionable errors, you can
131
+ run the migrations right from the error page. Other examples include Rails
132
+ plugins that need to run a rake task to setup themselves. They can now
133
+ raise actionable errors to run the setup straight from the error pages.
134
+
135
+ Here is how to define an actionable error:
136
+
137
+ ```ruby
138
+ class PendingMigrationError < MigrationError #:nodoc:
139
+ include ActiveSupport::ActionableError
140
+
141
+ action "Run pending migrations" do
142
+ ActiveRecord::Tasks::DatabaseTasks.migrate
143
+ end
144
+ end
145
+ ```
146
+
147
+ To make an error actionable, include the `ActiveSupport::ActionableError`
148
+ module and invoke the `action` class macro to define the action. An action
149
+ needs a name and a procedure to execute. The name is shown as the name of a
150
+ button on the error pages. Once clicked, it will invoke the given
151
+ procedure.
152
+
153
+ *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
154
+
155
+ * Preserve `html_safe?` status on `ActiveSupport::SafeBuffer#*`.
156
+
157
+ Before:
158
+
159
+ ("<br />".html_safe * 2).html_safe? #=> nil
160
+
161
+ After:
162
+
163
+ ("<br />".html_safe * 2).html_safe? #=> true
164
+
165
+ *Ryo Nakamura*
166
+
167
+ * Calling test methods with `with_info_handler` method to allow minitest-hooks
168
+ plugin to work.
169
+
170
+ *Mauri Mustonen*
171
+
172
+ * The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
173
+ longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
174
+ anyway). Experience shows introspection does not have many use cases, and
175
+ troubleshooting is done by logging. With this design trade-off we are able
176
+ to use even less memory in all environments.
177
+
178
+ *Xavier Noria*
179
+
180
+ * Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
181
+ and hence uses less memory when `config.cache_classes` is `true`, a standard
182
+ setup in production.
183
+
184
+ *Xavier Noria*
185
+
186
+ * In `:zeitwerk` mode, eager load directories in engines and applications only
187
+ if present in their respective `config.eager_load_paths`.
188
+
189
+ A common use case for this is adding `lib` to `config.autoload_paths`, but
190
+ not to `config.eager_load_paths`. In that configuration, for example, files
191
+ in the `lib` directory should not be eager loaded.
192
+
193
+ *Xavier Noria*
194
+
195
+ * Fix bug in Range comparisons when comparing to an excluded-end Range
196
+
197
+ Before:
198
+
199
+ (1..10).cover?(1...11) # => false
200
+
201
+ After:
202
+
203
+ (1..10).cover?(1...11) # => true
204
+
205
+ With the same change for `Range#include?` and `Range#===`.
206
+
207
+ *Owen Stephens*
208
+
209
+ * Use weak references in descendants tracker to allow anonymous subclasses to
210
+ be garbage collected.
211
+
212
+ *Edgars Beigarts*
213
+
214
+ * Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
215
+ passing a block optional. This will let users use
216
+ `ActiveSupport::Notifications` messaging features outside of
217
+ instrumentation.
218
+
219
+ *Ali Ibrahim*
220
+
221
+ * Fix `Time#advance` to work with dates before 1001-03-07
222
+
223
+ Before:
224
+
225
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
226
+
227
+ After
228
+
229
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
230
+
231
+ Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
232
+
233
+ *Andrew White*
234
+
235
+ * In Zeitwerk mode, engines are now managed by the `main` autoloader. Engines may reference application constants, if the application is reloaded and we do not reload engines, they won't use the reloaded application code.
236
+
237
+ *Xavier Noria*
238
+
239
+ * Add support for supplying `locale` to `transliterate` and `parameterize`.
240
+
241
+ I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
242
+
243
+ ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
244
+ "Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
245
+ ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
246
+
247
+ *Kaan Ozkan*, *Sharang Dashputre*
248
+
249
+ * Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
250
+
251
+ [ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
252
+
253
+ *DHH*
254
+
255
+ * Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding`, to create parity with
256
+ `Array#including` and `Enumerable#including`. Retained the old names as aliases.
257
+
258
+ *DHH*
259
+
260
+ * Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
261
+
262
+ [ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
263
+ post.authors.including(Current.person) # => All the authors plus the current person!
264
+
265
+ *DHH*
266
+
267
+
268
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
269
+
270
+ * No changes.
271
+
272
+
273
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
274
+
275
+ * New autoloading based on [Zeitwerk](https://github.com/fxn/zeitwerk).
276
+
277
+ *Xavier Noria*
278
+
279
+ * Revise `ActiveSupport::Notifications.unsubscribe` to correctly handle Regex or other multiple-pattern subscribers.
280
+
281
+ *Zach Kemp*
282
+
283
+ * Add `before_reset` callback to `CurrentAttributes` and define `after_reset` as an alias of `resets` for symmetry.
284
+
285
+ *Rosa Gutierrez*
286
+
287
+ * Remove the `` Kernel#` `` override that suppresses ENOENT and accidentally returns nil on Unix systems.
288
+
289
+ *Akinori Musha*
290
+
291
+ * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
292
+
293
+ `assoc` can now be called with either a string or a symbol.
294
+
295
+ *Stefan Schüßler*
296
+
297
+ * Add `Hash#deep_transform_values`, and `Hash#deep_transform_values!`.
298
+
299
+ *Guillermo Iguaran*
300
+
301
+
1
302
  ## Rails 6.0.0.beta1 (January 18, 2019) ##
2
303
 
3
304
  * Remove deprecated `Module#reachable?` method.
@@ -205,7 +506,7 @@
205
506
 
206
507
  *Kasper Timm Hansen*
207
508
 
208
- * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
509
+ * Fix bug where `ActiveSupport::TimeZone.all` would fail when tzinfo data for
209
510
  any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
210
511
 
211
512
  *Dominik Sander*
@@ -5,6 +5,7 @@ extensions that were found useful for the Rails framework. These additions
5
5
  reside in this package so they can be loaded as needed in Ruby projects
6
6
  outside of Rails.
7
7
 
8
+ You can read more about the extensions in the {Active Support Core Extensions}[https://edgeguides.rubyonrails.org/active_support_core_extensions.html] guide.
8
9
 
9
10
  == Download and installation
10
11
 
@@ -28,7 +29,7 @@ Active Support is released under the MIT license:
28
29
 
29
30
  API documentation is at:
30
31
 
31
- * http://api.rubyonrails.org
32
+ * https://api.rubyonrails.org
32
33
 
33
34
  Bug reports for the Ruby on Rails project can be filed here:
34
35
 
@@ -34,6 +34,7 @@ module ActiveSupport
34
34
  extend ActiveSupport::Autoload
35
35
 
36
36
  autoload :Concern
37
+ autoload :ActionableError
37
38
  autoload :CurrentAttributes
38
39
  autoload :Dependencies
39
40
  autoload :DescendantsTracker
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveSupport
4
+ # Actionable errors let's you define actions to resolve an error.
5
+ #
6
+ # To make an error actionable, include the <tt>ActiveSupport::ActionableError</tt>
7
+ # module and invoke the +action+ class macro to define the action. An action
8
+ # needs a name and a block to execute.
9
+ module ActionableError
10
+ extend Concern
11
+
12
+ class NonActionable < StandardError; end
13
+
14
+ included do
15
+ class_attribute :_actions, default: {}
16
+ end
17
+
18
+ def self.actions(error) # :nodoc:
19
+ case error
20
+ when ActionableError, -> it { Class === it && it < ActionableError }
21
+ error._actions
22
+ else
23
+ {}
24
+ end
25
+ end
26
+
27
+ def self.dispatch(error, name) # :nodoc:
28
+ actions(error).fetch(name).call
29
+ rescue KeyError
30
+ raise NonActionable, "Cannot find action \"#{name}\""
31
+ end
32
+
33
+ module ClassMethods
34
+ # Defines an action that can resolve the error.
35
+ #
36
+ # class PendingMigrationError < MigrationError
37
+ # include ActiveSupport::ActionableError
38
+ #
39
+ # action "Run pending migrations" do
40
+ # ActiveRecord::Tasks::DatabaseTasks.migrate
41
+ # end
42
+ # end
43
+ def action(name, &block)
44
+ _actions[name] = block
45
+ end
46
+ end
47
+ end
48
+ end
@@ -122,7 +122,11 @@ module ActiveSupport
122
122
  end
123
123
 
124
124
  def noise(backtrace)
125
- backtrace - silence(backtrace)
125
+ backtrace.select do |line|
126
+ @silencers.any? do |s|
127
+ s.call(line)
128
+ end
129
+ end
126
130
  end
127
131
  end
128
132
  end
@@ -492,7 +492,7 @@ module ActiveSupport
492
492
  #
493
493
  # Options are passed to the underlying cache implementation.
494
494
  #
495
- # All implementations may not support this method.
495
+ # Some implementations may not support this method.
496
496
  def delete_matched(matcher, options = nil)
497
497
  raise NotImplementedError.new("#{self.class.name} does not support delete_matched")
498
498
  end
@@ -501,7 +501,7 @@ module ActiveSupport
501
501
  #
502
502
  # Options are passed to the underlying cache implementation.
503
503
  #
504
- # All implementations may not support this method.
504
+ # Some implementations may not support this method.
505
505
  def increment(name, amount = 1, options = nil)
506
506
  raise NotImplementedError.new("#{self.class.name} does not support increment")
507
507
  end
@@ -510,7 +510,7 @@ module ActiveSupport
510
510
  #
511
511
  # Options are passed to the underlying cache implementation.
512
512
  #
513
- # All implementations may not support this method.
513
+ # Some implementations may not support this method.
514
514
  def decrement(name, amount = 1, options = nil)
515
515
  raise NotImplementedError.new("#{self.class.name} does not support decrement")
516
516
  end
@@ -519,7 +519,7 @@ module ActiveSupport
519
519
  #
520
520
  # Options are passed to the underlying cache implementation.
521
521
  #
522
- # All implementations may not support this method.
522
+ # Some implementations may not support this method.
523
523
  def cleanup(options = nil)
524
524
  raise NotImplementedError.new("#{self.class.name} does not support cleanup")
525
525
  end
@@ -529,7 +529,7 @@ module ActiveSupport
529
529
  #
530
530
  # The options hash is passed to the underlying cache implementation.
531
531
  #
532
- # All implementations may not support this method.
532
+ # Some implementations may not support this method.
533
533
  def clear(options = nil)
534
534
  raise NotImplementedError.new("#{self.class.name} does not support clear")
535
535
  end