diff options
author | Vasiliy Ermolovich <younash@gmail.com> | 2012-03-26 21:17:25 +0300 |
---|---|---|
committer | Vasiliy Ermolovich <younash@gmail.com> | 2012-03-26 21:18:25 +0300 |
commit | 633ee64e20da05ddbcab67558351733ba511a444 (patch) | |
tree | 1cf5ec448798d605055f1d513192669ed0ff646b | |
parent | 1d59caa975a9919a418a08bbaabfa62f0d9dafcd (diff) | |
download | rails-633ee64e20da05ddbcab67558351733ba511a444.tar.gz rails-633ee64e20da05ddbcab67558351733ba511a444.tar.bz2 rails-633ee64e20da05ddbcab67558351733ba511a444.zip |
String#titleize works properly with smart quotes, closes #5584
-rw-r--r-- | activesupport/lib/active_support/inflector/methods.rb | 6 | ||||
-rw-r--r-- | activesupport/test/inflector_test_cases.rb | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 48ea5653c7..4cebad742f 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'active_support/inflector/inflections' module ActiveSupport @@ -112,7 +114,7 @@ module ActiveSupport # "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])/) { $1.capitalize } end # Create the name of a table like Rails does for models to table names. This method @@ -209,7 +211,7 @@ module ActiveSupport def constantize(camel_cased_word) #:nodoc: names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? - + names.inject(Object) do |constant, name| constant.const_get(name, false) end diff --git a/activesupport/test/inflector_test_cases.rb b/activesupport/test/inflector_test_cases.rb index 809b8b46c9..879c3c1125 100644 --- a/activesupport/test/inflector_test_cases.rb +++ b/activesupport/test/inflector_test_cases.rb @@ -220,7 +220,9 @@ module InflectorTestCases 'Actionwebservice' => 'Actionwebservice', "david's code" => "David's Code", "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" } OrdinalNumbers = { |