Skip to content

Commit

Permalink
Merge pull request #134 from leethomas/update-comment-parsing-rules
Browse files Browse the repository at this point in the history
Update comment parsing rules
  • Loading branch information
hsbt committed May 16, 2016
2 parents a238c04 + 355d1ac commit f67c571
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion test/test_rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f67c571

Please sign in to comment.