Sha256: a0f4178986a96dab57f6bea5a391ea9ce9bb31dbdc5d3fad6c13b0184d3d4547
Contents?: true
Size: 1.41 KB
Versions: 9
Compression:
Stored size: 1.41 KB
Contents
module Saga class Parser attr_accessor :document def initialize @tokenizer = ::Saga::Tokenizer.new(self) @document = ::Saga::Document.new @current_section = :title @current_header = '' end def parse(input) @tokenizer.process(input) @document end def handle_author(author) @document.authors << author end def handle_story(story) @current_section = :stories @document.stories[@current_header] ||= [] @document.stories[@current_header] << story end def handle_definition(definition) @current_section = :definitions @document.definitions[@current_header] ||= [] @document.definitions[@current_header] << definition end def handle_string(string) return if string.strip == '' return(@current_section = :body) if string.strip == 'USER STORIES' if :title == @current_section @document.title = string.gsub(/^requirements/i, '').strip @current_section = :introduction elsif :introduction == @current_section @document.introduction << string elsif :stories == @current_section and string[0,2] == ' ' @document.stories[@current_header][-1][:notes] = string.strip else @current_header = string.strip end end def self.parse(input) parser = new parser.parse(input) end end end
Version data entries
9 entries across 9 versions & 1 rubygems