lib/review/textmaker.rb in review-5.1.1 vs lib/review/textmaker.rb in review-5.2.0
- old
+ new
@@ -15,33 +15,27 @@
require 'review/yamlloader'
require 'review/topbuilder'
require 'review/version'
require 'review/makerhelper'
require 'review/img_math'
+require 'review/loggable'
module ReVIEW
class TEXTMaker
include MakerHelper
+ include Loggable
attr_accessor :config, :basedir
def initialize
@basedir = nil
@logger = ReVIEW.logger
@plaintext = nil
@img_math = nil
+ @compile_errors = nil
end
- def error(msg)
- @logger.error msg
- exit 1
- end
-
- def warn(msg)
- @logger.warn msg
- end
-
def self.execute(*args)
self.new.execute(*args)
end
def parse_opts(args)
@@ -76,11 +70,11 @@
FileUtils.rm_rf(path)
end
def execute(*args)
cmd_config, yamlfile = parse_opts(args)
- error "#{yamlfile} not found." unless File.exist?(yamlfile)
+ error! "#{yamlfile} not found." unless File.exist?(yamlfile)
@config = ReVIEW::Configure.create(maker: 'textmaker',
yamlfile: yamlfile,
config: cmd_config)
@img_math = ReVIEW::ImgMath.new(@config, path_name: '_review_math_text')
@@ -90,11 +84,11 @@
generate_text_files(yamlfile)
@logger.success("built #{build_path}")
rescue ApplicationError => e
raise if @config['debug']
- error(e.message)
+ error! e.message
end
if @config['math_format'] == 'imgmath'
@img_math.make_math_images
end
@@ -107,10 +101,14 @@
Dir.mkdir(@path)
@book = ReVIEW::Book::Base.new(@basedir, config: @config)
build_body(@path, yamlfile)
+
+ if @compile_errors
+ app_error 'compile error, No TEXT file output.'
+ end
end
def build_body(basetmpdir, _yamlfile)
base_path = Pathname.new(@basedir)
builder = nil
@@ -160,11 +158,12 @@
textfile = "#{id}.txt"
begin
@converter.convert(filename, File.join(basetmpdir, textfile))
rescue => e
- warn "compile error in #{filename} (#{e.class})"
- warn e.message
+ @compile_errors = true
+ error "compile error in #{filename} (#{e.class})"
+ error e.message
end
end
end
end