class DeployDoc::TestPlan::AnnotationParser
Constants
- Annotation
- BLOCK_END
- BLOCK_START
- INLINE_END
- INLINE_START
- SINGLE_LINE
Public Class Methods
new(markdown, source_name="<unknown>")
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 10 def initialize(markdown, source_name="<unknown>") @source_name = source_name @markdown_lines = markdown.split("\n") end
parse(markdown, path="<unknown>")
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 6 def self.parse(markdown, path="<unknown>") AnnotationParser.new(markdown, path).parse! end
Public Instance Methods
parse!()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 15 def parse! @annotations = [] @parse_idx = 0 while !eof_reached? parse_block || parse_inline || parse_single_line || parse_text end @annotations end
Private Instance Methods
current_line()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 107 def current_line @markdown_lines[@parse_idx] end
current_line_nr()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 111 def current_line_nr @parse_idx + 1 end
eof_reached?()
click to toggle source
Helper functions ####
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 103 def eof_reached? @parse_idx >= @markdown_lines.length end
inc_line()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 115 def inc_line @parse_idx+=1 end
parse_block()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 40 def parse_block if (match = BLOCK_START.match(current_line)).nil? false else inc_line start_line = current_line_nr kind = match["kind"] params = match["params"].split(/\s+/) content = "" loop do if eof_reached? raise("Unexpected end of file; --> not closed? started on #{@source_name}:#{start_line}") elsif !(BLOCK_END.match(current_line).nil?) end_line = current_line_nr() -1 @annotations << Annotation.new(@source_name, [start_line, end_line], kind, params, content) return true else content += current_line + "\n" end inc_line end true end end
parse_inline()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 65 def parse_inline if (match = INLINE_START.match(current_line)).nil? false else inc_line start_line = current_line_nr kind = match["kind"] params = match["params"].split(/\s+/) content = "" loop do if eof_reached? raise("Unexpected end of file; --> not closed? started on #{@source_name}:#{start_line}") elsif !(INLINE_END.match(current_line).nil?) end_line = current_line_nr() -1 @annotations << Annotation.new(@source_name, [start_line, end_line], kind, params, content) return true else content += current_line + "\n" end inc_line end true end end
parse_single_line()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 90 def parse_single_line if (match = SINGLE_LINE.match(current_line)).nil? false else kind = match["kind"] params = match["params"].split(/\s+/) @annotations << Annotation.new(@source_name, [current_line_nr, current_line_nr], kind, params, nil) inc_line end end
parse_text()
click to toggle source
# File lib/deploy_doc/test_plan/annotator_parser.rb, line 28 def parse_text inc_line # ignore text, line by line end