class Mnogootex::Job::Warden
Public Class Methods
new(source:, configuration:)
click to toggle source
# File lib/mnogootex/job/warden.rb, line 14 def initialize(source:, configuration:) @source = source @configuration = configuration @processor = nil @porters = [] @runners = [] @logger = nil end
Public Instance Methods
start()
click to toggle source
# File lib/mnogootex/job/warden.rb, line 24 def start init_processor init_porters exec_porters init_and_exec_runners init_and_exec_logger @logger.join end
Private Instance Methods
commandline(target_pathname)
click to toggle source
TODO: generalize, integrate with Runner
# File lib/mnogootex/job/warden.rb, line 81 def commandline(target_pathname) [ *@configuration['commandline'], target_pathname.basename.to_s ] end
exec_porters()
click to toggle source
# File lib/mnogootex/job/warden.rb, line 44 def exec_porters @porters.each do |porter| porter.clobber porter.provide transformer(porter.hid, porter.target_path) end end
init_and_exec_logger()
click to toggle source
# File lib/mnogootex/job/warden.rb, line 71 def init_and_exec_logger @logger = Mnogootex::Job::Logger.new( spinner: @configuration['spinner'], processor: @processor.method(:run), runners: @runners, porters: @porters ) end
init_and_exec_runners()
click to toggle source
# File lib/mnogootex/job/warden.rb, line 52 def init_and_exec_runners @runners = @porters.map do |porter| Mnogootex::Job::Runner.new( cl: commandline(porter.target_path), chdir: porter.target_dir ) end end
init_porters()
click to toggle source
# File lib/mnogootex/job/warden.rb, line 35 def init_porters @configuration['jobs'].each do |cls| @porters << Mnogootex::Job::Porter.new( hid: cls, source_path: @source ) end end
init_processor()
click to toggle source
# File lib/mnogootex/job/warden.rb, line 61 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 ) end
transformer(new_class_name, target_pathname)
click to toggle source
TODO: generalize, integrate with Porter
# File lib/mnogootex/job/warden.rb, line 89 def transformer(new_class_name, target_pathname) old_code = target_pathname.read new_code = old_code.sub( /\\documentclass(\[.*?\])?{.*?}/, "\\documentclass{#{new_class_name}}" ) target_pathname.write(new_code) end