lib/liquidoc.rb in liquidoc-0.9.4 vs lib/liquidoc.rb in liquidoc-0.9.5

- old
+ new

@@ -121,12 +121,16 @@ regurgidata(data, build.output) end end when "migrate" inclusive = true - inclusive = step.options['inclusive'] if defined?(step.options['inclusive']) - copy_assets(step.source, step.target, inclusive) + missing = "exit" + if step.options + inclusive = step.options['inclusive'] if step.options.has_key?("inclusive") + missing = step.options['missing'] if step.options.has_key?("missing") + end + copy_assets(step.source, step.target, inclusive, missing) when "render" validate_file_input(step.source, "source") if step.source builds = step.builds for bld in builds doc = AsciiDocument.new(step.source) @@ -250,10 +254,11 @@ def initialize step @step = step if (defined?(@step['action'])).nil? raise "ConfigStructError" end + @step['options'] = nil unless defined?(step['options']) validate() end def type return @step['action'] @@ -785,25 +790,39 @@ # === # MIGRATE-type procs # === # Copy images and other files into target dir -def copy_assets src, dest, inclusive=true +def copy_assets src, dest, inclusive=true, missing='exit' unless File.file?(src) unless inclusive then src = src + "/." end end - @logger.debug "Copying #{src} to #{dest}" + src_to_dest = "#{src} to #{dest}" + unless (File.file?(src) || File.directory?(src)) + case missing + when "warn" + @logger.warn "Skipping migrate action (#{src_to_dest}); source not found." + return + when "skip" + @logger.debug "Skipping migrate action (#{src_to_dest}); source not found." + return + when "exit" + @logger.error "Unexpected missing source in migrate action (#{src_to_dest})." + raise "MissingSourceExit" + end + end + @logger.debug "Copying #{src_to_dest}" begin FileUtils.mkdir_p(dest) unless File.directory?(dest) if File.directory?(src) FileUtils.cp_r(src, dest) else FileUtils.cp(src, dest) end @logger.info "Copied #{src} to #{dest}." rescue Exception => ex - @logger.warn "Problem while copying assets. #{ex.message}" + @logger.error "Problem while copying assets. #{ex.message}" raise end end # === @@ -903,9 +922,12 @@ @logger.debug "Final pre-Asciidoctor attributes: #{attrs.to_yaml}" # Perform the aciidoctor convert if build.backend == "pdf" @logger.info "Generating PDF. This can take some time..." end + + + Asciidoctor.convert_file( doc.index, to_file: to_file, attributes: attrs, require: "pdf",