lib/nanoc/cli/commands/compile.rb in nanoc-4.0.2 vs lib/nanoc/cli/commands/compile.rb in nanoc-4.1.0a1

- old
+ new

@@ -15,19 +15,17 @@ EOS module Nanoc::CLI::Commands class Compile < ::Nanoc::CLI::CommandRunner - extend Nanoc::Int::Memoization - # Listens to compilation events and reacts to them. This abstract class # does not have a real implementation; subclasses should override {#start} # and set up notifications to listen to. # # @abstract Subclasses must override {#start} and may override {#stop}. class Listener - def initialize(_params = {}) + def initialize(*) end # @param [Nanoc::CLI::CommandRunner] command_runner The command runner for this listener # # @return [Boolean] true if this listener should be enabled for the given command runner, false otherwise @@ -145,15 +143,15 @@ # @see Listener#enable_for? def self.enable_for?(command_runner) command_runner.options.fetch(:verbose, false) end - # @option params [Array<Nanoc::Int::ItemRep>] :reps The list of item representations in the site - def initialize(params = {}) + # @param [Enumerable<Nanoc::Int::ItemRep>] reps + def initialize(reps:) @times = {} - @reps = params.fetch(:reps) + @reps = reps end # @see Listener#start def start Nanoc::Int::NotificationCenter.on(:filtering_started) do |_rep, filter_name| @@ -247,11 +245,11 @@ # @see Listener#enable_for? def self.enable_for?(_command_runner) !ENV.key?('TRAVIS') end - def initialize(_params = {}) + def initialize(*) @gc_count = 0 end # @see Listener#start def start @@ -312,15 +310,14 @@ end end # Prints file actions (created, updated, deleted, identical, skipped) class FileActionPrinter < Listener - # @option params [Array<Nanoc::Int::ItemRep>] :reps The list of item representations in the site - def initialize(params = {}) + def initialize(reps:) @start_times = {} - @reps = params.fetch(:reps) + @reps = reps end # @see Listener#start def start Nanoc::Int::NotificationCenter.on(:compilation_started) do |rep| @@ -359,13 +356,15 @@ def log(level, action, path, duration) Nanoc::CLI::Logger.instance.file(level, action, path, duration) end end - def initialize(options, arguments, command, params = {}) - super(options, arguments, command) - @listener_classes = params.fetch(:listener_classes, default_listener_classes) + attr_accessor :listener_classes + + def initialize(options, arguments, command) + super + @listener_classes = default_listener_classes end def run time_before = Time.now @@ -423,12 +422,11 @@ def teardown_listeners @listeners.each(&:stop) end def reps - site.items.map(&:reps).flatten + site.compiler.reps end - memoize :reps def prune_config site.config[:prune] || {} end