class Nanoc::CLI::Commands::Compile::FileActionPrinter

Prints file actions (created, updated, deleted, identical, skipped)

Public Class Methods

new(reps:) click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 315
def initialize(reps))
  @start_times = {}

  @reps = reps
end

Public Instance Methods

start() click to toggle source

@see Nanoc::CLI::Commands::Compile::Listener#start

# File lib/nanoc/cli/commands/compile.rb, line 322
def start
  Nanoc::Int::NotificationCenter.on(:compilation_started) do |rep|
    @start_times[rep.raw_path] = Time.now
  end
  Nanoc::Int::NotificationCenter.on(:rep_written) do |_rep, path, is_created, is_modified|
    duration = path && @start_times[path] ? Time.now - @start_times[path] : nil
    action =
      case
      when is_created  then :create
      when is_modified then :update
      else :identical
      end
    level =
      case
      when is_created  then :high
      when is_modified then :high
      else :low
      end
    log(level, action, path, duration)
  end
end
stop() click to toggle source

@see Nanoc::CLI::Commands::Compile::Listener#stop

# File lib/nanoc/cli/commands/compile.rb, line 345
def stop
  super
  @reps.select { |r| !r.compiled? }.each do |rep|
    rep.raw_paths.each do |_snapshot_name, raw_path|
      log(:low, :skip, raw_path, nil)
    end
  end
end

Private Instance Methods

log(level, action, path, duration) click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 356
def log(level, action, path, duration)
  Nanoc::CLI::Logger.instance.file(level, action, path, duration)
end