lib/mnogootex/job/warden.rb in mnogootex-1.1.0 vs lib/mnogootex/job/warden.rb in mnogootex-2.0.0
- old
+ new
@@ -9,13 +9,16 @@
require 'mnogootex/job/logger'
module Mnogootex
module Job
class Warden
- def initialize(source:, configuration:)
+ LATEXMK_PATH = 'latexmk'
+
+ def initialize(source:, configuration:, flags:)
@source = source
@configuration = configuration
+ @flags = flags
@processor = nil
@porters = []
@runners = []
@logger = nil
@@ -42,57 +45,58 @@
end
end
def exec_porters
@porters.each do |porter|
- porter.clobber
+ # porter.clobber
porter.provide
transformer(porter.hid, porter.target_path)
end
end
def init_and_exec_runners
@runners = @porters.map do |porter|
Mnogootex::Job::Runner.new(
cmd: commandline(porter.target_path),
- chdir: porter.target_dir
+ chdir: porter.target_dir,
)
end
end
def init_processor
@processor = Log::Processor.new(
matchers: Mnogootex::Log::DEFAULT_MATCHERS,
levels: Mnogootex::Log::DEFAULT_LEVELS,
min_level: :info,
colorize: true,
- indent_width: 4
+ indent_width: 4,
)
end
def init_and_exec_logger
@logger = Mnogootex::Job::Logger.new(
spinner: @configuration['spinner'],
processor: @processor.method(:run),
runners: @runners,
- porters: @porters
+ porters: @porters,
)
end
# TODO: generalize, integrate with Runner
def commandline(target_pathname)
[
- *@configuration['commandline'],
+ LATEXMK_PATH,
+ *@flags,
target_pathname.basename.to_s
]
end
# TODO: generalize, integrate with Porter
def transformer(new_class_name, target_pathname)
old_code = target_pathname.read
new_code = old_code.sub(
/\\documentclass(\[.*?\])?{.*?}/,
- "\\documentclass{#{new_class_name}}"
+ "\\documentclass{#{new_class_name}}",
)
target_pathname.write(new_code)
end
end
end