From 4bd340fbd28769654edb3242794984b165cfb0ea Mon Sep 17 00:00:00 2001 From: leethomas Date: Sat, 14 May 2016 22:23:01 -0700 Subject: [PATCH 1/2] added test cases for new comment parsing rules --- test/test_rake_task.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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) From 355d1ace7b2b8cb669e4e0aa16115c3c84fc5309 Mon Sep 17 00:00:00 2001 From: leethomas Date: Sat, 14 May 2016 22:24:56 -0700 Subject: [PATCH 2/2] update comment parsing rules to exclude non sentence terminating periods, include exclamation marks --- lib/rake/task.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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