1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Don't break task descriptions on a period that appears in the middle of a sentence

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@7153 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2007-06-29 02:43:16 +00:00
parent 468cc8682c
commit 8bb848087e
3 changed files with 13 additions and 3 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Don't break task descriptions on a period that appears in the middle of a sentence [Jamis Buck]
* Added support for :on_error => :continue in task definitions, allowing tasks to effectively ignore connection and execution errors that occur as they run [Rob Holland]
* Use correct parameters for Logger constructor in the SCM and Strategy base initializers [Jamis Buck]

View file

@ -49,7 +49,7 @@ module Capistrano
# given, the result will be truncated if it is longer than +max_length+,
# and an ellipsis appended.
def brief_description(max_length=nil)
brief = description[/^.*?\./] || description
brief = description[/^.*?\.(?=\s|$)/] || description
if max_length && brief.length > max_length
brief = brief[0,max_length-3] + "..."

View file

@ -79,15 +79,23 @@ class TaskDefinitionTest < Test::Unit::TestCase
assert_equal "Here is a line wrapped with spacing in it.\n\n foo bar\n baz bang", task.description
end
def test_task_brief_description_should_return_first_sentence_in_description
def test_brief_description_should_return_first_sentence_in_description
desc = "This is the task. It does all kinds of things."
task = new_task(:testing, @namespace, :desc => desc)
assert_equal "This is the task.", task.brief_description
end
def test_task_brief_description_should_truncate_if_length_given
def test_brief_description_should_truncate_if_length_given
desc = "This is the task that does all kinds of things. And then some."
task = new_task(:testing, @namespace, :desc => desc)
assert_equal "This is the task ...", task.brief_description(20)
end
def test_brief_description_should_not_break_at_period_in_middle_of_sentence
task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it.")
assert_equal "Take file.txt and copy it.", task.brief_description
task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it. Then do something else.")
assert_equal "Take file.txt and copy it.", task.brief_description
end
end