class ProoConfig
This class handles the configuration of WortSammler framework
Attributes
downstream_tracefile[R]
editions[R]
format[R]
frontmatter[R]
input[R]
mdreaderoptions[R]
mdwriteroptions[R]
outdir[R]
outname[R]
reqtracefile_base[R]
rootdir[R]
snippets[R]
stylefiles[R]
traceSortOrder[R]
upstream_tracefiles[R]
vars[R]
Public Class Methods
new()
click to toggle source
constructor
# File lib/wortsammler/class.proolib.rb, line 341 def initialize @mdreaderoptions = %w{ +fenced_code_blocks +compact_definition_lists -space_in_atx_header }.join() @mdwriteroptions = %w{ -backtick_code_blocks +fenced_code_blocks +compact_definition_lists +space_in_atx_header +yaml_metadata_block }.join() end
Public Instance Methods
load_from_file(configFileName, configSelect=nil)
click to toggle source
@param [String] configFileName name of the configfile (without .yaml) @param [Symbol] configSelect Default configuration. If not specified
the very first entry in the config file will apply. TODO: not yet implemented.
@return [ProoConfig] instance
# File lib/wortsammler/class.proolib.rb, line 363 def load_from_file(configFileName, configSelect=nil) begin config = YAML.load(File.new(configFileName)) rescue Exception => e unless File.exist?(configFileName) then $log.error "config file not found '#{configFileName}'" else $log.error "config file could not be loaded '#{configFileName}'" if File.directory?(configFileName) then # note that windows does not disinguish this. $log.error "#{configFileName} is a directory" end $log.error "reason '#{e.message}'" end exit(false) end basePath = File.dirname(configFileName) # this makes an absolute path based on the absolute path # of the configuration file expand_path =lambda do |lf| File.expand_path("#{basePath}/#{lf}") end #activeConfigs=config.select{|x| [x[:name]] & ConfigSelet} selectedConfig = config.first #TODO: check the config file #TODO: refactor the configuration processing @input = selectedConfig[:input].map { |file| File.expand_path("#{basePath}/#{file}") } @outdir = File.expand_path("#{basePath}/#{selectedConfig[:outdir]}") @outname = selectedConfig[:outname] @format = selectedConfig[:format] @traceSortOrder = selectedConfig[:traceSortOrder] @vars = selectedConfig[:vars] || {} @editions = selectedConfig[:editions] || nil @downstream_tracefile = selectedConfig[:downstream_tracefile] || nil @reqtracefile_base = selectedConfig[:reqtracefile_base] #todo expand path @upstream_tracefiles = selectedConfig[:upstream_tracefiles] || nil @upstream_tracefiles = @upstream_tracefiles.map { |file| File.expand_path("#{basePath}/#{file}") } unless @upstream_tracefiles.nil? @frontmatter = selectedConfig[:frontmatter] || nil @frontmatter = selectedConfig[:frontmatter].map { |file| File.expand_path("#{basePath}/#{file}") } unless @frontmatter.nil? @rootdir = basePath @mdreaderoptions = selectedConfig[:mdreaderoptions].join() if selectedConfig[:mdreaderoptions] @mdwriteroptions = selectedConfig[:mdwriteroptions].join() if selectedConfig[:mdwriteroptions] stylefiles = selectedConfig[:stylefiles] || nil if stylefiles.nil? @stylefiles = { :latex => expand_path.call("../ZSUPP_Styles/default.latex"), :docx => expand_path.call("../ZSUPP_Styles/default.docx"), :html => expand_path.call("../ZSUPP_Styles/default.css") } else @stylefiles = stylefiles.map { |key, value| { key => expand_path.call(value) } }.reduce(:merge) end snippets = selectedConfig[:snippets] if snippets.nil? @snippets = nil else @snippets = snippets.map { |file| File.expand_path("#{basePath}/#{file}") } end end