activesupport 6.0.0.beta3 → 6.0.2.rc2

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +282 -3
  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/memory_store.rb +2 -0
  9. data/lib/active_support/cache/redis_cache_store.rb +9 -6
  10. data/lib/active_support/concern.rb +24 -1
  11. data/lib/active_support/configurable.rb +3 -3
  12. data/lib/active_support/core_ext/array/access.rb +18 -6
  13. data/lib/active_support/core_ext/class/attribute.rb +10 -15
  14. data/lib/active_support/core_ext/date_and_time/calculations.rb +0 -30
  15. data/lib/active_support/core_ext/digest.rb +3 -0
  16. data/lib/active_support/core_ext/enumerable.rb +24 -4
  17. data/lib/active_support/core_ext/hash/deep_transform_values.rb +2 -2
  18. data/lib/active_support/core_ext/hash/except.rb +1 -1
  19. data/lib/active_support/core_ext/module/attribute_accessors.rb +5 -5
  20. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +5 -5
  21. data/lib/active_support/core_ext/module/delegation.rb +6 -0
  22. data/lib/active_support/core_ext/object/duplicable.rb +7 -117
  23. data/lib/active_support/core_ext/range/compare_range.rb +27 -12
  24. data/lib/active_support/core_ext/range/include_time_with_zone.rb +2 -2
  25. data/lib/active_support/core_ext/string/filters.rb +1 -1
  26. data/lib/active_support/core_ext/string/inflections.rb +7 -2
  27. data/lib/active_support/core_ext/string/output_safety.rb +51 -4
  28. data/lib/active_support/core_ext/time/calculations.rb +31 -2
  29. data/lib/active_support/dependencies.rb +41 -5
  30. data/lib/active_support/dependencies/zeitwerk_integration.rb +44 -21
  31. data/lib/active_support/deprecation/method_wrappers.rb +7 -18
  32. data/lib/active_support/deprecation/proxy_wrappers.rb +24 -3
  33. data/lib/active_support/descendants_tracker.rb +52 -6
  34. data/lib/active_support/duration.rb +2 -3
  35. data/lib/active_support/evented_file_update_checker.rb +14 -2
  36. data/lib/active_support/gem_version.rb +2 -2
  37. data/lib/active_support/hash_with_indifferent_access.rb +6 -3
  38. data/lib/active_support/i18n_railtie.rb +6 -1
  39. data/lib/active_support/inflector/transliterate.rb +43 -14
  40. data/lib/active_support/logger_thread_safe_level.rb +2 -1
  41. data/lib/active_support/notifications/fanout.rb +2 -2
  42. data/lib/active_support/notifications/instrumenter.rb +12 -11
  43. data/lib/active_support/ordered_hash.rb +1 -1
  44. data/lib/active_support/ordered_options.rb +1 -1
  45. data/lib/active_support/parameter_filter.rb +6 -1
  46. data/lib/active_support/security_utils.rb +1 -1
  47. data/lib/active_support/subscriber.rb +55 -6
  48. data/lib/active_support/testing/parallelization.rb +21 -2
  49. metadata +13 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99b9851bbeeac26a9d5991ab86865b1475b44a197941819902c8b8aa298319ff
4
- data.tar.gz: d2abae2569905e69d2dbf9c778f6f6407d4f3ffb7fe8f3f0de071c9bafcc5007
3
+ metadata.gz: 5a401c8a26a884dfb9b910b9fe1c49702c2d5709f41d93d84f753689b9169f8d
4
+ data.tar.gz: 341f5067a5b84020dddb1765b12f03ed6e029dbb3595812fe761f9b44f62845c
5
5
  SHA512:
6
- metadata.gz: 66ced4ae57566a0063f24c7b1c4a778bbb56897414a88ca7e1f8736cc7ba1b33deb549a75a556ba0ac1cbec17cf326e57f3f5bde9a04c53c3ef0059e2bb81d74
7
- data.tar.gz: 29783c4224cc61b14fdc1f227d30a090edaed71a5f5535221ce091e82a398e80f9beb103d1353581bb19fdc05e855c7e00a5bba898364043c017f74dbbc06d40
6
+ metadata.gz: ad9e83272d901afd1ea11d01351b797424ceb281d8ae60dbb8a8a14d58103ef9333df7597dc9ade84686b236aaede84d8e9503b11660d1d6d15e9988dd41b1f0
7
+ data.tar.gz: 63a63bfd1a50f5b915949726d1a4f4c30595d05968bc5e7942dc65b40fb8d4039f6bc8f89200e07c2d16d38257355b315b26ef29d7a30cd60368f0cb539d9d2d
@@ -1,3 +1,281 @@
1
+ ## Rails 6.0.2.rc2 (December 09, 2019) ##
2
+
3
+ * Eager load translations during initialization.
4
+
5
+ *Diego Plentz*
6
+
7
+ * Use per-thread CPU time clock on `ActiveSupport::Notifications`.
8
+
9
+ *George Claghorn*
10
+
11
+
12
+ ## Rails 6.0.1 (November 5, 2019) ##
13
+
14
+ * `ActiveSupport::SafeBuffer` supports `Enumerator` methods.
15
+
16
+ *Shugo Maeda*
17
+
18
+ * The Redis cache store fails gracefully when the server returns a "max number
19
+ of clients reached" error.
20
+
21
+ *Brandon Medenwald*
22
+
23
+ * Fixed that mutating a value returned by a memory cache store would
24
+ unexpectedly change the cached value.
25
+
26
+ *Jonathan Hyman*
27
+
28
+ * The default inflectors in `zeitwerk` mode support overrides:
29
+
30
+ ```ruby
31
+ # config/initializers/zeitwerk.rb
32
+ Rails.autoloaders.each do |autoloader|
33
+ autoloader.inflector.inflect(
34
+ "html_parser" => "HTMLParser",
35
+ "ssl_error" => "SSLError"
36
+ )
37
+ end
38
+ ```
39
+
40
+ 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.
41
+
42
+ 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.
43
+
44
+ *Xavier Noria*
45
+
46
+ * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
47
+ and endless range targets.
48
+
49
+ *Allen Hsu*, *Andrew Hodgkinson*
50
+
51
+ * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
52
+
53
+ *Iain Beeston*
54
+
55
+
56
+ ## Rails 6.0.0 (August 16, 2019) ##
57
+
58
+ * Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
59
+ better backwards compatibility.
60
+
61
+ *Xavier Noria*
62
+
63
+ * Let `require_dependency` in `zeitwerk` mode support arguments that respond
64
+ to `to_path` for better backwards compatibility.
65
+
66
+ *Xavier Noria*
67
+
68
+ * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
69
+
70
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
71
+ to make log level local to Ruby Fibers in addition to Threads.
72
+
73
+ Example:
74
+
75
+ logger = ActiveSupport::Logger.new(STDOUT)
76
+ logger.level = 1
77
+ p "Main is debug? #{logger.debug?}"
78
+
79
+ Fiber.new {
80
+ logger.local_level = 0
81
+ p "Thread is debug? #{logger.debug?}"
82
+ }.resume
83
+
84
+ p "Main is debug? #{logger.debug?}"
85
+
86
+ Before:
87
+
88
+ Main is debug? false
89
+ Thread is debug? true
90
+ Main is debug? true
91
+
92
+ After:
93
+
94
+ Main is debug? false
95
+ Thread is debug? true
96
+ Main is debug? false
97
+
98
+ *Alexander Varnin*
99
+
100
+ * Do not delegate missing `marshal_dump` and `_dump` methods via the
101
+ `delegate_missing_to` extension. This avoids unintentionally adding instance
102
+ variables when calling `Marshal.dump(object)`, should the delegation target of
103
+ `object` be a method which would otherwise add them. Fixes #36522.
104
+
105
+ *Aaron Lipman*
106
+
107
+
108
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
109
+
110
+ * `truncate` would return the original string if it was too short to be truncated
111
+ and a frozen string if it were long enough to be truncated. Now truncate will
112
+ consistently return an unfrozen string regardless. This behavior is consistent
113
+ with `gsub` and `strip`.
114
+
115
+ Before:
116
+
117
+ 'foobar'.truncate(5).frozen?
118
+ # => true
119
+ 'foobar'.truncate(6).frozen?
120
+ # => false
121
+
122
+ After:
123
+
124
+ 'foobar'.truncate(5).frozen?
125
+ # => false
126
+ 'foobar'.truncate(6).frozen?
127
+ # => false
128
+
129
+ *Jordan Thomas*
130
+
131
+
132
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
133
+
134
+ * Introduce `ActiveSupport::ActionableError`.
135
+
136
+ Actionable errors let's you dispatch actions from Rails' error pages. This
137
+ can help you save time if you have a clear action for the resolution of
138
+ common development errors.
139
+
140
+ The de-facto example are pending migrations. Every time pending migrations
141
+ are found, a middleware raises an error. With actionable errors, you can
142
+ run the migrations right from the error page. Other examples include Rails
143
+ plugins that need to run a rake task to setup themselves. They can now
144
+ raise actionable errors to run the setup straight from the error pages.
145
+
146
+ Here is how to define an actionable error:
147
+
148
+ ```ruby
149
+ class PendingMigrationError < MigrationError #:nodoc:
150
+ include ActiveSupport::ActionableError
151
+
152
+ action "Run pending migrations" do
153
+ ActiveRecord::Tasks::DatabaseTasks.migrate
154
+ end
155
+ end
156
+ ```
157
+
158
+ To make an error actionable, include the `ActiveSupport::ActionableError`
159
+ module and invoke the `action` class macro to define the action. An action
160
+ needs a name and a procedure to execute. The name is shown as the name of a
161
+ button on the error pages. Once clicked, it will invoke the given
162
+ procedure.
163
+
164
+ *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
165
+
166
+ * Preserve `html_safe?` status on `ActiveSupport::SafeBuffer#*`.
167
+
168
+ Before:
169
+
170
+ ("<br />".html_safe * 2).html_safe? #=> nil
171
+
172
+ After:
173
+
174
+ ("<br />".html_safe * 2).html_safe? #=> true
175
+
176
+ *Ryo Nakamura*
177
+
178
+ * Calling test methods with `with_info_handler` method to allow minitest-hooks
179
+ plugin to work.
180
+
181
+ *Mauri Mustonen*
182
+
183
+ * The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
184
+ longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
185
+ anyway). Experience shows introspection does not have many use cases, and
186
+ troubleshooting is done by logging. With this design trade-off we are able
187
+ to use even less memory in all environments.
188
+
189
+ *Xavier Noria*
190
+
191
+ * Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
192
+ and hence uses less memory when `config.cache_classes` is `true`, a standard
193
+ setup in production.
194
+
195
+ *Xavier Noria*
196
+
197
+ * In `:zeitwerk` mode, eager load directories in engines and applications only
198
+ if present in their respective `config.eager_load_paths`.
199
+
200
+ A common use case for this is adding `lib` to `config.autoload_paths`, but
201
+ not to `config.eager_load_paths`. In that configuration, for example, files
202
+ in the `lib` directory should not be eager loaded.
203
+
204
+ *Xavier Noria*
205
+
206
+ * Fix bug in Range comparisons when comparing to an excluded-end Range
207
+
208
+ Before:
209
+
210
+ (1..10).cover?(1...11) # => false
211
+
212
+ After:
213
+
214
+ (1..10).cover?(1...11) # => true
215
+
216
+ With the same change for `Range#include?` and `Range#===`.
217
+
218
+ *Owen Stephens*
219
+
220
+ * Use weak references in descendants tracker to allow anonymous subclasses to
221
+ be garbage collected.
222
+
223
+ *Edgars Beigarts*
224
+
225
+ * Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
226
+ passing a block optional. This will let users use
227
+ `ActiveSupport::Notifications` messaging features outside of
228
+ instrumentation.
229
+
230
+ *Ali Ibrahim*
231
+
232
+ * Fix `Time#advance` to work with dates before 1001-03-07
233
+
234
+ Before:
235
+
236
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
237
+
238
+ After
239
+
240
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
241
+
242
+ Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
243
+
244
+ *Andrew White*
245
+
246
+ * 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.
247
+
248
+ *Xavier Noria*
249
+
250
+ * Add support for supplying `locale` to `transliterate` and `parameterize`.
251
+
252
+ I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
253
+
254
+ ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
255
+ "Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
256
+ ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
257
+
258
+ *Kaan Ozkan*, *Sharang Dashputre*
259
+
260
+ * Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
261
+
262
+ [ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
263
+
264
+ *DHH*
265
+
266
+ * Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding`, to create parity with
267
+ `Array#including` and `Enumerable#including`. Retained the old names as aliases.
268
+
269
+ *DHH*
270
+
271
+ * Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
272
+
273
+ [ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
274
+ post.authors.including(Current.person) # => All the authors plus the current person!
275
+
276
+ *DHH*
277
+
278
+
1
279
  ## Rails 6.0.0.beta3 (March 11, 2019) ##
2
280
 
3
281
  * No changes.
@@ -31,6 +309,7 @@
31
309
 
32
310
  *Guillermo Iguaran*
33
311
 
312
+
34
313
  ## Rails 6.0.0.beta1 (January 18, 2019) ##
35
314
 
36
315
  * Remove deprecated `Module#reachable?` method.
@@ -64,7 +343,7 @@
64
343
 
65
344
  *Jan Habermann*, *Xavier Noria*
66
345
 
67
- * Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSuppport::Multibyte::Unicode#unpack_graphemes(string)`
346
+ * Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSupport::Multibyte::Unicode#unpack_graphemes(string)`
68
347
  in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
69
348
 
70
349
  *Francesco Rodríguez*
@@ -82,7 +361,7 @@
82
361
 
83
362
  *Edouard Chin*
84
363
 
85
- * Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSuppport::Multibyte::Chars#normalize`
364
+ * Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSupport::Multibyte::Chars#normalize`
86
365
  in favor of `String#unicode_normalize`
87
366
 
88
367
  *Francesco Rodríguez*
@@ -238,7 +517,7 @@
238
517
 
239
518
  *Kasper Timm Hansen*
240
519
 
241
- * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
520
+ * Fix bug where `ActiveSupport::TimeZone.all` would fail when tzinfo data for
242
521
  any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
243
522
 
244
523
  *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