class Giblish::DocInfo
Container class for bundling together the data we cache for each asciidoc file we come across
Attributes
converted[RW]
doc_id[RW]
error_msg[RW]
history[RW]
purpose_str[RW]
rel_path[R]
src_file[R]
status[RW]
stderr[RW]
title[R]
Public Class Methods
new(adoc: nil, dst_root_abs: nil, adoc_stderr: "")
click to toggle source
# File lib/giblish/docinfo.rb, line 28 def initialize(adoc: nil, dst_root_abs: nil, adoc_stderr: "") @src_file = nil @history = [] @converted = true @stderr = adoc_stderr return unless adoc # Get the purpose info if it exists @purpose_str = get_purpose_info adoc # fill in doc meta data d_attr = adoc.attributes self.src_file = (d_attr["docfile"]) self.title = (adoc.doctitle) @doc_id = d_attr["docid"] return if dst_root_abs.nil? # Get the relative path beneath the root dir to the doc @rel_path = Pathname.new( "#{d_attr['outdir']}/#{d_attr['docname']}#{d_attr['docfilesuffix']}".encode("utf-8") ).relative_path_from(dst_root_abs) end
Public Instance Methods
src_file=(rhs)
click to toggle source
# File lib/giblish/docinfo.rb, line 24 def src_file=(rhs) @src_file = rhs.nil? ? nil : rhs.encode("utf-8") end
title=(rhs)
click to toggle source
these members can have encoding issues when running in a mixed Windows/Linux setting. that is why we explicitly encodes them when writing to them
# File lib/giblish/docinfo.rb, line 20 def title=(rhs) @title = rhs.nil? ? nil : rhs.encode("utf-8") end
to_s()
click to toggle source
# File lib/giblish/docinfo.rb, line 51 def to_s "DocInfo: title: #{@title} src_file: #{@src_file}" end
Private Instance Methods
get_purpose_info(adoc)
click to toggle source
# File lib/giblish/docinfo.rb, line 57 def get_purpose_info(adoc) # Get the 'Purpose' section if it exists purpose_str = String.new("") adoc.blocks.each do |section| next unless section.is_a?(Asciidoctor::Section) && (section.level == 1) && (section.name =~ /^Purpose$/) # filter out 'odd' text, such as lists etc... section.blocks.each do |bb| next unless bb.is_a?(Asciidoctor::Block) purpose_str << "#{bb.source}\n+\n" end end purpose_str end