aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | Delete uneeded blank fileGuillermo Iguaran2019-02-081-0/+0
| | | | |
* | | | | Add 'Hash#deep_transform_values', and 'Hash#deep_transform_values!'Guillermo Iguaran2019-02-085-0/+84
| | | | |
* | | | | Fix elapsed time calculationsbogdanvlviv2019-02-082-3/+3
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Merge pull request #35170 from palkan/fix/encrypted-fileRafael França2019-02-051-1/+2
|\ \ \ \ | | | | | | | | | | Add missing `require "tmpdir"` in ActiveSupport::EncryptedFile
| * | | | Add missing `require "tmpdir"` in ActiveSupport::EncryptedFileVladimir Dementyev2019-02-051-1/+2
| | | | |
* | | | | Respect ENV variables when finding DBs etc for the test suiteMatthew Draper2019-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | If they're not set we'll still fall back to localhost, but this makes it possible to run the tests against a remote Postgres / Redis / whatever.
* | | | | Merge pull request #35063 from rosa/current-before-reset-callbackRafael Mendonça França2019-02-043-9/+41
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | Support before_reset callback in CurrentAttributes
| * | | | Support before_reset callback in CurrentAttributesRosa Gutierrez2019-01-303-8/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | | | | Keep cache for strings in notifications/fanoutJohn Hawthorn2019-02-011-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | Make Notifications::Fanout#listeners_for fasterJohn Hawthorn2019-02-011-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 typo fixes.alkesh262019-02-017-7/+7
| | | | |
* | | | | Remove the Kernel#` override that turns ENOENT into nilAkinori MUSHA2019-01-313-14/+4
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Merge pull request #35080 from sos4nt/add_hash_assocRyuta Kamizono2019-01-303-0/+28
|\ \ \ \ | |_|/ / |/| | | | | | | Add HashWithIndifferentAccess#assoc
| * | | Add HashWithIndifferentAccess#assocStefan Schüßler2019-01-303-0/+27
|/ / /
* | | Preparing for 6.0.0.beta1 releaseRafael Mendonça França2019-01-182-1/+3
| | |
* | | No dup nor delete from optionsKrzysztof Rybka2019-01-181-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Remove secret_token rack env and cookie upgrade codeRafael Mendonça França2019-01-171-32/+0
| | | | | | | | | | | | Now that secret_token was removed all this code is now dead.
* | | Remove deprecated `Module#reachable?` methodRafael Mendonça França2019-01-174-58/+5
| | |
* | | Remove deprecated `#acronym_regex` method from `Inflections`Rafael Mendonça França2019-01-173-8/+5
| | |
* | | Refactor calculating beginning_of_quarter and end_of_quarter (#34927)Krzysztof Rybka2019-01-141-2/+2
| | | | | | | | | | | | | | | | | | | | | * Calculate first month of quarter instead of finding * Calculate last month of quarter instead of finding [Krzysztof Rybka + Rafael Mendonça França]
* | | Fix safe_constantize to not raise a LoadError.Keenan Brock2019-01-094-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### 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 ```
* | | Merge pull request #34899 from rails/speed-up-stepAaron Patterson2019-01-091-1/+4
|\ \ \ | | | | | | | | Duration#coerce should always return a Scalar
| * | | Duration#coerce should always return a ScalarAaron Patterson2019-01-081-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | This speeds up Range.new(x, y).step(Duration).each { ... } Fixes #34888
* | | | Enable `Lint/UselessAssignment` cop to avoid unused variable warnings (#34904)Ryuta Kamizono2019-01-091-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enable `Lint/UselessAssignment` cop to avoid unused variable warnings Since we've addressed the warning "assigned but unused variable" frequently. 370537de05092aeea552146b42042833212a1acc 3040446cece8e7a6d9e29219e636e13f180a1e03 5ed618e192e9788094bd92c51255dda1c4fd0eae 76ebafe594fc23abc3764acc7a3758ca473799e5 And also, I've found the unused args in c1b14ad which raises no warnings by the cop, it shows the value of the cop.
* | | Revert "Revert "Merge pull request #34387 from ↵Kasper Timm Hansen2019-01-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | yhirano55/rails_info_properties_json"" I reverted the wrong commit. Damn it. This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
* | | Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"Kasper Timm Hansen2019-01-081-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had a discussion on the Core team and we don't want to expose this information as a JSON endpoint and not by default. It doesn't make sense to expose this JSON locally and this controller is only accessible in dev, so the proposed access from a production app seems off. This reverts commit 8eaffe7e89719ac62ff29c2e4208cfbeb1cd1c38, reversing changes made to b6e4305c3bca4c673996d0af9db0f4cfbf50215e.
* | | Merge pull request #34700 from gmcgibbon/fetch_multi_key_orderRafael França2019-01-073-10/+24
|\ \ \ | | | | | | | | Preserve key order of #fetch_multi
| * | | Preserve key order passed to ActiveSupport::CacheStore#fetch_multiGannon McGibbon2018-12-273-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | fetch_multi(*names) now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
* | | | Clarify `delegate_missing_to` [ci skip]bogdanvlviv2019-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Clarify benefit of `delegate_missing_to`Michael Gee2019-01-041-1/+1
| | | | | | | | | | | | Removing the explicit receiver clarifies the purpose of `delegate_missing_to`.
* | | | Fix examples in ActiveSupport::LogSubscriber docsGannon McGibbon2019-01-011-3/+3
| | | | | | | | | | | | | | | | [ci skip]
* | | | Merge pull request #34707 from xlts/update-notifications-docsGannon McGibbon2018-12-312-9/+35
|\ \ \ \ | | | | | | | | | | Add examples describing error handling in ActiveSupport::Notification…
| * | | | Add examples describing error handling in ActiveSupport::Notifications and ↵Mariusz Hausenplas2018-12-142-9/+35
| | | | | | | | | | | | | | | | | | | | ActiveSupport::LogSubscriber documentation files
* | | | | Bump license years for 2019Arun Agrawal2018-12-312-2/+2
| | | | |
* | | | | Tweak test nameGeorge Claghorn2018-12-301-1/+1
| | | | |
* | | | | Make Active Storage blob keys lowercaseJulik Tarkhanov2018-12-302-3/+43
| | | | | | | | | | | | | | | Accommodate case-insensitive filesystems and database collations.
* | | | | No need to handle if FrozenError is availableYasuo Honda2018-12-232-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rails 6 requires Ruby 2.5, which introduces `FrozenError` https://docs.ruby-lang.org/en/2.5.0/NEWS.html Related to #31520
* | | | | Fixes `warning: mismatched indentations at 'rescue' with 'def' at 15`.utilum2018-12-211-2/+2
| | | | | | | | | | | | | | | | | | | | See https://travis-ci.org/rails/rails/jobs/470890129#L2361
* | | | | Add missing require for `String#to_d`yuuji.yaginuma2018-12-211-0/+1
| | | | |
* | | | | Merge pull request #34767 from y-yagi/fix_convert_string_to_bigdecimalYuji Yaginuma2018-12-211-5/+1
|\ \ \ \ \ | | | | | | | | | | | | Use BigDecimal provided methods to convert String to BigDecimal
| * | | | | Use BigDecimal provided methods to convert String to BigDecimalyuuji.yaginuma2018-12-211-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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 ```
* | | | | | Merge pull request #34764 from kamipo/avoid_redundant_beginRyuta Kamizono2018-12-219-178/+153
|\ \ \ \ \ \ | | | | | | | | | | | | | | Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin block
| * | | | | | Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-219-178/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | Merge pull request #34769 from elebow/module-delegate-to-docstringRyuta Kamizono2018-12-211-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Module.delegate rdoc update to clarify :to parameter [ci skip]
| * | | | | | | Clarify the :to parameter of delegateEddie Lebow2018-12-201-1/+1
| | | | | | | |
* | | | | | | | Merge pull request #33822 from y-yagi/do_not_check_parents_dor_directoriesYuji Yaginuma2018-12-212-2/+50
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | Do no watch parent directory of `dirs`
| * | | | | | | Do not add parent directory to file system monitoringyuuji.yaginuma2018-12-182-2/+50
| | |_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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]
* | | | | | | Add test for `travel_to` with time zoneyuuji.yaginuma2018-12-211-0/+17
| |_|/ / / / |/| | | | | | | | | | | | | | | | | This is a regression test for #34751.
* | | | | | Merge pull request #34762 from bogdanvlviv/fix-a-few-deprecation-warningsKasper Timm Hansen2018-12-204-31/+9
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | Follow up #34754
| * | | | | Follow up #34754bogdanvlviv2018-12-204-31/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fix a few deprecation warnings - Remove testing of `Hash#slice` - Imporve test of `Hash#slice!` - Remove mention about `Hash#slice` from the guide