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
332 333 334 335 336 337 |
# File 'lib/nanoc/cli/commands/compile.rb', line 332 def initialize(params={}) @start_times = {} @stop_times = {} @reps = params.fetch(:reps) end |
Instance Method Details
- (Object) start
340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/nanoc/cli/commands/compile.rb', line 340 def start Nanoc::NotificationCenter.on(:compilation_started) do |rep| @start_times[rep.raw_path] = Time.now end Nanoc::NotificationCenter.on(:compilation_ended) do |rep| @stop_times[rep.raw_path] = Time.now end Nanoc::NotificationCenter.on(:rep_written) do |rep, path, is_created, is_modified| action = (is_created ? :create : (is_modified ? :update : :identical)) level = (is_created ? :high : (is_modified ? :high : :low)) log(level, action, path, duration_for(rep)) end end |
- (Object) stop
355 356 357 358 359 360 361 362 |
# File 'lib/nanoc/cli/commands/compile.rb', line 355 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, duration_for(rep)) end end end |