提交 4b685aad 编写于 作者: X Xavier Noria

revises the regexp used in titleize

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.
上级 cf9664ad
......@@ -114,7 +114,7 @@ def humanize(lower_case_and_underscored_word)
# "TheManWithoutAPast".titleize # => "The Man Without A Past"
# "raiders_of_the_lost_ark".titleize # => "Raiders Of The Lost Ark"
def titleize(word)
humanize(underscore(word)).gsub(/\b(['’`]?[a-z])/) { $1.capitalize }
humanize(underscore(word)).gsub(/\b(?<!['’`])[a-z]/) { $&.capitalize }
end
# Create the name of a table like Rails does for models to table names. This method
......
......@@ -211,18 +211,21 @@ module InflectorTestCases
}
MixtureToTitleCase = {
'active_record' => 'Active Record',
'ActiveRecord' => 'Active Record',
'action web service' => 'Action Web Service',
'Action Web Service' => 'Action Web Service',
'Action web service' => 'Action Web Service',
'actionwebservice' => 'Actionwebservice',
'Actionwebservice' => 'Actionwebservice',
"david's code" => "David's Code",
"David's code" => "David's Code",
"david's Code" => "David's Code",
"Fred’s" => "Fred’s",
"Fred`s" => "Fred`s"
'active_record' => 'Active Record',
'ActiveRecord' => 'Active Record',
'action web service' => 'Action Web Service',
'Action Web Service' => 'Action Web Service',
'Action web service' => 'Action Web Service',
'actionwebservice' => 'Actionwebservice',
'Actionwebservice' => 'Actionwebservice',
"david's code" => "David's Code",
"David's code" => "David's Code",
"david's Code" => "David's Code",
"sgt. pepper's" => "Sgt. Pepper's",
"i've just seen a face" => "I've Just Seen A Face",
"maybe you'll be there" => "Maybe You'll Be There",
"Fred’s" => "Fred’s",
"Fred`s" => "Fred`s"
}
OrdinalNumbers = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册