From 64612db7cf85aee8434e7b9b4fd8d6d0249c60e4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 1 Jul 2005 16:57:58 +0000 Subject: Added new rules to the Inflector to deal with more unusual plurals mouse/louse => mice/lice, information => information, ox => oxen #1571 [foamdino@gmail.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1582 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/CHANGELOG | 2 ++ activesupport/lib/active_support/inflector.rb | 9 +++++++++ activesupport/test/inflector_test.rb | 12 +++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index b73488f60e..aa9f5b887d 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added new rules to the Inflector to deal with more unusual plurals mouse/louse => mice/lice, information => information, ox => oxen #1571 [foamdino@gmail.com] + * 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] * Made 1.year == 365.25.days to account for leap years. This allows you to do User.find(:all, :conditions => ['birthday > ?', 50.years.ago]) without losing a lot of days. #1488 [tuxie@dekadance.se] diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index 2f2b37f52a..dc0d57b901 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -58,6 +58,9 @@ module Inflector def plural_rules #:doc: [ [/(fish)$/i, '\1\2'], # fish + [/(information)$/i, '\1'], # information (plural noun) + [/^(ox)$/i, '\1\2en'], # ox + [/([m|l])ouse/i, '\1ice'], # mouse, louse [/(x|ch|ss|sh)$/i, '\1es'], # search, switch, fix, box, process, address [/(series)$/i, '\1\2'], [/([^aeiouy]|qu)ies$/i, '\1y'], @@ -68,6 +71,8 @@ module Inflector [/(p)erson$/i, '\1\2eople'], # person, salesperson [/(m)an$/i, '\1\2en'], # man, woman, spokesman [/(c)hild$/i, '\1\2hildren'], # child + [/(o)$/i, '\1\2es'], # buffalo, tomato + [/(bu)s$/i, '\1\2ses'], # bus [/s$/i, 's'], # no change (compatibility) [/$/, 's'] ] @@ -76,6 +81,10 @@ module Inflector def singular_rules #:doc: [ [/(f)ish$/i, '\1\2ish'], + [/^(ox)en/i, '\1'], + [/(o)es/i, '\1'], + [/(bus)es$/i, '\1'], + [/([m|l])ice/i, '\1ouse'], [/(x|ch|ss|sh)es$/i, '\1'], [/(m)ovies$/i, '\1\2ovie'], [/(s)eries$/i, '\1\2eries'], diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index 670ab83317..b95d543304 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -60,7 +60,17 @@ class InflectorTest < Test::Unit::TestCase "series" => "series", - "perspective" => "perspectives" + "perspective" => "perspectives", + + "ox" => "oxen", + "buffalo" => "buffaloes", + "tomato" => "tomatoes", + "dwarf" => "dwarves", + "elf" => "elves", + "information" => "information", + "bus" => "buses", + "mouse" => "mice", + "louse" => "lice" } CamelToUnderscore = { -- cgit v1.2.3