Class: Nanoc::CLI::Commands::Compile::FileActionPrinter
- Inherits:
-
Listener
- Object
- Listener
- 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)
-
- (FileActionPrinter) initialize(params = {})
constructor
A new instance of FileActionPrinter.
-
- (Object) start
-
- (Object) stop
Methods inherited from Listener
Constructor Details
- (FileActionPrinter) initialize(params = {})
Returns a new instance of FileActionPrinter
337 338 339 340 341 |
# File 'lib/nanoc/cli/commands/compile.rb', line 337 def initialize(params = {}) @start_times = {} @reps = params.fetch(:reps) end |
Instance Method Details
- (Object) start
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/nanoc/cli/commands/compile.rb', line 344 def start Nanoc::NotificationCenter.on(:compilation_started) do |rep| @start_times[rep.raw_path] = Time.now end Nanoc::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 |
- (Object) stop
367 368 369 370 371 372 373 374 |
# File 'lib/nanoc/cli/commands/compile.rb', line 367 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 |