Class: PDF::Storycards::StoryParser

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/storycards/story_parser.rb

Instance Method Summary collapse

Instance Method Details

#extract_meta_data(story_text) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pdf/storycards/story_parser.rb', line 26

def (story_text)
   = {}
  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'
      [name] = value
    end
  end
  
end

#parse_stories(story_text) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/pdf/storycards/story_parser.rb', line 5

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

#parse_story_group(story_text) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pdf/storycards/story_parser.rb', line 14

def parse_story_group(story_text)
   = (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. = 
  end
  stories
end