Class: Quarry::Spec::Markup
Overview
Specification Markup
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Specification.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(file) ⇒ Markup
constructor
A new instance of Markup.
- #parse ⇒ Object
- #parse_section(text, lineno) ⇒ Object
Constructor Details
#initialize(file) ⇒ Markup
Returns a new instance of Markup.
15 16 17 18 19 |
# File 'lib/quarry/spec/markup.rb', line 15 def initialize(file) @file = file @steps = [] parse end |
Instance Attribute Details
#file ⇒ Object (readonly)
Specification
11 12 13 |
# File 'lib/quarry/spec/markup.rb', line 11 def file @file end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
12 13 14 |
# File 'lib/quarry/spec/markup.rb', line 12 def steps @steps end |
Instance Method Details
#description ⇒ Object
65 66 67 |
# File 'lib/quarry/spec/markup.rb', line 65 def description File.basename(file) end |
#parse ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/quarry/spec/markup.rb', line 22 def parse lineno = 0 text = '' File.open(file, 'r') do |f| f.readlines.each_with_index do |line, lineno| case line when /^\s*$/ parse_section(text, lineno) text = '' else text << line end end end end |
#parse_section(text, lineno) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/quarry/spec/markup.rb', line 39 def parse_section(text, lineno) return if text.strip == '' case text when /\A[-=].*?$/, /[-=]\s*\Z/ #text << line steps << Header.new(self, text, lineno) when /^\s+/ last = steps.last case last when Step, Macro last.code << "\n\n#{text.rstrip}" when Comment if last.macro? steps << Macro.new(self, text, lineno, last.type) else steps << Step.new(self, text, lineno) end else steps << Step.new(self, text, lineno) end else steps << Comment.new(self, text, lineno) end end |