Commit Graph

8455 Commits

Author SHA1 Message Date
Rafael França aeea158d95
Merge pull request #40774 from stevecrozz/inflection-locale-defaults-and-fallbacks
Fix :en-GB pluralization test (day -> days)
2020-12-09 13:45:34 -05:00
Stephen Crosby fc61648249
Fix :en-GB pluralization test (day -> days) 2020-12-09 10:33:20 -08:00
Rafael França d3ccc920e7
Merge pull request #38659 from stevecrozz/inflection-locale-defaults-and-fallbacks
Inflection support default_locale and fallbacks
2020-12-09 13:30:34 -05:00
Stephen Crosby ea27ff3d62
Inflection support default_locale and fallbacks 2020-12-09 10:06:05 -08:00
Rafael França eebde10693
Merge pull request #40759 from orhantoy/broadcast-tagged-logging
Clone to keep extended Logger methods for tagged logger
2020-12-08 14:01:53 -05:00
KapilSachdev a908d06c85
feat(rubocop): Add Style/RedundantRegexpEscape
- This cop will help in removing unnecessary escaping inside Regexp literals.
2020-12-08 18:57:09 +00:00
Rafael França ccefd5ce7f
Merge pull request #40201 from Shopify/symbol-name
Use Symbol#name if available in HashWithIndifferentAccess
2020-12-08 13:45:16 -05:00
Orhan Toy 70af536b5d Clone to keep extended Logger methods for tagged logger
`#dup` resets the extended Logger methods that could come from enabling broadcasting. That would mean if we create a tagged logger from a Logger with broadcasting enabled (usually to stdout), the new tagged logger will not perform broadcasting.
2020-12-07 14:43:37 +01:00
Rafael Mendonça França 59f7f5889e
Start Rails 6.2 development 🎉 2020-12-03 01:35:29 +00:00
Rafael França 366df0397f
Merge pull request #40721 from d12/optimize_hash_with_indifferent_access_initializer
55% speedup for HashWithIndifferentAccess.new when no args provided
2020-12-01 14:56:56 -05:00
Nathaniel Woodthorpe 0841cdf268 Optimize HashWithIndifferentAccess.new when no args are provided 2020-12-01 13:25:11 -05:00
Akira Matsuda 6f9d4a000b
Merge pull request #40663 from amatsuda/keep_safe_buffer
Let AS::SafeBuffer#[] and * return value be an instance of SafeBuffer in Ruby 3.0
2020-12-01 17:42:37 +09:00
Akira Matsuda 4cb20843eb Mark scrub as an unsafe method on SafeBuffer 2020-12-01 17:40:17 +09:00
Nathaniel Woodthorpe f5e5976388 Fix the return value of #deep_transform_keys from a Hash to a HashWithIndifferentAccess 2020-11-30 17:13:53 -05:00
alvir b96f4ae1d5 Use application time zone when gets time as String. 2020-11-26 11:35:23 +03:00
Bibek Sharma Chapagain fde2d644b1
Grammer correction on ActiveSupport en.yml 2020-11-22 14:12:26 +11:00
Akira Matsuda a4d2493b26 Let AS::SafeBuffer#[] and * return value be an instance of SafeBuffer in Ruby 3
Ruby 3 introduces an incompatibility that String methods return String instances when called on a subclass instance.
https://bugs.ruby-lang.org/issues/10845
https://github.com/ruby/ruby/pull/3701
2020-11-21 16:32:18 +09:00
Petrik 332a2909d4 Fix ForkTracker on ruby <= 2.5.3
Making the fork method private by calling `private :fork` raises a
"no superclass method `fork'" error when calling super in a subclass on
ruby <= 2.5.3. The error doesn't occur on ruby 2.5.4 and higher.
Making the method private by redefining doesn't raise the error.

The possible fix on 2.5.4 is 75aba10d7a

The error can be reproduced with the following script on ruby 2.5.3:
```
class Cluster
  def start
    fork { puts "forked!" }
  end
end

module CoreExt
  def fork(*)
    super
  end
end

module CoreExtPrivate
  include CoreExt
  private :fork
end

::Object.prepend(CoreExtPrivate)
Cluster.new.start
```

Fixes #40603
2020-11-17 21:22:12 +01:00
Akshay Birajdar 888d8c7063 [ci skip] Fix rdoc formatting 2020-11-17 18:49:19 +05:30
Jonathan Hefner b20ac9a1d3 Document Regexp#multiline? [ci-skip]
`Regexp#multiline?` has been publicized in the Active Support Core
Extensions guide for a while now.  This commit adds matching API docs.
2020-11-11 16:03:02 -06:00
Daniel Colson 4e646bb281
Allow subscribing with a single argument callable
Fixes #39976

Prior to this commit it was possible to pass a single argument block to
`ActiveSupport::Notifications.subscribe`, rather than 5 separate
arguments:

```rb
ActiveSupport::Notifications.subscribe('some_event') do |event|
  puts "Reacting to #{event.name}"
end
```

But it was not possible to do the same with a lambda, since the lambda
parameter is a required (`:req`) parameter, but we were checking only
for an optional (`:opt`) parameter.

```rb
listener = ->(event) do
  puts "Reacting to #{event.name}"
end

ActiveSupport::Notifications.subscribe('some_event', &listener)
```

It was also not possible to do this with a custom callable object, since
the custom callable does not respond directly to `:parameters` (although
it's `:call` method object does).

```rb
class CustomListener
  def call(event)
    puts "Reacting to #{event.name}"
  end
end

ActiveSupport::Notifications.subscribe('some_event', CustomListener.new)
```

Prior to this commit these examples would have raised `ArgumentError:
wrong number of arguments (given 5, expected 1)`.

With this commit the single argument lambda and custom callable work
like the single argument block.
2020-11-09 22:26:21 -05:00
Rafael França e71b4a5e04
Merge pull request #40588 from etiennebarrie/activesupport-currentattributes-testhelper-teardown
Allow access to CurrentAttributes in test teardown
2020-11-09 16:04:42 -05:00
Étienne Barrié 0400be279b Allow access to CurrentAttributes in test teardown 2020-11-09 15:15:42 -05:00
Rafael Mendonça França 0a59de2d2a
Don't require event to be passed to read_entry
This will make sure this method is backward compatible with stores that
don't pass the intrumentation payload to the method.
2020-11-09 20:11:36 +00:00
Rafael França 53e97f0fa0
Merge pull request #40490 from kirs/cache-instrument-store-local
Instrument cache entries from local cache
2020-11-05 16:36:50 -05:00
Kir Shatrov c88205613b Instrument cache entries from local cache 2020-11-04 23:12:21 +00:00
maxgurewitz 55501549cb disable compression for MemoryStore's by default
- Compression has reduced effectiveness for MemoryStore, which does not
send data over a network.
2020-11-04 12:20:24 -05:00
Eugene Kenny bc524f16ee
Merge pull request #40517 from eugeneius/depend_on_message
Use LoadError#original_message if available in depend_on
2020-11-03 18:12:24 +00:00
Tahsin Hasan a52ca5fddc Create unit test to use to_time for timestamp in string 2020-11-03 18:51:43 +06:00
Rafael Mendonça França 8389f9902c
Preparing for 6.1.0.rc1 release 2020-11-02 21:12:47 +00:00
Eugene Kenny 94ab712585 Use LoadError#original_message if available in depend_on
did_you_mean 1.5.0 will add suggestions to `LoadError`. This means that
`LoadError#message` will now return a new string on each invocation, and
mutating the result will no longer modify the error's message.
2020-11-02 20:54:29 +00:00
Rafael Mendonça França 81ee5dcdf4
Merge pull request #39538.
Closes #39538.
2020-11-02 20:42:40 +00:00
Vipul A M fdfac8760f
Although libraries support both formats of sign before and after DIGITS(ex: https://github.com/moment/luxon/pull/683, https://github.com/moment/moment/issues/2408), many do not.
For example PG refers to https://www.ietf.org/rfc/rfc3339.txt when converting(Ref: https://www.postgresql.org/docs/current/datatype-datetime.html)

According to the ref there is no explicit mention of allowing sign before the parts, which reads as below:

 Durations:

    dur-second        = 1*DIGIT "S"
    dur-minute        = 1*DIGIT "M" [dur-second]
    dur-hour          = 1*DIGIT "H" [dur-minute]
    dur-time          = "T" (dur-hour / dur-minute / dur-second)
    dur-day           = 1*DIGIT "D"
    dur-week          = 1*DIGIT "W"
    dur-month         = 1*DIGIT "M" [dur-day]
    dur-year          = 1*DIGIT "Y" [dur-month]
    dur-date          = (dur-day / dur-month / dur-year) [dur-time]

    duration          = "P" (dur-date / dur-time / dur-week)

We should not attempt to move sign forward in this case.
2020-11-02 20:41:48 +00:00
Rafael Mendonça França 36fe7b8d8f
Ruby 2.7.2 still have the same bug 2020-10-30 21:33:09 +00:00
Rafael Mendonça França 0b72dd37c1
Fix warning in Rubies that already have the method 2020-10-30 21:01:33 +00:00
Rafael França fcb5f9035f
Merge pull request #39828 from tgxworld/backward_patches_for_time_floor_ceil
Add `Time#ceil` and `Time#floor` core extensions.
2020-10-30 16:01:55 -04:00
Eugene Kenny 9509bc23c2 Fixup test for TimeWithZone Time.at precision
This test doesn't involve a DateTime, and can be shortened a bit.
2020-10-30 12:35:03 +00:00
Eugene Kenny a6636b0d1c
Merge pull request #40448 from BKSpurgeon/fix-timezone-rounding-bug
Fix: timezone bug - rounding problem
2020-10-30 12:00:55 +00:00
Rafael França 43daedcb7d
Merge pull request #39550 from vipulnsward/expiry-fix
Fix parsing of jsonified expiry date on AS::Message::Metadata for old json format
2020-10-29 21:47:40 -04:00
Ryuta Kamizono 8512213a39 Fix deprecation will be removed version s/Rails 6.1/Rails 6.2/ 2020-10-30 10:11:29 +09:00
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