diff --git a/lib/rake/task.rb b/lib/rake/task.rb index 1d3244d2b..5300b6fc4 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -304,10 +304,10 @@ def transform_comments(separator, &block) private :transform_comments # Get the first sentence in a string. The sentence is terminated - # by the first period or the end of the line. Decimal points do - # not count as periods. + # by the first period, exclamation mark, or the end of the line. + # Decimal points do not count as periods. def first_sentence(string) - string.split(/\.[ \t]|\.$|\n/).first + string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first end private :first_sentence diff --git a/test/test_rake_task.rb b/test/test_rake_task.rb index 63ff86556..d9e13bd60 100644 --- a/test/test_rake_task.rb +++ b/test/test_rake_task.rb @@ -352,12 +352,24 @@ def test_comment_setting assert_equal "A Comment", t.comment end - def test_comments_with_sentences + def test_comments_with_sentences_period desc "Comment 1. Comment 2." t = task(:t, :name, :rev) assert_equal "Comment 1", t.comment end + def test_comments_with_sentences_exclamation_mark + desc "An exclamation mark! Comment." + t = task(:t, :name, :rev) + assert_equal "An exclamation mark", t.comment + end + + def test_comments_with_many_periods + desc "This is a test...I think ... testing. Comment." + t = task(:t, :name, :rev) + assert_equal "This is a test...I think ... testing", t.comment + end + def test_comments_with_tabbed_sentences desc "Comment 1.\tComment 2." t = task(:t, :name, :rev)