Sha256: db455c981aee11077f3a04d4a55d82b942aa9c3ab2c6c395d53ec6e9a3317d7a
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Stack module Parsable attr_accessor :raw attr_accessor :data attr_accessor :inline_data def parse!(raw_doc = self.raw, defaults = { }) self.data, self.raw = extract_yaml(raw_doc, nil, defaults) puts self.data end def payload self.data.deep_symbolize.merge(:inline_data => inline_data) end def extract_yaml(raw, replace = nil, defaults = { }) self.inline_data = [ ] data_table = defaults out = raw.dup i = -1 puts "out -> #{out}" while out =~ /^(---\s*\n.*?\n?)(---.*?\n)/m yaml = $1.dup out = out.gsub(/#{Regexp.escape(yaml)}#{Regexp.escape($2)}/m,((i>-1) ? "{{ document.inline_data[#{i}] | render_table }}" : "")) puts "out2 -> #{out}" d = YAML.load(yaml) if d.is_a?(Hash) self.inline_data << d if i > -1 data_table = data_table.deep_merge(d) end d = nil; i += 1; end data_table = data_table.deep_symbolize return data_table, out end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stack-0.0.3 | lib/stack/parsable.rb |