aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorAlexey Gaziev <alex.gaziev@gmail.com>2012-04-29 13:42:40 +0400
committerAlexey Gaziev <alex.gaziev@gmail.com>2012-04-29 13:42:40 +0400
commit076536433f0eb3e684c8e7a571223c274c179b5e (patch)
treea51ec490b96b458aaa13effe92462795c14404f3 /activesupport/lib
parente6ab0d56cf5d376f4b351282c606ecc74e6fad9a (diff)
downloadrails-076536433f0eb3e684c8e7a571223c274c179b5e.tar.gz
rails-076536433f0eb3e684c8e7a571223c274c179b5e.tar.bz2
rails-076536433f0eb3e684c8e7a571223c274c179b5e.zip
Tests for regexp separator in String#truncate
https://github.com/rails/rails/commit/5a7513593f64e0ff7e4de1ee37bac5eeddfae270
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/string/filters.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb
index 9ef410c38b..32a37296d5 100644
--- a/activesupport/lib/active_support/core_ext/string/filters.rb
+++ b/activesupport/lib/active_support/core_ext/string/filters.rb
@@ -25,11 +25,14 @@ class String
# 'Once upon a time in a world far far away'.truncate(27)
# # => "Once upon a time in a wo..."
#
- # Pass a <tt>:separator</tt> to truncate +text+ at a natural break:
+ # Pass a string or regexp <tt>:separator</tt> to truncate +text+ at a natural break:
#
# 'Once upon a time in a world far far away'.truncate(27, :separator => ' ')
# # => "Once upon a time in a..."
#
+ # 'Once upon a time in a world far far away'.truncate(27, :separator => /\s/)
+ # # => "Once upon a time in a..."
+ #
# The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...")
# for a total length not exceeding <tt>:length</tt>:
#