Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Light refactoring.

  • Loading branch information...
commit 60b3ace6391831b20e10e0bc638025bdf0d376d2 1 parent 97172ab
@tobie authored
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,7 +4,7 @@
class TestFragment < Test::Unit::TestCase
- def test_normalize_empty_fragment
+ def test_normalized_lines_of_empty_fragment
fragment =<<EOF
/**
*
@@ -12,13 +12,13 @@ def test_normalize_empty_fragment
**/
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
@@ -26,14 +26,14 @@ def test_normalize_basic_fragment
**/
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
@@ -41,7 +41,7 @@ def test_normalize_broken_fragment
**/
EOF
assert_raise PDoc::Fragment::InconsistentPrefixError do
- PDoc::Fragment.new(fragment, 0).normalize
+ PDoc::Fragment.new(fragment, 0).normalized_lines
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.