Inflector irregular singularize rules #8671

Merged
merged 1 commit into from Jan 21, 2013
View
3 activesupport/lib/active_support/inflector/inflections.rb
@@ -132,13 +132,16 @@ def irregular(singular, plural)
plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + plural[1..-1])
singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
+ singular(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + singular[1..-1])
else
plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
plural(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
plural(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
+ singular(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
+ singular(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
end
end
View
1 activesupport/test/inflector_test_cases.rb
@@ -310,5 +310,6 @@ module InflectorTestCases
'move' => 'moves',
'cow' => 'kine',
'zombie' => 'zombies',
+ 'genus' => 'genera'
}
end