Browse files

Light refactoring.

  • Loading branch information...
1 parent 97172ab commit 60b3ace6391831b20e10e0bc638025bdf0d376d2 @tobie committed May 22, 2010
Showing with 8 additions and 7 deletions.
  1. +2 −1 lib/pdoc/parser/fragment.rb
  2. +6 −6 test/unit/parser/test_fragment.rb
View
3 lib/pdoc/parser/fragment.rb
@@ -10,7 +10,7 @@ def initialize(string, line_number)
@string = string
end
- def normalize
+ def normalized_lines
# Cleans up the text by removing opening and closing comment tags
# and removing the prefix off of every line.
# Raises and error if prefix are inconsistent. (Prefix is calculated
@@ -37,6 +37,7 @@ def prefix
def prefix_regexp
@prefix_regexp ||= Regexp.new('^' << Regexp.escape(prefix))
end
+ private(:prefix_regexp)
def lines
@lines ||= @string.split("\n")
View
12 test/unit/parser/test_fragment.rb
@@ -4,44 +4,44 @@
class TestFragment < Test::Unit::TestCase
- def test_normalize_empty_fragment
+ def test_normalized_lines_of_empty_fragment
fragment =<<EOF
/**
*
*
**/
EOF
fragment = PDoc::Fragment.new(fragment, 0)
- lines = fragment.normalize
+ lines = fragment.normalized_lines
assert_equal("", lines[0])
assert_equal("", lines[1])
assert_equal("", lines.last)
end
- def test_normalize_basic_fragment
+ def test_normalized_lines_of_basic_fragment
fragment =<<EOF
/**
* foo
* bar
**/
EOF
fragment = PDoc::Fragment.new(fragment, 0)
- lines = fragment.normalize
+ lines = fragment.normalized_lines
assert_equal("", lines[0])
assert_equal("foo", lines[1])
assert_equal(" bar", lines[2])
assert_equal("", lines.last)
end
- def test_normalize_broken_fragment
+ def test_normalized_lines_of_broken_fragment
fragment =<<EOF
/**
* foo
*bar
**/
EOF
assert_raise PDoc::Fragment::InconsistentPrefixError do
- PDoc::Fragment.new(fragment, 0).normalize
+ PDoc::Fragment.new(fragment, 0).normalized_lines
end
end

0 comments on commit 60b3ace

Please sign in to comment.