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
324 325 326 327 328 |
# File 'lib/nanoc/cli/commands/compile.rb', line 324 def initialize(params = {}) @start_times = {} @reps = params.fetch(:reps) end |
Instance Method Details
- (Object) start
331 332 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 331 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
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 |