Permalink
Browse files

More inflector fixes #1599 [foamdino@gmail.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1662 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 930f336 commit f5db702901408d7d74a3dec0cb6cdcaf987223dd @dhh dhh committed Jul 4, 2005
Showing with 14 additions and 5 deletions.
  1. +1 −1 activesupport/CHANGELOG
  2. +6 −3 activesupport/lib/active_support/inflector.rb
  3. +7 −1 activesupport/test/inflector_test.rb
View
@@ -1,6 +1,6 @@
*SVN*
-* Added new rules to the Inflector to deal with more unusual plurals mouse/louse => mice/lice, information => information, ox => oxen, photo => photos, archive => archives #1571, #1583, #1490 [foamdino@gmail.com/others]
+* Added new rules to the Inflector to deal with more unusual plurals mouse/louse => mice/lice, information => information, ox => oxen, virus => viri, archive => archives #1571, #1583, #1490, #1599 [foamdino@gmail.com/others]
* Fixed memory leak with Object#remove_subclasses_of, which inflicted a Rails application running in development mode with a ~20KB leak per request #1289 [c.r.mcgrath@gmail.com]
@@ -58,7 +58,7 @@ def constantize(camel_cased_word)
def plural_rules #:doc:
[
[/(fish)$/i, '\1\2'], # fish
- [/(information)$/i, '\1'], # information (plural noun)
+ [/(information|equipment|money)$/i, '\1'], # plural nouns
[/^(ox)$/i, '\1\2en'], # ox
[/([m|l])ouse/i, '\1ice'], # mouse, louse
[/(x|ch|ss|sh)$/i, '\1es'], # search, switch, fix, box, process, address
@@ -73,8 +73,10 @@ def plural_rules #:doc:
[/(m)an$/i, '\1\2en'], # man, woman, spokesman
[/(c)hild$/i, '\1\2hildren'], # child
[/(photo)$/i, '\1s'],
- [/(o)$/i, '\1\2es'], # buffalo, tomato
+ [/(buffal|tomat)o$/i, '\1\2oes'], # buffalo, tomato
[/(bu)s$/i, '\1\2ses'], # bus
+ [/(alias)/i, '\1es'], # alias
+ [/([octop|vir])us$/i, '\1i'], # octopus, virus - virus has no defined plural (according to Latin/dictionary.com), but viri is better than viruses/viruss
[/s$/i, 's'], # no change (compatibility)
[/$/, 's']
]
@@ -84,7 +86,8 @@ def singular_rules #:doc:
[
[/(f)ish$/i, '\1\2ish'],
[/^(ox)en/i, '\1'],
- [/(photo)s$/i, '\1'],
+ [/(alias)es$/i, '\1'],
+ [/([octop|vir])i$/i, '\1us'],
[/(o)es/i, '\1'],
[/(bus)es$/i, '\1'],
[/([m|l])ice/i, '\1ouse'],
@@ -71,9 +71,15 @@ class InflectorTest < Test::Unit::TestCase
"dwarf" => "dwarves",
"elf" => "elves",
"information" => "information",
+ "equipment" => "equipment",
"bus" => "buses",
"mouse" => "mice",
- "louse" => "lice"
+ "louse" => "lice",
+ "house" => "houses",
+ "octopus" => "octopi",
+ "virus" => "viri",
+ "alias" => "aliases",
+ "portfolio" => "portfolios"
}
CamelToUnderscore = {

0 comments on commit f5db702

Please sign in to comment.