class BuildConfigStep
Public Class Methods
new(step)
click to toggle source
# File lib/liquidoc.rb, line 326 def initialize step @step = step if (defined?(@step['action'])).nil? raise "ConfigStructError" end @step['options'] = nil unless defined?(step['options']) validate() end
Public Instance Methods
builds()
click to toggle source
# File lib/liquidoc.rb, line 363 def builds return @step['builds'] end
command()
click to toggle source
# File lib/liquidoc.rb, line 355 def command return @step['command'] end
data()
click to toggle source
# File lib/liquidoc.rb, line 339 def data return @step['data'] end
message()
click to toggle source
# File lib/liquidoc.rb, line 367 def message # dynamically build a human-friendly log message, possibly appending a reason unless @step['message'] reason = ", #{@step['reason']}" if @step['reason'] noninclusively = ", without carrying the parent directory" if self.options.is_a?(Hash) && self.options['inclusive'] == false && File.directory?(self.source) stage = "" ; stage = "[#{self.stage}] " if self.stage case self.type when "migrate" text = ". #{stage}Copies `#{self.source}` to `#{self.target}`#{noninclusively}#{reason}." when "parse" if self.data.is_a? Array if self.data.count > 1 text = ". Draws data from the following files:" self.data.each do |file| text.concat("\n * `#{file}`.") end text.concat("\n") else text = ". #{stage}Draws data from `#{self.data[0]}`" end else if self.data text = ". #{stage}Draws data from `#{self.data['file']}`" else text = ". #{stage}Uses data passed via CLI --var options." end end text.concat("#{reason},") if reason text.concat(" and parses it as follows:") return text when "render" if self.source text = ". #{stage}Using the index file `#{self.source}` as a map#{reason}, and ingesting AsciiDoc attributes from " if self.data.is_a? Array text.concat("the following data files:") self.data.each do |file| text.concat("\n * `#{file}`.") end else text.concat("`#{self.data}`") end return text end end else return @step['message'] end end
options()
click to toggle source
# File lib/liquidoc.rb, line 351 def options return @step['options'] end
source()
click to toggle source
# File lib/liquidoc.rb, line 343 def source return @step['source'] end
stage()
click to toggle source
# File lib/liquidoc.rb, line 359 def stage return @step['stage'] end
target()
click to toggle source
# File lib/liquidoc.rb, line 347 def target return @step['target'] end
type()
click to toggle source
# File lib/liquidoc.rb, line 335 def type return @step['action'] end
validate()
click to toggle source
# File lib/liquidoc.rb, line 416 def validate case self.type when "parse" reqs = ["data,builds"] when "migrate" reqs = ["source,target"] when "render" reqs = ["builds"] when "execute" reqs = ["command"] end for req in reqs if (defined?(@step[req])).nil? @logger.error "Every #{@step['action']}-type in the configuration file needs a '#{req}' declaration." raise "ConfigStructError" end end end