Sha256: dd4b7e03310e8e52cf0d704a1faa6cc30e577ff8d524f0ca74ca1f3a4de1eb5f
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require 'quarry/markup/step' module Quarry # = Specification Markup # class Markup attr :file attr :steps # def initialize(file) @file = file @steps = [] parse end # 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 # 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 # def description File.basename(file) end end #class Markup end#module Quarry
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quarry-0.5.0 | lib/quarry/markup.rb |