Sha256: 46bdd1b964d98a59d6699b9da5c93914374a3659c98c6c760c52a951830b093d
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
module PDF module Storycards class StoryParser def parse_stories(story_text) all_stories = [] story_groups = story_text.split(/^\.$/) story_groups.each do |story_group| all_stories << parse_story_group(story_group) end return all_stories.flatten end def parse_story_group(story_text) meta_data = extract_meta_data(story_text) story_mediator = StoryCapturingMediator.new rspec_story_parser = Spec::Story::Runner::StoryParser.new(story_mediator) rspec_story_parser.parse(story_text.split("\n")) stories = story_mediator.stories stories.each do |story| story.meta_data = meta_data end stories end def extract_meta_data(story_text) meta_data = {} story_text.split("\n").each do |line| match_data = /^([^ :]+):(.*)$/.match(line) unless match_data.nil? name = match_data[1].strip value = match_data[2].strip break if name == 'Story' meta_data[name] = value end end meta_data end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pdf-storycards-0.1.0 | lib/pdf/storycards/story_parser.rb |