aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/methods.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Merge pull request #8156 from fredwu/acronym_fix-master"Steve Klabnik2013-03-161-1/+1
| | | | | | | | | This reverts commit 867dc1700f32aae6f98c4651bd501597e6b52bc0, reversing changes made to 9a421aaa8285cf2a7ecb1af370748b0337818930. This breaks anyone who's using ForceSSL: https://travis-ci.org/rails-api/rails-api/jobs/5556065 Please see comments on #8156 for some discussion.
* Fixed a bug where the inflector would replace camelCase strings and ↵Fred Wu2013-03-171-1/+1
| | | | disregarding specified acronyms, fixes #8015
* Remove unnecessary begin..rescue..end, use only rescueAkira Matsuda2013-01-061-8/+6
|
* Refactor Inflector#ordinal to avoid converting the number twiceCarlos Antonio da Silva2012-11-041-2/+4
|
* update AS/inflector docs [ci skip]Francesco Rodriguez2012-09-141-89/+97
|
* Make ActiveSupport::Inflector locale aware and multilingualDavid Celis2012-07-301-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Inflector is currently not very supportive of internationalized websites. If a user wants to singularize and/or pluralize words based on any locale other than English, they must define each case in locale files. Rather than create large locale files with mappings between singular and plural words, why not allow the Inflector to accept a locale? This patch makes ActiveSupport::Inflector locale aware and uses `:en`` unless otherwise specified. Users will still be provided a list of English (:en) inflections, but they may additionally define inflection rules for other locales. Each list is kept separately and permanently. There is no reason to limit users to one list of inflections: ActiveSupport::Inflector.inflections(:es) do |inflect| inflect.plural(/$/, 's') inflect.plural(/([^aeéiou])$/i, '\1es') inflect.plural(/([aeiou]s)$/i, '\1') inflect.plural(/z$/i, 'ces') inflect.plural(/á([sn])$/i, 'a\1es') inflect.plural(/é([sn])$/i, 'e\1es') inflect.plural(/í([sn])$/i, 'i\1es') inflect.plural(/ó([sn])$/i, 'o\1es') inflect.plural(/ú([sn])$/i, 'u\1es') inflect.singular(/s$/, '') inflect.singular(/es$/, '') inflect.irregular('el', 'los') end 'ley'.pluralize(:es) # => "leyes" 'ley'.pluralize(:en) # => "leys" 'avión'.pluralize(:es) # => "aviones" 'avión'.pluralize(:en) # => "avións" A multilingual Inflector should be of use to anybody that is tasked with internationalizing their Rails application. Signed-off-by: David Celis <david@davidcelis.com>
* make sure the inflection rules are loaded when cherry-picking ↵Xavier Noria2012-06-291-0/+1
| | | | active_support/core_ext/string/inflections.rb [fixes #6884]
* Fix warning: shadowing outer local variable - constant.kennyj2012-05-191-3/+3
|
* Handle case where ancestor is not the end of the chainAndrew White2012-05-191-7/+12
|
* Fix constantize so top level constants are looked up properly.Marc-Andre Lafortune2012-05-191-1/+1
|
* Make constantize look down the ancestor chain (excluding Object)Marc-Andre Lafortune2012-05-191-1/+13
|
* removing unnecessary 'examples' noise from activesupportFrancesco Rodriguez2012-05-131-13/+0
|
* fix typo in ActiveSupport::Inflector#titleizeFrancesco Rodriguez2012-04-281-1/+1
|
* revises the regexp used in titleizeXavier Noria2012-04-071-1/+1
| | | | | | | | | The regexp used in titleize matches saxon genitive and other contractions, only to call capitalize on the captured text and have the apostrophe upcased which yields the apostrophe itself. It is more clear that the regexp matches just what it has to match.
* Updated/changed useless tr/gsubsJurriaan Pruis2012-04-031-1/+1
|
* Fix typoArtyom Bolshakov2012-04-031-1/+1
|
* String#titleize works properly with smart quotes, closes #5584Vasiliy Ermolovich2012-03-261-2/+4
|
* Inflector/constantize - inject method lets us to avoid using another variablehoma2012-02-281-5/+3
|
* prefer tr to gsub for replacing charactersXavier Noria2012-02-121-2/+2
|
* inflection regexp are meant to be applied onceXavier Noria2012-02-121-2/+2
|
* removes redundant argumentXavier Noria2012-02-121-1/+1
|
* boosts inflectionsXavier Noria2012-02-121-1/+1
| | | | | The impact of this change has been measured pluralizing the entire /usr/share/dict/words, showing a 6x speedup
* Add ActiveSupport::Inflector.ordinal and Integer#ordinalTim Gildea2012-02-041-10/+24
|
* There is an "inherit" option on const_get too, why not use it?Semyon Perepelitsa2012-01-311-1/+1
|
* safe_constantize should handle wrong constant name NameErrors Fixes #4710Alex Tambellini2012-01-261-1/+1
|
* global variables may not be set depending on the match. fixes #4703Aaron Patterson2012-01-261-1/+4
|
* Change ActiveRecord::Errors to ActiveModel::Errors in guidesCarlos Antonio da Silva2012-01-251-6/+6
| | | | | | | Use ActiveModel::Errors in inflection example docs as well. Also fixes wrong information and link to locale file related to Errors#full_messages in I18n guide.
* remove ruby 1.8 checking in constantize methodVasiliy Ermolovich2011-12-291-39/+24
|
* fix typo again (Thanks Phillip Oertel)Vijay Dev2011-11-081-1/+1
|
* fix typoVijay Dev2011-11-061-1/+1
|
* Refactored pluralize and singularize into a common method.Henrik Hodne2011-11-061-16/+18
| | | | See diff discussion on rails/#3536.
* defines Module#qualified_const_(defined?|get|set) and String#deconstantizeXavier Noria2011-10-291-6/+23
| | | | | | | | | | This commit also implements a faster version of #demodulize I was unable to isolate with git add --patch. Not a big fan of the name #deconstantize. It complements #demodulize getting rid of the rightmost constant, hence the name, but it is unrelated to the well-known #constantize. So unsure. Could not come with anything better, please feel free to rename.
* let demodulize do less work, and add testsXavier Noria2011-10-291-1/+3
| | | | This is also faster on 1.9.
* Update CHANGELOG for safe_constantize.José Valim2011-09-231-1/+4
|
* Ensure that constantize just rescues NameError that applies to the constant ↵José Valim2011-09-231-4/+20
| | | | being currently loaded.
* Added ActiveSupport::Inflector.safe_constantize and String#safe_constantize; ↵Ryan Oblak2011-09-231-0/+27
| | | | refactored common constantize tests into ConstantizeTestCases
* Revert removing gsub and sub from safe buffer.José Valim2011-09-081-24/+8
|
* remove support of symbols on classify and camelizeDamien Mathieu2011-09-081-0/+16
|
* make gsub and sub unavailable in SafeBuffers - Closes #1555Damien Mathieu2011-09-081-8/+8
|
* Add more examples to #titleizePol Llovet2011-07-091-2/+4
|
* Add acronym support to Inflector; Issue #1366David Lee2011-06-111-7/+10
|
* RefactorDavid Lee2011-06-111-0/+92
|
* adds code examples for negative ordinalizeVijay Dev2011-05-081-1/+3
|
* ordinalize negative numbers patchJason2011-05-071-2/+2
| | | | | | | Applied patch by Amir Manji https://github.com/rails/rails/issues/437#issuecomment-1116045 Signed-off-by: Jason <jasonmichaelroth@gmail.com>
* camelize and underscore are sort of inverse of each other, but not in a ↵Xavier Noria2010-07-221-1/+11
| | | | mathematical sense [#5174 state:resolved]
* Avoid unnecessary allocations in Inflector.underscore [#3626 state:resolved]Joe Van Dyk2010-04-121-5/+7
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Avoid calling triggering const_missing if const_missing is private when ↵Carl Lerche2010-02-181-1/+1
| | | | doing constantize
* Break up inflector to reduce the dependency burden on dependency-les methods ↵Yehuda Katz2009-11-071-0/+139
like constantize.