aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | Fix typoPatrick Toomey2019-05-311-1/+1
| | | | | |
| * | | | | Recursively process arrays consistentlyPatrick Toomey2019-05-311-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | Based on the way parameters are currently processed, a parameter value of type Hash is recursively processed. For a value of type Array however, the current behavior is to simply return the original array, with no filtering. It is not clear what the expected behavior should be. But, doing nothing seems incorrect, since it bypasses custom Proc based parameter filtering all together for arrays of values. This change processes values of type Array consistently. We map over the values and recursively call value_for_key on them. This still works with values of type Hash, since value_for_key already knows how to process Hash values.
* | | | | | Omit marshal_dump & _dump from delegate_missing_toAaron Lipman2019-07-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exclude missing marshal_dump and _dump methods from being delegated to an object's delegation target via the delegate_missing_to extension. This avoids unintentionally adding instance variables to an object during marshallization, should the delegation target be a method which would otherwise add them. In current versions of Ruby, a bug exists in the way objects are marshalled, allowing for instance variables to be added or removed during marshallization (see https://bugs.ruby-lang.org/issues/15968). This results in a corrupted serialized byte stream, causing an object's instance variables to "leak" into subsequent serialized objects during demarshallization. In Rails, this behavior may be triggered when marshalling an object that uses the delegate_missing_to extension, if the delegation target is a method which adds or removes instance variables to an object being marshalled - when calling Marshal.dump(object), Ruby's built in behavior will check whether the object responds to :marshal_dump or :_dump, which in turn triggers the delegation target method in the responds_to_missing? function defined in activesupport/lib/active_support/core_ext/module/delegation.rb While future versions of Ruby will resolve this bug by raising a RuntimeError, the underlying cause of this error may not be readily apparent when encountered by Rails developers. By excluding marshal_dump and _dump from being delegated to an object's target, this commit eliminates a potential cause of unexpected behavior and/or RuntimeErrors. Fixes #36522
* | | | | | Revert "Make UTF-8 string requirement explicit for ↵Cliff Pruitt2019-07-171-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | `ActiveSupport::Inflector.transliterate`"
* | | | | | Merge pull request #36690 from cpruitt/make-parameterize-requires-utf-8-explicitEileen M. Uchitelle2019-07-171-2/+7
|\ \ \ \ \ \ | | | | | | | | | | | | | | Make UTF-8 string requirement explicit for `ActiveSupport::Inflector.transliterate`
| * | | | | | Make UTF-8 string requirement explicit for `transliterate`Cliff Pruitt2019-07-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's noted in #34062 that String#parameterize will raise an `Encoding::CompatibilityError` if the string is not UTF-8 encoded. The error is raised as a result of passing the string to `.unicode_normalize`. This PR raises a higher level `ArgumentError` if the provided string is not UTF-8 and updates documentation to note the encoding requirement.
* | | | | | | Merge pull request #36648 from louim/patch-1Rafael França2019-07-161-2/+2
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | Update message verifier documentation [ci skip]
| * | | | | | Update message verifier documentation [ci skip]Louis-Michel Couture2019-07-101-2/+2
| | | | | | | | | | | | | | | | | | | | | Generate method of ActiveSupport Message verifier implied that the message is encrypted, but the message is simply Base64-encoded.
* | | | | | | Merge pull request #36667 from ↵Gannon McGibbon2019-07-161-0/+3
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gmcgibbon/clarify_logger_set_in_log_subscriber_docs Specify log subscribers need a logger set before they can receive events
| * | | | | | | Specify log subscribers need a logger set before they can receive eventsGannon McGibbon2019-07-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current example code for `ActiveSupport::LogSubscriber` mysteriously fails if you're using it outside of Rails. This helps clarify a logger needs to be set first before log subscribers can process events. [ci skip]
* | | | | | | | Merge pull request #36685 from Shopify/as-depedencies-unhook-fixRafael França2019-07-161-3/+23
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Fix Loadable.exclude_from to also reset Kernel#require
| * | | | | | | | Fix Loadable.exclude_from to also reset Kernel#requireJean Boussier2019-07-161-3/+23
| | | | | | | | |
* | | | | | | | | Merge pull request #36557 from ↵Matthew Draper2019-07-161-3/+24
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sikachu/fix-source-annotation-extractor-annotation Fix problem with accessing deprecated constant proxy's subclass
| * | | | | | | | | Fix problem with accessing constant proxy subclassPrem Sichanugrist2019-07-051-3/+24
| | |_|_|_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes #36313. After #32065 moved `SourceAnnotationExtractor` into `Rails` module, it broke the ability to access `SourceAnnotationExtractor::Annotate` directly as user would get this error: TypeError: Rails::SourceAnnotationExtractor is not a class/module This commit fixes the issue by making `DeprecatedConstantProxy` to inherit from `Module` and then defines `method_missing` and `const_missing` to retain the previous functionality. Thank you Matthew Draper for the idea of how to fix the issue! [Prem Sichanugrist & Matthew Draper]
* | | | | | | | | Merge pull request #36656 from Edouard-chin/ec-local-cache-referenceRafael França2019-07-151-1/+4
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Return a copy of the cache entry when local_cache exists:
| * | | | | | | | | Return a copy of the cache entry when local_cache exists:Edouard CHIN2019-07-111-1/+4
| | |_|_|/ / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - When the local cache exists (during the request lifecycle), the entry returned from the LocalStore is passed as a reference which means mutable object can accidentaly get modified. This behaviour seems unnecessarily unsafe and is prone to issues like it happened in our application. This patch dup the `Entry` returned from the cache and dup it's internal value.
* | | | | | | | | active_support/core_ext/object/duplicable is not in use hereRyuta Kamizono2019-07-161-1/+0
| |_|_|/ / / / / |/| | | | | | |
* | | | | | | | Inline anemic log guardDavid Heinemeier Hansson2019-07-151-6/+3
| |_|/ / / / / |/| | | | | | | | | | | | | | | | | | | | This is the only use of it
* | | | | | | Merge pull request #36658 from Shopify/duplicable-changesRyuta Kamizono2019-07-141-117/+7
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Remove dead code in duplicable.rb
| * | | | | | | Implement UnboundMethod#duplicable?Jean Boussier2019-07-121-1/+10
| | | | | | | |
| * | | | | | | Remove dead code in duplicable.rbJean Boussier2019-07-111-120/+1
| |/ / / / / /
* | | | | | | active_support/deprecation is not in use hereAkira Matsuda2019-07-122-2/+0
| | | | | | |
* | | | | | | active_support/dependencies/autoload is already required via active_support.rbAkira Matsuda2019-07-122-5/+0
|/ / / / / /
* | | | | | Merge pull request #36443 from jhawthorn/as_parallelization_process_nameJohn Hawthorn2019-07-061-0/+11
|\ \ \ \ \ \ | | | | | | | | | | | | | | Set process title of parallelized test workers
| * | | | | | Set process name of parallelized test workersJohn Hawthorn2019-06-071-0/+11
| |/ / / / /
* | | | | | Rely on Kernel require instead of self requireBenoit Tigeot2019-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this code (exctracted from derailed_benchmarks): ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "rails", "~> 6.0.0.rc1", require: false end FILES = [ "rails/engine/configuration", "rails/source_annotation_extractor", "active_support/deprecation" ] module Kernel alias :original_require :require def require(file) Kernel.require(file) end class << self alias :original_require :require end end Kernel.define_singleton_method(:require) do |file| original_require(file) end FILES.each do |file| puts "requiring file: #{file}" require file end ``` It fails with Rails 6 and the change introduced by 32065 ``` requiring file: rails/engine/configuration requiring file: rails/source_annotation_extractor Traceback (most recent call last): 11: from repro_derailed.rb:33:in `<main>' 10: from repro_derailed.rb:33:in `each' 9: from repro_derailed.rb:35:in `block in <main>' 8: from repro_derailed.rb:21:in `require' 7: from repro_derailed.rb:30:in `block in <main>' 6: from repro_derailed.rb:30:in `require' 5: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/railties-6.0.0.rc1/lib/rails/source_annotation_extractor.rb:8:in `<top (required)>' 4: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new' 3: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new' 2: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:125:in `initialize' 1: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:23:in `method_missing' /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:148:in `warn': private method `warn' called for nil:NilClass (NoMethodError) ``` Related: - https://github.com/schneems/derailed_benchmarks/pull/130 - https://github.com/rails/rails/pull/32065
* | | | | | Indentation >>Akira Matsuda2019-06-221-6/+6
| | | | | |
* | | | | | Delete `DateAndTime` method definition in rails that is compatible with ruby ↵soartec-lab2019-06-162-30/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | definition Tests are also only on the `Time` class Update doc forgetting to erase when moved Update guide `Date` class to `Time` class and defined file Update guide correction omission
* | | | | | Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-1338-42/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* | | | | | Add missing file to require digest/uuid on active_support core extensionsLucas Arantes2019-06-121-0/+3
|/ / / / /
* | / / / Allow `on_rotation` in MessageEncryptor to be passed in constructor:Edouard CHIN2019-06-061-4/+5
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Use case: I'm writing a wrapper around MessageEncryptor to make things easier to rotate a secret in our app. It works something like ```ruby crypt = RotatableSecret.new(['old_secret', 'new_secret']) crypt.decrypt_and_verify(message) ``` I'd like the caller to not have to care about passing the `on_rotation` option and have the wrapper deal with it when instantiating the MessageEncryptor object. Also, almost all of the time the on_rotation should be the same when rotating a secret (logging something or StatsD event) so I think it's not worth having to repeat ourselves each time we decrypt a message.
* | | | Don't call listen with empty directory listJohn Hawthorn2019-06-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Listen interprets an empty list of directories as "watch the current directory". Since EventedFileUpdateChecker doesn't share these semantics, we should not initialize listen if we end up with an empty directory list.
* | | | Fix `subscribed` with no pattern to subscribe all messagesRyuta Kamizono2019-06-032-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a regression for #36184. And also, add new `monotonic` argument to the last of the method signature rather than the first.
* | | | Fail parallel tests if workers exit earlyJohn Hawthorn2019-05-301-0/+8
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if a test worker exited early, the in-flight test it was supposed to run wasn't reported as a failure. If all workers exited immediately, this would be reported as ex. Finished in 1.708349s, 39.2192 runs/s, 79.0237 assertions/s. 67 runs, 135 assertions, 0 failures, 0 errors, 2 skips This commit validates that all workers finish running tests by ensuring that the queue is empty after they exit. This works because we signal the workers to exit by pushing nil onto the queue, so that there should be a number of items left in the queue matching potentially missed tests.
* | | Change commentsEdu Depetris2019-05-251-2/+2
| | |
* | | Merge pull request #36340 from jhawthorn/evented_file_checker_symlinkKasper Timm Hansen2019-05-241-0/+7
|\ \ \ | | | | | | | | Fix EventedFileUpdateChecker through a symlink
| * | | Fix EventedFileUpdateChecker through a symlinkJohn Hawthorn2019-05-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On MacOS, Dir.tmpdir gives me a folder inside "/var/folders/". However, /var is a symlink to /private/var. Previously, the nonexistent directory test would fail because it was initialized with /var/folders/... but the filenames from listen would be the realpaths. This commit normalizes the dirs by calling realpath on them if they exist. This is done on boot!, so it will work with newly directories through the symlink.
* | | | Address 639d7be. Readd changelog line; remove needless explicit return.Kasper Timm Hansen2019-05-241-1/+1
| | | |
* | | | Delete evented_file_update_checker existing_parentJohn Hawthorn2019-05-231-7/+0
|/ / / | | | | | | | | | This is no longer used as of caa3cc8868206f8109e0d633efb09d31e94ef635
* / / Add :allow_nil option to delegate_missing_to; use in ActiveStorageMatt Tanous2019-05-231-3/+8
|/ / | | | | | | attachment
* | Correct human file size examples [ci skip]Alexander Graul2019-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | The `number_to_human_size` helpers in Action View and Active Support calculate the "human size" with a base of 1024. The examples should reflect that so they don't confuse the reader. The updated documentations use the values from: helper.number_to_human_size(1500)
* | Introduce ↵Vishal Telangre2019-05-102-7/+53
|/ | | | | | | | | | | | | | | | | | | | 'ActiveSupport::Notifications::Fanout::Subscribers::MonotonicTimed' and 'ActiveSupport::Notifications::monotonic_subscribe' Also, change the signature of ‘ActiveSupport::Notifications::Fanout#subscribe’ to accept optional ‘monotonic’ boolean argument. Then initialize either a ‘Timed’ or ‘MonotonicTimed’ subscriber based on the value of ‘monotonic’ parameter. Introduce ‘ActiveSupport::Notifications::monotonic_subscribe’ method Also, provision ‘ActiveSupport::Notifications::subscribed’ to optionally accept ‘monotonic’ boolean argument. Update documentation for ActiveSupport::Notifications Add tests Update guides documentation under the 'Active Support Instrumentation' chapter Incorporate feedback: use optional keyword argument to specify optional 'monotonic' option to 'subscribed' method Fix a typo
* Merge pull request #34642 from ↵Rafael França2019-05-011-1/+1
|\ | | | | | | | | azimux/improve-hwia-initialize-by-skipping-to_h-if-already-a-hash HashWithIndifferentAccess#initialize performance improvement
| * HashWithIndifferentAccess#initialize performance improvementMiles Georgi2018-12-061-1/+1
| | | | | | | | | | | | | | | | | | Rails 4 -> Rails 5 introduced a #to_hash call in HashWithIndifferentAccess#initialize to guarantee access to the #default and #default_proc methods. This can be a very expensive operation for very large HashWithIndifferentAccess objects. This commit bypasses this #to_hash call if it is already a Hash.
* | revert changes to monotonic timesKevin Solorio2019-04-301-2/+2
| | | | | | | | | | | | | | | | | | | | The change to monotonic times causes failures for applications where the subscribed block is expecting Time objects as described in this issue: https://github.com/rails/rails/issues/36145 The original PR (https://github.com/rails/rails/pull/35984) was concerned with errors on the cpu_time. Test was edited to reflect changes to initializer using 0 values instead of nil
* | Improve error message of ActiveSupport delegateokuramasafumi2019-04-291-1/+1
| | | | | | | | | | | | | | | | | | ActiveSupport `delegate` has `to` option, but it's not a option hash anymore and now it's a keyword argument. When `to` argument is not given, it raises an ArgumentError but the message suggests supplying "options hash", which is now wrong. Now it's fixed to provide correct suggestion to supply a keyword argument.
* | Frozen truncate (#36109)Jordan Thomas2019-04-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add test asserting truncate returns unfrozen string * Ensure strings returned from truncate are not frozen This fixes an issue where strings too short to be truncated were returned unfrozen, where as long-enough strings were returned frozen. Now retuned strings will not be frozen whether or not the string returned was shortened. * Update changelog w/ new truncate behavior description [Jordan Thomas + Rafael Mendonça França]
* | Start Rails 6.1 developmentRafael Mendonça França2019-04-242-3/+3
| |
* | upgrades Zeitwerk to 2.1.4Xavier Noria2019-04-232-11/+9
| | | | | | | | | | | | This commit more or less undoes 9b5401f, restores autoloaded? not to touch the descendants tracker, and autoloaded_constants because it is documented in the guide.
* | Merge pull request #36037 from kamipo/deprecate_methodsRyuta Kamizono2019-04-191-18/+7
|\ \ | | | | | | Refactor `ActiveSupport::Deprecation.deprecate_methods` not to expose internal methods