| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | | | |
| | | | |
| | | | |
| | | | | |
Possible thanks to Zeitwerk 1.3.0.
|
| | | | | |
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
[ci skip]
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Rails.autoloader and Rails.once_autoloader was just tentative API good
enough for a first patch. Rails.autoloader is singular and does not
convey in its name that there is another autoloader. That might be
confusing, for example if you set a logger and miss traces. On the other
hand, the name `once_autoloader` is very close to being horrible.
Rails.autoloaders.main and Rails.autoloaders.once read better for my
taste, and have a nice symmetry. Also, both "main" and "once" are four
letters long, short and same length.
They are tagged as "rails.main" and "rails.once", respectively.
References #35235.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Both methods were introduced in Ruby 2.5 and fit this use case very
nicely: listing a directory's entries excluding the "." and ".." nodes.
The private method #exclude_from was removed as it no longer serves
its original purpose.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
I believe the current style does not clearly communicate that we are
ignoring non-existing autoload paths altogether. Your eyes may even be
looking for an else clause that is easy to miss but that does not exist.
With the early `next` and code comment the loop reads better for my
taste.
|
| | | | |
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
use ProxyPattern to match for ActiveSupport::Notifications fanout/unsubscribe
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | | |
`object.transform_values!` returns `object` itself.
|
| | | | | |
|
| | | | | |
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
I've found a few places in Rails code base where I think it makes sense
to calculate elapsed time more precisely by using
`Concurrent.monotonic_time`:
- Fix calculation of elapsed time in `ActiveSupport::Cache::MemoryStore#prune`
- Fix calculation of elapsed time in
`ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#wait_poll`
- Fix calculation of elapsed time in
`ActiveRecord::ConnectionAdapters::ConnectionPool#attempt_to_checkout_all_existing_connections`
- Fix calculation of elapsed time in `ActiveRecord::ConnectionAdapters::Mysql2Adapter#explain`
See
https://docs.ruby-lang.org/en/2.5.0/Process.html#method-c-clock_gettime
https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way
Related to 7c4542146f0dde962205e5a90839349631ae60fb
|
|\ \ \ \
| | | | |
| | | | | |
Add missing `require "tmpdir"` in ActiveSupport::EncryptedFile
|
| | | | | |
|
|\ \ \ \ \
| |/ / / /
|/| | | |
| | | | | |
Support before_reset callback in CurrentAttributes
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This is useful when we need to do some work associated to `Current.reset`
but that work depends on the values of the current attributes themselves.
This cannot be done in the supported `resets` callback because when the
block is executed, CurrentAttributes's instance has already been reset.
For symmetry, `after_reset` is defined as alias of `resets`.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
When adding/removing a subscription with a string pattern, it isn't
necessary to clear the entire cache, only the cache for the key being
added.
When adding/removing subscriptions for a regex or to match all events,
the full cache is still cleared.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Previously we stored all subscribers in an array, and every time a new
message name came in asked each subscriber if they responded to the
message.
This commit changes Fanout to hash subscribers with a String pattern by
their pattern. This way we can look them up directly and only do the
O(N) scan over the non-string (Regex or any) patterns.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
ActiveSupport overrides `` Kernel#` `` so that it would not raise
`Errno::ENOENT` but return `nil` instead (due to the last statement
`STDERR.puts` returning nil) if a given command were not found.
Because of this, you cannot safely say somthing like
`` `command`.chomp `` when ActiveSupport is loaded.
It turns out that this is an outdated monkey patch for Windows
platforms to emulate Unix behavior on an ancient version of Ruby, and
it should be removed by now.
|
| |/ /
|/| | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Memory comparison:
Options: {:years=>1, :months=>1, :weeks=>1, :days=>1}
Calculating -------------------------------------
master 576.000 memsize ( 0.000 retained)
5.000 objects ( 0.000 retained)
0.000 strings ( 0.000 retained)
advance_no_dup 288.000 memsize ( 0.000 retained)
4.000 objects ( 0.000 retained)
0.000 strings ( 0.000 retained)
Comparison:
advance_no_dup: 288 allocated
master: 576 allocated - 2.00x more
Options: {:years=>1}
Calculating -------------------------------------
master 264.000 memsize ( 0.000 retained)
2.000 objects ( 0.000 retained)
0.000 strings ( 0.000 retained)
advance_no_dup 72.000 memsize ( 0.000 retained)
1.000 objects ( 0.000 retained)
0.000 strings ( 0.000 retained)
Comparison:
advance_no_dup: 72 allocated
master: 264 allocated - 3.67x more
Options: {:weeks=>1}
Calculating -------------------------------------
master 264.000 memsize ( 0.000 retained)
2.000 objects ( 0.000 retained)
0.000 strings ( 0.000 retained)
advance_no_dup 72.000 memsize ( 0.000 retained)
1.000 objects ( 0.000 retained)
0.000 strings ( 0.000 retained)
Comparison:
advance_no_dup: 72 allocated
master: 264 allocated - 3.67x more
Peformance comparison:
Options: {:years=>1, :months=>1, :weeks=>1, :days=>1}
Warming up --------------------------------------
master 27.740k i/100ms
advance_no_dup 37.705k i/100ms
Calculating -------------------------------------
master 338.511k (± 5.9%) i/s - 1.692M in 5.020333s
advance_no_dup 572.980k (± 3.7%) i/s - 2.866M in 5.008680s
Comparison:
advance_no_dup: 572979.7 i/s
master: 338510.9 i/s - 1.69x slower
Options: {:years=>1}
Warming up --------------------------------------
master 53.313k i/100ms
advance_no_dup 115.016k i/100ms
Calculating -------------------------------------
master 639.715k (± 1.7%) i/s - 3.199M in 5.001851s
advance_no_dup 1.579M (± 6.4%) i/s - 7.936M in 5.053876s
Comparison:
advance_no_dup: 1579251.7 i/s
master: 639714.8 i/s - 2.47x slower
Options: {:weeks=>1}
Warming up --------------------------------------
master 57.353k i/100ms
advance_no_dup 129.141k i/100ms
Calculating -------------------------------------
master 674.113k (± 3.4%) i/s - 3.384M in 5.025973s
advance_no_dup 1.911M (± 2.5%) i/s - 9.556M in 5.004496s
Comparison:
advance_no_dup: 1910739.3 i/s
master: 674112.6 i/s - 2.83x slower
|
| | |
| | |
| | |
| | | |
Now that secret_token was removed all this code is now dead.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* Calculate first month of quarter instead of finding
* Calculate last month of quarter instead of finding
[Krzysztof Rybka + Rafael Mendonça França]
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
### Summary
There was an issues when using `safe_constantize` on a string that has
the wrong case.
File `em.rb` defines `EM`.
`"Em".safe_constantize` causes a little confusion with the autoloader.
The autoloader finds file "em.rb",
expecting it to define `Em`, but `Em` is not defined.
The autoloader raises a `LoadError`, which is good,
But `safe_constantize` is defined to return `nil` when a class is not found.
### Before
```
"Em".safe_constantize
LoadError: Unable to autoload constant Em, \
expected rails/activesupport/test/autoloading_fixtures/em.rb to define it
```
### After
```
"Em".safe_constantize
# => nil
```
|
| | |
| | |
| | |
| | |
| | |
| | | |
This speeds up Range.new(x, y).step(Duration).each { ... }
Fixes #34888
|
|\ \ \
| | | |
| | | | |
Preserve key order of #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.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Since #34864 removed explicit receiver to clarify the
purpose of `delegate_missing_to`, I think it will be
better to do the same a few lines above to easier figure
out that `delegate_missing_to` defines `method_missing`,
`respond_to_missing?` when comparing these examples.
|
| | | |
| | | |
| | | | |
Removing the explicit receiver clarifies the purpose of `delegate_missing_to`.
|
| | | |
| | | |
| | | |
| | | | |
[ci skip]
|
|\ \ \ \
| | | | |
| | | | | |
Add examples describing error handling in ActiveSupport::Notification…
|
| |/ / /
| | | |
| | | |
| | | | |
ActiveSupport::LogSubscriber documentation files
|
| | | | |
|
| | | |
| | | |
| | | | |
Accommodate case-insensitive filesystems and database collations.
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Use BigDecimal provided methods to convert String to BigDecimal
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
`String#to_d` does not raise an exception if an invalid value is specified.
So can remove exception handling.
```
$ bundle exec ruby -v -rbigdecimal -rbigdecimal/util -e 'p "123,003".to_d'
ruby 2.6.0dev (2018-12-21 trunk 66474) [x86_64-linux]
0.123e3
```
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin block
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).
I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
Module.delegate rdoc update to clarify :to parameter [ci skip]
|
| | |/ / / /
| |/| | | | |
|
|\ \ \ \ \ \
| |/ / / / /
|/| | | | | |
Do no watch parent directory of `dirs`
|
| | |/ / /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
`EventedFileUpdateChecker` will search the parent directory if the
specified directory does not exist.
Since `test/mailers/previews` is included in the watch target by default,
if there is no test directory (e.g. using `rspec`), the Rails root directory
will be included in the watch target.
```
$ rails new app
$ cd app
$ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)"
false
$ rm -rf test
$ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)"
true
```
This causes `node_modules` to be included in watch target. Adding parent
directories to watch target may include unexpected directories.
In order to avoid this, fixed that parents of nonexistent directories are
not added to the watch targets, instead checking that the directory
exists when checking changes.
Related to #32700.
[Matthew Draper & Yuji Yaginuma]
|
|\ \ \ \ \
| |_|/ / /
|/| | | | |
Follow up #34754
|