Skip to content

Commit 60b3ace

Browse files
committed
Light refactoring.
1 parent 97172ab commit 60b3ace

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/pdoc/parser/fragment.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(string, line_number)
1010
@string = string
1111
end
1212

13-
def normalize
13+
def normalized_lines
1414
# Cleans up the text by removing opening and closing comment tags
1515
# and removing the prefix off of every line.
1616
# Raises and error if prefix are inconsistent. (Prefix is calculated
@@ -37,6 +37,7 @@ def prefix
3737
def prefix_regexp
3838
@prefix_regexp ||= Regexp.new('^' << Regexp.escape(prefix))
3939
end
40+
private(:prefix_regexp)
4041

4142
def lines
4243
@lines ||= @string.split("\n")

test/unit/parser/test_fragment.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@
44

55
class TestFragment < Test::Unit::TestCase
66

7-
def test_normalize_empty_fragment
7+
def test_normalized_lines_of_empty_fragment
88
fragment =<<EOF
99
/**
1010
*
1111
*
1212
**/
1313
EOF
1414
fragment = PDoc::Fragment.new(fragment, 0)
15-
lines = fragment.normalize
15+
lines = fragment.normalized_lines
1616
assert_equal("", lines[0])
1717
assert_equal("", lines[1])
1818
assert_equal("", lines.last)
1919
end
2020

21-
def test_normalize_basic_fragment
21+
def test_normalized_lines_of_basic_fragment
2222
fragment =<<EOF
2323
/**
2424
* foo
2525
* bar
2626
**/
2727
EOF
2828
fragment = PDoc::Fragment.new(fragment, 0)
29-
lines = fragment.normalize
29+
lines = fragment.normalized_lines
3030
assert_equal("", lines[0])
3131
assert_equal("foo", lines[1])
3232
assert_equal(" bar", lines[2])
3333
assert_equal("", lines.last)
3434
end
3535

36-
def test_normalize_broken_fragment
36+
def test_normalized_lines_of_broken_fragment
3737
fragment =<<EOF
3838
/**
3939
* foo
4040
*bar
4141
**/
4242
EOF
4343
assert_raise PDoc::Fragment::InconsistentPrefixError do
44-
PDoc::Fragment.new(fragment, 0).normalize
44+
PDoc::Fragment.new(fragment, 0).normalized_lines
4545
end
4646
end
4747

0 commit comments

Comments
 (0)