aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/deprecation
Commit message (Collapse)AuthorAgeFilesLines
* Refactor `ActiveSupport::Deprecation.deprecate_methods` not to expose ↵Ryuta Kamizono2019-04-191-18/+7
| | | | | | | | | | | | | | | | | internal methods In #33325, `deprecate_methods` is replaced from `prepend` to completely emurated `alias_method_chain`, it exposed two internal methods `xxx_with_deprecation` and `xxx_without_deprecation`. After that, #34648 restored the `prepend` implementation, which doesn't expose any internal methods, so we no longer be able to ensure to always expose that internal methods. As I said at https://github.com/rails/rails/pull/33325#issuecomment-409016725, I think that internal methods exposed is not a specification but a limitation when using `alias_method_chain`, there is no longer a reason to follow that limitation.
* Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-211-4/+4
| | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* Make `deprecate` work for non-exists methodsyuuji.yaginuma2018-12-071-14/+24
| | | | | | | | Before #33325, `deprecate` works for non-exist methods. This is necessary, for example, if want to deprecate dynamically defined methods like attributes methods. Fixes #34646
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* Remove unused requireRyuta Kamizono2018-07-311-1/+0
| | | | | "active_support/core_ext/module/aliasing" is no longer used since #19434.
* Merge pull request #33325 from Edouard-chin/ec-deprecate-class-methodRyuta Kamizono2018-07-311-14/+17
|\ | | | | A regression in `deprecate_methods` was introduced in a982a42:
| * A regression in deprecate_methods was introduced in a982a42:Edouard CHIN2018-07-301-14/+17
| | | | | | | | | | | | | | | | | | | | | | - Refactoring alias_chain to Module#prepend broke the possibility to deprecate class methods since the module generated was prepended to the target's instance. A suggestion to fix this was to use `AS#redefine_method` which would solve the problem but with the cost of redefining directly the method. Decided to go with the same alias_chain implementation as before instead. - Fixes #33253
* | Remove unused `require "active_support/core_ext/regexp"`Ryuta Kamizono2018-07-291-2/+0
|/ | | | | | | | Ruby 2.4 has native `Regexp#match?`. https://ruby-doc.org/core-2.4.0/Regexp.html#method-i-match-3F Related #32034.
* Raise a better exception when a invalid depreation behavior is setRafael Mendonça França2018-05-181-0/+4
| | | | Fixes #32928.
* Return back "/" to the end of RAILS_GEM_ROOTbogdanvlviv2018-04-201-1/+1
| | | | | | | | | | | - The "/" was removed in 40bdbce191ad90dfea43dad51fac5c4726b89392 during refactoring. It may cause regression since looks like was added intentionaly because it is possible that a name of any another gem can start with /rails/, so slash was added to ensure that it is "rails" gem. I would like to backport this to `5-2-stable` too. - Use `__dir__` instead of `__FILE__`. Follow up #29176.
* Correct ActiveSupport::Deprecation::Behavior#behavior= documentationJohn Fragoulis2018-02-231-1/+1
| | | | | The callback parameters need to reflect changes after https://github.com/rails/rails/pull/28800
* Enable autocorrect for `Lint/EndAlignment` copKoichi ITO2018-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary This PR changes .rubocop.yml. Regarding the code using `if ... else ... end`, I think the coding style that Rails expects is as follows. ```ruby var = if cond a else b end ``` However, the current .rubocop.yml setting does not offense for the following code. ```ruby var = if cond a else b end ``` I think that the above code expects offense to be warned. Moreover, the layout by autocorrect is unnatural. ```ruby var = if cond a else b end ``` This PR adds a setting to .rubocop.yml to make an offense warning and autocorrect as expected by the coding style. And this change also fixes `case ... when ... end` together. Also this PR itself is an example that arranges the layout using `rubocop -a`. ### Other Information Autocorrect of `Lint/EndAlignment` cop is `false` by default. https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443 This PR changes this value to `true`. Also this PR has changed it together as it is necessary to enable `Layout/ElseAlignment` cop to make this behavior.
* Preserve original method visibility when deprecating a methodJordan Brough2017-12-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes `deprecate` so that it preserves method visibility (like it did previously when it was utilizing `alias_method_chain`). When Module#prepend replaced alias_method_chain in a982a42 it caused deprecated methods to always become public. `alias_method_chain` had this bit of code: https://github.com/rails/rails/blob/v5.0.6/activesupport/lib/active_support/core_ext/module/aliasing.rb#L40-L47 which preserved method visibility. Without this fix, a workaround would be: ```ruby class C8 private def new_method end def old_method end deprecate :old_method, :new_method # workaround: instance_method(:old_method).owner.send(:private, :old_method) end ``` Because the visibility needs to be fixed on the Module prepended by MethodWrapper.
* Formatting fix for example codeT.J. Schuck2017-11-282-2/+2
| | | | | | | | | | | | | | | | Just cleaning up the formatting of the example code here to format an inline bit of commentary as a comment. Before: ![](https://monosnap.com/file/Clso8IQGOWHU3o6cStbY5NaMPx3ysP.png) After: ![](https://monosnap.com/file/QdbKKvLAeiQ0RucppVYETvaWEstnOI.png) [ci skip]
* [ci skip] Fix documentation for deprecation method_wrappersIgnat Zakrevsky2017-11-271-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seems like version with class methods doesn't work. ```ruby require "active_support/deprecation.rb" module Fred extend self def aaa; end def bbb; end def ccc; end def ddd; end def eee; end end ActiveSupport::Deprecation.deprecate_methods(Fred, :aaa, bbb: :zzz, ccc: 'use Bar#ccc instead') Fred.aaa Fred.bbb Fred.ccc ``` # produces nothing vs ```ruby require "active_support/deprecation.rb" class Fred def aaa; end def bbb; end def ccc; end def ddd; end def eee; end end ActiveSupport::Deprecation.deprecate_methods(Fred, :aaa, bbb: :zzz, ccc: 'use Bar#ccc instead') Fred.new.aaa Fred.new.bbb Fred.new.ccc ``` produces ``` DEPRECATION WARNING: aaa is deprecated and will be removed from Rails 5.2 (called from <main> at deprications.rb:15) DEPRECATION WARNING: bbb is deprecated and will be removed from Rails 5.2 (use zzz instead) (called from <main> at deprications.rb:16) DEPRECATION WARNING: ccc is deprecated and will be removed from Rails 5.2 (use Bar#ccc instead) (called from <main> at deprications.rb:17) ```
* Deprecate ActiveSupport::Inflector#acronym_regexNick LaMuro2017-10-282-3/+4
| | | | | | | | | To be removed in Rails 6.0 (default for the deprecate helper). Code moved around as well for the ActiveSupport::Deprecation modules, since it was dependent on ActiveSupport::Inflector being loaded for it to work. By "lazy loading" the Inflector code from within the Deprecation code, we can require ActiveSupport::Deprecation from ActiveSupport::Inflector and not get a circular dependency issue.
* [Active Support] require_relative => requireAkira Matsuda2017-10-215-9/+9
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-116-0/+6
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-096-0/+6
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-015-9/+9
|
* Define path with __dir__bogdanvlviv2017-05-231-1/+1
| | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* Send deprecation horizon and gem name as arguments to deprecation heavier ↵Willem van Bergen2017-04-192-9/+22
| | | | handler, and make sure they are used for the ActiveSupport::Notifications message.
* Add AS::Deprecation::DeprecatedConstantAccessorDominic Cleal2017-03-221-0/+50
| | | | | | | An alternative to DeprecatedConstantProxy which works more transparently with exceptions because it returns the object that the new constant refers to rather than a proxy. This is then compatible with `rescue OldException`.
* Remove redundant namespaces from sample code of `deprecated_method_warning` ↵kenta-s2017-02-151-3/+3
| | | | [ci skip]
* Fix the return of `deprecate_methods` in doc [ci skip]kenta-s2017-02-141-1/+1
|
* Change ActionView ERB Handler from Erubis to ErubiJeremy Evans2017-01-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | Erubi offers the following advantages for Rails: * Works with ruby's --enable-frozen-string-literal option * Has 88% smaller memory footprint * Does no freedom patching (Erubis adds a method to Kernel) * Has simpler internals (1 file, <150 lines of code) * Has an open development model (Erubis doesn't have a public source control repository or bug tracker) * Is not dead (Erubis hasn't been updated since 2011) Erubi is a simplified fork of Erubis that contains just the parts that are generally needed (which includes the parts that Rails uses). The only intentional difference in behavior is that it does not include support for <%=== tags for debug output. That could be added to the ActionView ERB handler if it is desired. The Erubis template handler remains in a deprecated state so that code that accesses it directly does not break. It can be removed after Rails 5.1.
* Correct caller tracking in delegated deprecation methodsMatthew Draper2016-10-031-0/+13
|
* applies remaining conventions across the projectXavier Noria2016-08-061-2/+2
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-065-9/+9
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* systematic revision of =~ usage in ASXavier Noria2016-07-221-1/+2
| | | | | Where appropriate prefer the more concise Regexp#match?, String#include?, String#start_with?, and String#end_with?
* `behaviour` --> `behavior`Jon Moss2016-05-271-1/+1
| | | | http://edgeguides.rubyonrails.org/api_documentation_guidelines.html#english
* Pass over all Rails 5 warnings, to make sure:Vipul A M2016-04-121-1/+0
| | | | | | | | | | - we are ending sentences properly - fixing of space issues - fixed continuity issues in some sentences. Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 . This change reverts making sure we add '.' at end of deprecation sentences. This is to keep sentences within Rails itself consistent and with a '.' at the end.
* :bomb: run the test @rafaelfranca :angry:Rafael Mendonça França2016-02-241-1/+1
|
* Ignore callstacks from Ruby stdlib in deprecationRafael Mendonça França2016-02-241-4/+12
| | | | Fixes #22982.
* Converting backtrace to strings before calling set_backtraceTony Novak2016-02-101-1/+1
| | | | Fixes #23058
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2016-02-071-2/+2
|\
| * [ci skip] Fix one more typoPrathamesh Sonpatki2016-01-301-1/+1
| | | | | | | | - Followup of https://github.com/rails/docrails/commit/10bc49710b7205a6172c3e072b3c77114fefd952
| * [ci skip] Fix typoyui-knk2016-01-271-1/+1
| |
* | Fix nodoc to internal class error document some of themVipul A M2016-01-251-0/+2
|/ | | | | | | [ci skip] Fixes #20808 [Vipul A M & Julio Lopez]
* Update deprecation_horizon to 5.1 from 5.0 [ci skip]Ryuta Kamizono2016-01-141-3/+3
|
* Fix deprecation message when frame doesn't have absolute_pathRafael Mendonça França2015-11-031-1/+1
| | | | | | When a frame is an eval block without filename argument there is no absolute_path so the previous implementation would fail because `nil` doesn't responds to `start_with?`.
* Fix bug where custom deprecators are not used.Brandon Dunne2015-10-141-12/+36
| | | | | | | | | | | | Add tests for ActiveSupport::Deprecation.deprecate_methods Modify ActiveSupport::Testing::Deprecation to allow a custom deprecator Leverage ActiveSupport::Testing::Deprecation assert_deprecated Update documentation for ActiveSupport::Deprecation.deprecate_methods Use cases: Using the default deprecator => "removed from Rails X.Y" Passing a custom deprecator in the options hash => "removed from MyGem next-release" Deprecating methods directly from custom deprecator => "removed from MyGem next-release"
* Only prepend a single module when defining deprecation wrappers.Charles Oliver Nutter2015-10-131-4/+4
| | | | | I could not find any reason why each method got its own prepended module here, and all tests appear to pass with my change.
* Documentation typoAkira Matsuda2015-09-201-1/+1
| | | | [ci skip]
* use `caller_locations` instead of `caller`Aaron Patterson2015-08-242-3/+14
| | | | | We have `caller_locations`, so we don't need to parse the strings in the callstack.
* A few documentation tweaks [ci skip]Robin Dupret2015-06-072-4/+4
| | | | [Robin Dupret & Shunsuke Aida]
* Merge pull request #20286 from davydovanton/doc-deprecation-behaviorAbdelkader Boudih2015-05-251-0/+12
|\ | | | | Add documentation for Deprecation::Behavior module
| * [skip ci] Add documentation for Deprecation::Behavior moduleAnton Davydov2015-05-251-0/+12
| |
* | s/contstant/constant re #20282 [ci skip]Zachary Scott2015-05-241-2/+2
| |