Sha256: 4a8387b4f09f8e1722abef6dc66edde512a03a31372a9180cb829fff3c5369d4
Contents?: true
Size: 1.15 KB
Versions: 15
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Nanoc::CLI::Commands::CompileListeners class Aggregate < Abstract def initialize(command_runner:, site:, compiler:) @site = site @compiler = compiler @command_runner = command_runner @listener_classes = self.class.default_listener_classes end def start setup_listeners end def stop teardown_listeners end def self.default_listener_classes [ Nanoc::CLI::Commands::CompileListeners::DiffGenerator, Nanoc::CLI::Commands::CompileListeners::DebugPrinter, Nanoc::CLI::Commands::CompileListeners::TimingRecorder, Nanoc::CLI::Commands::CompileListeners::FileActionPrinter, ] end protected def setup_listeners res = @compiler.run_until_reps_built reps = res.fetch(:reps) @listeners = @listener_classes .select { |klass| klass.enable_for?(@command_runner, @site) } .map { |klass| klass.new(reps: reps) } @listeners.each(&:start_safely) end def teardown_listeners return unless @listeners @listeners.reverse_each(&:stop_safely) end end end
Version data entries
15 entries across 15 versions & 1 rubygems