Commit Graph

857 Commits

Author SHA1 Message Date
Rafael Mendonça França
a7faef6869
Remove deprecated ActiveSupport::Notifications::Instrumenter#end= 2020-10-30 00:26:03 +00:00
Rafael Mendonça França
6cbc7842f0
Deprecate ActiveSupport::Multibyte::Unicode.default_normalization_form 2020-10-30 00:26:03 +00:00
Rafael Mendonça França
2c6f5c0b8a
Remove deprecated methods in ActiveSupport::Multibyte::Unicode 2020-10-30 00:26:02 +00:00
Rafael Mendonça França
8f14d5ad4b
Remove deprecated ActiveSupport::Multibyte::Chars#consumes? and ActiveSupport::Multibyte::Chars#normalize 2020-10-30 00:26:01 +00:00
Rafael Mendonça França
6a4151f026
Remove deprecated file active_support/core_ext/range/include_range 2020-10-30 00:25:59 +00:00
Rafael Mendonça França
96a0cb6938
Remove deprecated file active_support/core_ext/hash/transform_values 2020-10-30 00:25:58 +00:00
Rafael Mendonça França
36eebfe184
Remove deprecated file active_support/core_ext/hash/compact 2020-10-30 00:25:57 +00:00
Rafael Mendonça França
14cfb37083
Remove deprecated file active_support/core_ext/array/prepend_and_append 2020-10-30 00:25:56 +00:00
Rafael Mendonça França
959af4bfcb
Remove deprecated file active_support/core_ext/numeric/inquiry 2020-10-30 00:25:54 +00:00
Rafael Mendonça França
b8a8a66993
Remove deprecated file active_support/core_ext/module/reachable 2020-10-30 00:25:53 +00:00
Rafael Mendonça França
167b4153ca
Remove deprecated Module#parent_name, Module#parent and `Module#parents 2020-10-30 00:25:52 +00:00
Rafael Mendonça França
e84af03914
Remove deprecated ActiveSupport::LoggerThreadSafeLevel#after_initialize 2020-10-30 00:25:51 +00:00
Rafael Mendonça França
8d1ade40dd
Remove deprecated LoggerSilence constant 2020-10-30 00:25:50 +00:00
Rafael Mendonça França
4bd56f4428
Remove deprecated fallback to I18n.default_local when config.i18n.fallbacks is empty 2020-10-30 00:25:50 +00:00
Eugene Kenny
a03a2c4188 Improve use_sha1_digests deprecation message
We now provide the full setting that maintains the existing behaviour.
2020-10-29 18:46:21 +00:00
ojab
1edc61dff0
Remove keys from local_cache in RedisCacheStore#delete_matched
Fixes #38627
2020-10-27 17:03:22 +00:00
Nate Matykiewicz
5017b92362 Speed up ActiveSupport::SecurityUtils.fixed_length_secure_compare
by using `OpenSSL.fixed_length_secure_compare`, if available.
2020-10-22 00:03:19 -05:00
Sam Bostock
e79364610c
Fallback to $MEMCACHE_SERVERS if no servers given
By default, Dalli has two fallbacks if no server addresses are given:

- $MEMCACHE_SERVERS
- "127.0.0.1:11211"

However, MemCacheStore does its own check for addresses, and falls back
to "localhost:11211" if none are present.

This can lead to bugs in migrations from the deprecated :dalli_store
(provided by the Dalli) to :mem_cache_store:

```diff
-config.cache_store = :dalli_store     # could be implicitly relying on $MEMCACHE_SERVERS
+config.cache_store = :mem_cache_store # ignores $MEMCACHE_SERVERS
```

By removing our own fallback and simply passing `nil` to Dalli::Client,
we get its fallback logic for free. Tests are added so we can detect if
this ever changes.
2020-10-20 23:50:52 -04:00
Ryuta Kamizono
8ecb0e22d7 Fix typo s/inherit_from/inherit_all/ [ci skip] 2020-09-24 14:42:01 +09:00
Adrianna Chang
387aa8c373 Subscriber.attach_to with inherit_all option 2020-09-22 08:48:46 -04:00
Michael Grosser
950bf54cda
Using write with unless_exist + expires_in should unlock after the given expires_in and not 5 minutes later (#40260)
Co-authored-by: Jye Lee <jyelee124@gmail.com>
Co-authored-by: Eugene Kenny <elkenny@gmail.com>
2020-09-20 21:07:35 +01:00
Jason York
a2535d9fe9 Rename prefix to in_* and update CHANGELOG 2020-08-26 09:36:03 -05:00
Rajesh Sharma
4a552c3ab9 Fix option not being passed with fetch_multi
In redis cache store, options to `fetch_multi` are passed correctly to
`write_multi` but not to `read_multi`. This causes cache always to be missed
when passing `namespace` option to it.
2020-07-26 08:34:30 +02:00
maxgurewitz
73ba6faa36 prevents redundant memcached compression
- Disables Dalli compression in MemCacheStore.
- Fixes issue where redundant compression in Dalli can cause values to
either be compressed twice, or compressed when they fall below the
specified compression threshold.
2020-07-25 12:59:39 -07:00
maxgurewitz
f1fb097a74 prevents raw redis and memcached compression
- Fixes issue where reads with raw: true using redis or memcached cache
store, will compress values on reads.
- Should speed up raw cache reads by preventing unnecessary cpu intensive
operation.
2020-07-24 11:56:43 -07:00
Jean Boussier
12f3f11f61 Use URI::DEFAULT_PARSER rather than instantiate a new one 2020-06-29 23:06:34 +02:00
Xavier Noria
f2902edc0c register the obsolescence of require_dependency in the CHANGELOG [ci skip] 2020-05-06 22:14:50 +02:00
Ryuta Kamizono
62a20c2a64 Add 3rd person aliases of Symbol#start_with? and Symbol#end_with?
This is the opposite direction of #39152.
2020-05-06 02:18:26 +09:00
Ryuta Kamizono
783a195cb7 Revert "Merge pull request #39152 from kamipo/deprecate_starts_ends_with"
This reverts commit 55e038cf17afcd6712d38d5a43d463bc7f7d098f, reversing
changes made to 8b900a7105eb4ae6957017a99a89e276186c287c.
2020-05-05 23:19:02 +09:00
Ryuta Kamizono
6a4395f466 Deprecate starts_with? and ends_with? for String core extensions
In the past, we sometimes hit missing `Symbol#start_with?` and
`Symbol#end_with?`.

63256bc5d7
a8e812964d

So I proposed `Symbol#start_with?` and `Symbol#end_with?` to allow duck
typing that methods for String and Symbol, then now it is available in
Ruby 2.7.

https://bugs.ruby-lang.org/issues/16348

Using `String#starts_with?` and `String#ends_with?` could not be gained
that conveniency, so it is preferable to not use these in the future.
2020-05-05 15:51:24 +09:00
Roman Kushnir
17e24f92f1 Add override of unary plus for ActiveSupport::Duration
```ruby
(+ 1.second).class
=> ActiveSupport::Duration
```

Fixes #39079.
2020-04-30 01:54:47 +02:00
Ryuta Kamizono
6f2126c760 Fixup CHANGELOGs [ci skip] 2020-04-15 21:23:24 +09:00
akinomaeni
cbc8057bbb Add subsec to ActiveSupport::TimeWithZone#inspect
Time.at(1498099140).in_time_zone.inspect
=> "Thu, 22 Jun 2017 02:39:00.000000000 UTC +00:00"
Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
=> "Thu, 22 Jun 2017 02:39:00.123456780 UTC +00:00"
Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
=> "Thu, 22 Jun 2017 02:39:00.333333333 UTC +00:00"
2020-04-11 10:22:23 +09:00
akinomaeni
1e799f2385 Add subsec to ActiveSupport::TimeWithZone#inspect
Time.at(1498099140).in_time_zone.inspect
=> "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
=> "Thu, 22 Jun 2017 02:39:00.12345678 UTC +00:00"
Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
=> "Thu, 22 Jun 2017 02:39:00 1/3 UTC +00:00"
2020-04-04 22:57:06 +09:00
Eugene Kenny
775148c837 Allow utc_to_local_returns_utc_offset_times to be set in new_framework_defaults_6_1.rb
Enabling this option in new_framework_defaults_6_1.rb didn't work
before, as railtie initializers run before application initializers.
2020-04-03 19:41:35 +01:00
Eugene Kenny
f84e0d64dd Allow logs to be tagged without a block
Calling `#tagged` without a block now returns a new logger with the tags
applied. This is useful for when you want to tag an individual log line,
rather than an entire request.
2020-03-31 16:02:59 +01:00
Michael Groeneman
e4068f5ff2 Align Range#cover? extension behavior with Ruby behavior for backwards ranges.
`(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby. Previously this returned `true`.

Also update `#include?` and `#===` behavior to match.
2020-03-30 13:52:47 -07:00
Kasper Timm Hansen
bf34c808f9
Merge branch 'tzinfo2' 2020-03-28 20:53:24 +01:00
Phil Ross
e9425abe33
Update to TZInfo v2.0.0
Co-authored-by: Jared Beck <jared@jaredbeck.com>
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2020-03-28 20:42:43 +01:00
Jatin Dhankhar
5df9b4584c
Add Date and Time #yesterday? and #tomorrow? (#37625)
Add Date and Time `#yesterday?` and `#tomorrow?` alongside `#today?`.

Aliased to `#prev_day?` and `#next_day?` to match the existing `#prev/next_day` methods.
2020-03-19 20:30:14 -07:00
Eugene Kenny
a4914a436e Add Enumerable#pick to complement Relation#pick
This allows `pick` to be called on an object that could either be an
enumerable or a relation.

Also clarify the documentation for `Enumerable#pluck`, and add an
example of plucking multiple keys to the core extensions guide.
2020-03-18 20:03:56 +00:00
Rafael França
40b7d93c5b
Merge pull request #38576 from Edouard-chin/ec-activejob-deprecation
Fix AJ wrong deprecation message on `after_callbacks_if_terminated`:
2020-03-03 15:28:50 -05:00
Edouard CHIN
06dd162fb3 ActiveSupport::Calbacks#halted_callback_hook receive callback name:
- The `halted_callback_hook` method is called whenever the
  `terminator` halt the callback execution.
  Usually, this translate to when a `before` callback throw
  an `:abort`.

  <details>
    <summary> Example </summary>

    ```ruby
      class Foo
        include ActiveSupport::Callbacks

	define_callbacks :save
	set_callback(:save, :before) { throw(:abort) }

	def run
	  run_callbacks(:save) do
	    'hello'
	  end
	end

	def halted_callback_hook(filter)
	  # filter is the proc passed to `set_callback` above
	end
      end
    ```
  </details>

  ### Problem

  When a class has multiple callbacks, (i.e. `save`, `validate` ...),
  it's impossible to tell in the halted_callback_hook which type of
  callback halted the execution.
  This is useful to take different action based on the callback.

  <details>
    <summary> Use Case </summary>

    ```ruby
      class Foo
        include ActiveSupport::Callbacks

	define_callbacks :save
	define_callbacks :validate

	set_callback(:save, :before) { throw(:abort) }
	set_callback(:validate, :before) { throw(:abort) }

	def run
	  run_callbacks(:validate) do
	    ...
	  end

	  run_callbacks(:save) do
	    ...
	  end
	end

	def halted_callback_hook(filter)
	  Rails.logger.warn("Couldn't save the record, the ??? callback halted the execution")
	end
      end
    ```
  </details>

  ### Solution

  Allow `halted_callback_hook` to receive a second argument which is
  the name of the callback being run.
2020-03-03 16:17:55 -04:00
Ryuta Kamizono
1d3eb7be13 Fixup CHANGELOGs [ci skip] 2020-02-25 14:14:54 +09:00
Elia Schito
1dedf07af9
Prepend class methods of prepended concerns 2020-02-14 18:11:50 +01:00
Jason Karns
54ecc90d90
More tests for concerning 2020-02-10 02:23:43 +01:00
Vishal Telangre
740bb178d9
Deprecate using Range#include? to check the inclusion of a value in a date time range
Use `Range#cover?` instead of `Range#include?` to check the inclusion of a value in a date time range.
2020-01-08 20:28:02 +05:30
tom-lord
7905bdfd8b Add :round_mode parameter support to number helpers
Support handling a `round_mode` in `ActiveSupport::NumberHelper::RoundingHelper`

Add default value to locale file

Update inline documentation with new parameter option

Update CHANGELOG

Add round_mode examples to all the tests

Add I18n test

Simplify logic

Further simpification
2020-01-05 21:23:02 +00:00
Ryuta Kamizono
22483b86a6 Fix broken markup [ci skip] 2019-12-30 13:54:35 +09:00
Nicolas Dular
97d428b790 Return unfrozen strings from to_sentence 2019-12-28 21:56:46 +01:00