Permalink
Browse files

Fixed Inflector for words like "news" and "series" that are the same …

…in plural and singular #603 [echion], #615 [marcenuc]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@618 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent b1999be commit 603ab7d812931d5f85171393b30665b244a6187e @dhh dhh committed Feb 15, 2005
Showing with 13 additions and 2 deletions.
  1. +2 −0 activesupport/CHANGELOG
  2. +3 −0 activesupport/lib/inflector.rb
  3. +8 −2 activesupport/test/inflector_test.rb
View
@@ -1,3 +1,5 @@
+* Fixed Inflector for words like "news" and "series" that are the same in plural and singular #603 [echion], #615 [marcenuc]
+
* Added Hash#stringify_keys and Hash#stringify_keys!
* Added IndifferentAccess as a way to wrap a hash by a symbol-based store that also can be accessed by string keys
@@ -58,6 +58,7 @@ def constantize(camel_cased_word)
def plural_rules #:doc:
[
[/(x|ch|ss|sh)$/, '\1es'], # search, switch, fix, box, process, address
+ [/series$/, '\1series'],
[/([^aeiouy]|qu)ies$/, '\1y'],
[/([^aeiouy]|qu)y$/, '\1ies'], # query, ability, agency
[/(?:([^f])fe|([lr])f)$/, '\1\2ves'], # half, safe, wife
@@ -75,6 +76,7 @@ def singular_rules #:doc:
[
[/(x|ch|ss)es$/, '\1'],
[/movies$/, 'movie'],
+ [/series$/, 'series'],
[/([^aeiouy]|qu)ies$/, '\1y'],
[/([lr])ves$/, '\1f'],
[/([^f])ves$/, '\1fe'],
@@ -84,6 +86,7 @@ def singular_rules #:doc:
[/men$/, 'man'],
[/status$/, 'status'],
[/children$/, 'child'],
+ [/news$/, 'news'],
[/s$/, '']
]
end
@@ -49,7 +49,13 @@ class InflectorTest < Test::Unit::TestCase
"day" => "days",
"comment" => "comments",
- "foobar" => "foobars"
+ "foobar" => "foobars",
+ "newsletter" => "newsletters",
+
+ "old_news" => "old_news",
+ "news" => "news",
+
+ "series" => "series"
}
CamelToUnderscore = {
@@ -162,4 +168,4 @@ def test_constantize
assert_equal InflectorTest, Inflector.constantize("InflectorTest")
assert_raises(NameError) { Inflector.constantize("UnknownClass") }
end
-end
+end

0 comments on commit 603ab7d

Please sign in to comment.