2019-04-09 05:06:44 -04:00
* The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
anyway). Experience shows introspection does not have many use cases, and
troubleshooting is done by logging. With this design trade-off we are able
to use even less memory in all environments.
*Xavier Noria*
2019-04-07 06:30:34 -04:00
* Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
and hence uses less memory when `config.cache_classes` is `true` , a standard
setup in production.
*Xavier Noria*
2019-03-30 03:38:41 -04:00
* In `:zeitwerk` mode, eager load directories in engines and applications only
if present in their respective `config.eager_load_paths` .
A common use case for this is adding `lib` to `config.autoload_paths` , but
not to `config.eager_load_paths` . In that configuration, for example, files
in the `lib` directory should not be eager loaded.
*Xavier Noria*
2019-03-27 20:57:05 -04:00
* Fix bug in Range comparisons when comparing to an excluded-end Range
Before:
2019-03-30 19:38:37 -04:00
(1..10).cover?(1...11) # => false
2019-03-27 20:57:05 -04:00
After:
2019-03-30 19:38:37 -04:00
(1..10).cover?(1...11) # => true
2019-03-27 20:57:05 -04:00
With the same change for `Range#include?` and `Range#===` .
2019-03-30 19:38:37 -04:00
*Owen Stephens*
2019-03-27 20:57:05 -04:00
2017-12-14 05:37:51 -05:00
* Use weak references in descendants tracker to allow anonymous subclasses to
be garbage collected.
*Edgars Beigarts*
2019-03-22 15:13:58 -04:00
* Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
2019-03-22 11:17:33 -04:00
passing a block optional. This will let users use
`ActiveSupport::Notifications` messaging features outside of
instrumentation.
*Ali Ibrahim*
2019-03-18 12:51:33 -04:00
* Fix `Time#advance` to work with dates before 1001-03-07
Before:
2019-03-30 19:38:37 -04:00
2019-03-18 12:51:33 -04:00
Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
2019-03-30 19:38:37 -04:00
2019-03-18 12:51:33 -04:00
After
2019-03-30 19:38:37 -04:00
2019-03-18 12:51:33 -04:00
Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
*Andrew White*
2019-03-15 17:50:04 -04:00
* 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.
*Xavier Noria*
2019-03-12 04:50:38 -04:00
* Add support for supplying `locale` to `transliterate` and `parameterize` .
2019-03-11 18:03:54 -04:00
I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
2019-03-30 19:38:37 -04:00
ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
"Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
2019-03-11 18:03:54 -04:00
*Kaan Ozkan* , *Sharang Dashputre*
2019-03-30 20:45:44 -04:00
* Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
2019-03-05 19:04:41 -05:00
2019-03-30 19:38:37 -04:00
[ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
2019-03-05 19:04:41 -05:00
*DHH*
2019-03-30 19:38:37 -04:00
* Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding` , to create parity with
`Array#including` and `Enumerable#including` . Retained the old names as aliases.
2019-03-05 19:04:41 -05:00
*DHH*
2019-03-30 19:38:37 -04:00
* Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
2019-03-12 04:50:38 -04:00
2019-03-30 19:38:37 -04:00
[ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
post.authors.including(Current.person) # => All the authors plus the current person!
2019-03-05 19:04:41 -05:00
*DHH*
2019-03-12 04:50:38 -04:00
2019-03-11 11:58:15 -04:00
## Rails 6.0.0.beta3 (March 11, 2019) ##
* No changes.
2019-02-25 17:45:04 -05:00
## Rails 6.0.0.beta2 (February 25, 2019) ##
2019-02-14 03:00:33 -05:00
* New autoloading based on [Zeitwerk ](https://github.com/fxn/zeitwerk ).
*Xavier Noria*
2019-02-07 14:58:50 -05:00
* Revise `ActiveSupport::Notifications.unsubscribe` to correctly handle Regex or other multiple-pattern subscribers.
*Zach Kemp*
2019-01-27 05:18:40 -05:00
* Add `before_reset` callback to `CurrentAttributes` and define `after_reset` as an alias of `resets` for symmetry.
*Rosa Gutierrez*
2019-02-04 17:41:40 -05:00
* Remove the `` Kernel#` `` override that suppresses ENOENT and accidentally returns nil on Unix systems.
2017-11-28 03:44:12 -05:00
*Akinori Musha*
2019-01-29 05:49:23 -05:00
* Add `ActiveSupport::HashWithIndifferentAccess#assoc` .
`assoc` can now be called with either a string or a symbol.
*Stefan Schüßler*
2019-02-08 12:28:12 -05:00
* Add `Hash#deep_transform_values` , and `Hash#deep_transform_values!` .
*Guillermo Iguaran*
2019-03-12 04:50:38 -04:00
2019-01-18 15:42:12 -05:00
## Rails 6.0.0.beta1 (January 18, 2019) ##
2019-01-15 17:21:19 -05:00
* Remove deprecated `Module#reachable?` method.
*Rafael Mendonça França*
2019-01-15 17:02:22 -05:00
* Remove deprecated `#acronym_regex` method from `Inflections` .
*Rafael Mendonça França*
2019-01-07 14:13:45 -05:00
* Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
*Keenan Brock*
2018-12-13 13:08:49 -05:00
* Preserve key order passed to `ActiveSupport::CacheStore#fetch_multi` .
`fetch_multi(*names)` now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
*Gannon McGibbon*
2018-11-29 13:36:20 -05:00
* If the same block is `included` multiple times for a Concern, an exception is no longer raised.
*Mark J. Titorenko* , *Vlad Bokov*
2018-11-01 01:58:32 -04:00
* Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
would not act as alias for `#symbolize_keys` .
*Nick Weiland*
2018-10-28 14:44:16 -04:00
* Improve the logic that detects non-autoloaded constants.
*Jan Habermann* , *Xavier Noria*
2018-10-18 15:51:21 -04:00
* Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSuppport::Multibyte::Unicode#unpack_graphemes(string)`
in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)` , respectively.
*Francesco Rodríguez*
2018-10-15 02:29:56 -04:00
* Deprecate `ActiveSupport::Multibyte::Chars.consumes?` in favor of `String#is_utf8?` .
*Francesco Rodríguez*
2018-10-09 13:36:56 -04:00
* Fix duration being rounded to a full second.
```
time = DateTime.parse("2018-1-1")
time += 0.51.seconds
```
Will now correctly add 0.51 second and not 1 full second.
*Edouard Chin*
2018-10-12 11:40:29 -04:00
* Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSuppport::Multibyte::Chars#normalize`
in favor of `String#unicode_normalize`
*Francesco Rodríguez*
2018-10-08 04:57:18 -04:00
* Deprecate `ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase` in favor of
`String#downcase/upcase/swapcase` .
*Francesco Rodríguez*
2018-09-21 00:49:59 -04:00
* Add `ActiveSupport::ParameterFilter` .
*Yoshiyuki Kinjo*
2018-10-02 12:51:35 -04:00
* Rename `Module#parent` , `Module#parents` , and `Module#parent_name` to
`module_parent` , `module_parents` , and `module_parent_name` .
*Gannon McGibbon*
2018-10-01 18:00:18 -04:00
* Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence`
*Edouard Chin*
2018-06-03 19:42:07 -04:00
* Deprecate using negative limits in `String#first` and `String#last` .
*Gannon McGibbon* , *Eric Turner*
2018-09-28 04:28:30 -04:00
* Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
with symbol arguments
*Abraham Chan*
2018-09-27 20:50:21 -04:00
* Treat `#delete_prefix` , `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
Ensure safety of arguments for `#insert` , `#[]=` and `#replace` calls on `html_safe` Strings.
*Janosch Müller*
2018-09-11 19:33:59 -04:00
* Changed `ActiveSupport::TaggedLogging.new` to return a new logger instance instead
of mutating the one received as parameter.
2017-01-24 07:48:43 -05:00
*Thierry Joyal*
2018-09-07 05:09:46 -04:00
* Define `unfreeze_time` as an alias of `travel_back` in `ActiveSupport::Testing::TimeHelpers` .
The alias is provided for symmetry with `freeze_time` .
*Ryan Davidson*
2018-09-08 03:50:05 -04:00
* Add support for tracing constant autoloads. Just throw
ActiveSupport::Dependencies.logger = Rails.logger
ActiveSupport::Dependencies.verbose = true
in an initializer.
*Xavier Noria*
2018-09-06 18:56:31 -04:00
* Maintain `html_safe?` on html_safe strings when sliced.
2018-09-06 16:17:18 -04:00
string = "< div > test< / div > ".html_safe
string[-1..1].html_safe? # => true
2018-09-06 18:56:31 -04:00
*Elom Gomez* , *Yumin Wong*
2018-09-06 16:17:18 -04:00
Add `Array#extract!`
The method removes and returns the elements for which the block returns a true value.
If no block is given, an Enumerator is returned instead.
```
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
numbers # => [0, 2, 4, 6, 8]
```
2018-06-14 15:24:45 -04:00
* Add `Array#extract!` .
The method removes and returns the elements for which the block returns a true value.
If no block is given, an Enumerator is returned instead.
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
numbers # => [0, 2, 4, 6, 8]
*bogdanvlviv*
2018-08-05 13:11:22 -04:00
* Support not to cache `nil` for `ActiveSupport::Cache#fetch` .
cache.fetch('bar', skip_nil: true) { nil }
cache.exist?('bar') # => false
*Martin Hong*
2018-07-26 17:54:47 -04:00
* Add "event object" support to the notification system.
2018-07-26 17:56:25 -04:00
Before this change, end users were forced to create hand made artisanal
2018-07-26 17:54:47 -04:00
event objects on their own, like this:
ActiveSupport::Notifications.subscribe('wait') do |*args|
@event = ActiveSupport::Notifications::Event.new(*args)
end
2018-08-05 13:11:22 -04:00
2018-07-26 17:54:47 -04:00
ActiveSupport::Notifications.instrument('wait') do
sleep 1
end
2018-08-05 13:11:22 -04:00
2018-07-26 17:54:47 -04:00
@event .duration # => 1000.138
After this change, if the block passed to `subscribe` only takes one
parameter, the framework will yield an event object to the block. Now
end users are no longer required to make their own:
ActiveSupport::Notifications.subscribe('wait') do |event|
@event = event
end
2018-08-05 13:11:22 -04:00
2018-07-26 17:54:47 -04:00
ActiveSupport::Notifications.instrument('wait') do
sleep 1
end
2018-08-05 13:11:22 -04:00
2018-07-26 17:54:47 -04:00
p @event .allocations # => 7
p @event .cpu_time # => 0.256
p @event .idle_time # => 1003.2399
Now you can enjoy event objects without making them yourself. Neat!
*Aaron "t.lo" Patterson*
2018-09-06 18:56:31 -04:00
* Add cpu_time, idle_time, and allocations to Event.
2018-07-26 12:55:59 -04:00
*Eileen M. Uchitelle* , *Aaron Patterson*
2018-07-01 06:42:18 -04:00
* RedisCacheStore: support key expiry in increment/decrement.
Pass `:expires_in` to `#increment` and `#decrement` to set a Redis EXPIRE on the key.
If the key is already set to expire, RedisCacheStore won't extend its expiry.
Rails.cache.increment("some_key", 1, expires_in: 2.minutes)
*Jason Lee*
2018-09-06 18:56:31 -04:00
* Allow `Range#===` and `Range#cover?` on Range.
2018-05-21 17:53:38 -04:00
`Range#cover?` can now accept a range argument like `Range#include?` and
`Range#===` . `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
into a new file, with these two methods.
*Requiring active_support/core_ext/range/include_range is now deprecated.*
*Use `require "active_support/core_ext/range/compare_range"` instead.*
*utilum*
2018-05-21 11:44:13 -04:00
* Add `index_with` to Enumerable.
Allows creating a hash from an enumerable with the value from a passed block
or a default argument.
%i( title body ).index_with { |attr| post.public_send(attr) }
# => { title: "hey", body: "what's up?" }
%i( title body ).index_with(nil)
# => { title: nil, body: nil }
2018-05-31 08:44:23 -04:00
Closely linked with `index_by` , which creates a hash where the keys are extracted from a block.
2018-05-21 11:44:13 -04:00
*Kasper Timm Hansen*
2019-03-13 06:41:40 -04:00
* Fix bug where `ActiveSupport::TimeZone.all` would fail when tzinfo data for
2018-04-21 19:35:36 -04:00
any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
2018-04-17 16:03:02 -04:00
*Dominik Sander*
2018-04-17 16:17:25 -04:00
* Redis cache store: `delete_matched` no longer blocks the Redis server.
(Switches from evaled Lua to a batched SCAN + DEL loop.)
*Gleb Mazovetskiy*
2018-04-12 01:54:20 -04:00
* Fix bug where `ActiveSupport::Cache` will massively inflate the storage
size when compression is enabled (which is true by default). This patch
does not attempt to repair existing data: please manually flush the cache
to clear out the problematic entries.
*Godfrey Chan*
2018-08-09 14:04:24 -04:00
* Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
2018-03-06 19:41:46 -05:00
URI.unescape("\xe3\x83\x90") # => "バ"
URI.unescape("%E3%83%90") # => "バ"
URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
*Ashe Connor* , *Aaron Patterson*
2018-03-06 23:42:49 -05:00
* Add `before?` and `after?` methods to `Date` , `DateTime` ,
`Time` , and `TimeWithZone` .
*Nick Holden*
2018-03-04 21:29:54 -05:00
* `ActiveSupport::Inflector#ordinal` and `ActiveSupport::Inflector#ordinalize` now support
translations through I18n.
# locale/fr.rb
{
fr: {
number: {
nth: {
ordinals: lambda do |_key, number:, **_options|
if number.to_i.abs == 1
'er'
else
'e'
end
end,
ordinalized: lambda do |_key, number:, **_options|
"#{number}#{ActiveSupport::Inflector.ordinal(number)}"
end
}
}
}
}
*Christian Blais*
2018-02-27 17:05:46 -05:00
* Add `:private` option to ActiveSupport's `Module#delegate`
in order to delegate methods as private:
2018-02-20 04:38:19 -05:00
class User < ActiveRecord::Base
has_one :profile
delegate :date_of_birth, to: :profile, private: true
def age
Date.today.year - date_of_birth.year
end
end
# User.new.age # => 29
# User.new.date_of_birth
# => NoMethodError: private method `date_of_birth' called for #< User:0x00000008221340 >
*Tomas Valent*
2016-12-09 13:34:35 -05:00
* `String#truncate_bytes` to truncate a string to a maximum bytesize without
breaking multibyte characters or grapheme clusters like 👩👩👦👦.
*Jeremy Daer*
2018-02-17 18:23:17 -05:00
* `String#strip_heredoc` preserves frozenness.
"foo".freeze.strip_heredoc.frozen? # => true
Fixes that frozen string literals would inadvertently become unfrozen:
# frozen_string_literal: true
foo = < < -MSG.strip_heredoc
la la la
MSG
foo.frozen? # => false !??
*Jeremy Daer*
2018-12-19 15:09:34 -05:00
* Rails 6 requires Ruby 2.5.0 or newer.
2018-02-17 16:02:18 -05:00
2018-12-19 15:09:34 -05:00
*Jeremy Daer* , *Kasper Timm Hansen*
2018-02-17 16:02:18 -05:00
2018-03-11 16:22:20 -04:00
* Adds parallel testing to Rails.
2018-02-17 16:02:18 -05:00
Parallelize your test suite with forked processes or threads.
*Eileen M. Uchitelle* , *Aaron Patterson*
2017-12-20 16:59:41 -05:00
2017-12-14 10:05:13 -05:00
2018-01-30 18:51:17 -05:00
Please check [5-2-stable ](https://github.com/rails/rails/blob/5-2-stable/activesupport/CHANGELOG.md ) for previous changes.