Class: Nanoc::CLI::Commands::Compile::FileActionPrinter
- Defined in:
- lib/nanoc/cli/commands/compile.rb
Overview
Prints file actions (created, updated, deleted, identical, skipped)
Instance Method Summary collapse
-
#initialize(reps:) ⇒ FileActionPrinter
constructor
A new instance of FileActionPrinter.
-
#start ⇒ Object
-
#stop ⇒ Object
Methods inherited from Listener
Constructor Details
#initialize(reps:) ⇒ FileActionPrinter
Returns a new instance of FileActionPrinter
326 327 328 329 330 |
# File 'lib/nanoc/cli/commands/compile.rb', line 326 def initialize(reps:) @start_times = {} @reps = reps end |
Instance Method Details
#start ⇒ Object
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/nanoc/cli/commands/compile.rb', line 333 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 = if is_created then :create elsif is_modified then :update else :identical end level = if is_created then :high elsif is_modified then :high else :low end log(level, action, path, duration) end end |
#stop ⇒ Object
354 355 356 357 358 359 360 361 |
# File 'lib/nanoc/cli/commands/compile.rb', line 354 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 |