Sha256: f67cec81a96f9be487060bf9055ce6ca43de8191afb97b752c5a06473ddc7b1d
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'erb' require 'vedeu/support/helpers' require 'vedeu/output/text_adaptor' module Vedeu class ERBParser include Helpers def self.parse(object) new(object).parse end def initialize(object) @object = object @output = '' end def parse { interfaces: [ { name: interface, lines: TextAdaptor.adapt(erb_output) } ] } end private attr_reader :object def capture(&block) erbout = eval('_erbout', block.binding) erbout_length = erbout.length block.call erbout_addition = erbout[erbout_length..-1] erbout[erbout_length..-1] = '' erbout_addition = erbout_addition.join if erbout_addition.is_a? Array erbout_addition end def erb_output ERB.new(template, nil, '-').result(get_binding) end def interface object.interface end def template File.read(object.path) end def get_binding object.send(:binding) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.6 | lib/vedeu/output/erb_parser.rb |
vedeu-0.1.5 | lib/vedeu/output/erb_parser.rb |
vedeu-0.1.4 | lib/vedeu/output/erb_parser.rb |