Skip to content

Commit

Permalink
Don't break task descriptions on a period that appears in the middle …
Browse files Browse the repository at this point in the history
…of a sentence

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@7153 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Jun 29, 2007
1 parent 183308c commit 58c7b7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/task_definition.rb
Expand Up @@ -49,7 +49,7 @@ def description(rebuild=false)
# 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] + "..."
Expand Down
12 changes: 10 additions & 2 deletions test/task_definition_test.rb
Expand Up @@ -79,15 +79,23 @@ def test_description_munging_should_be_sensitive_to_code_blocks
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

0 comments on commit 58c7b7a

Please sign in to comment.