class Nanoc::CLI::Commands::Compile

Attributes

listener_classes[RW]

Public Instance Methods

run() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 17
def run
  self.class.enter_site_dir

  if options[:watch]
    run_repeat
  else
    run_once
  end
end
run_once() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 32
def run_once
  time_before = Time.now

  @site = load_site

  puts 'Compiling site…'
  compiler = Nanoc::Core::Compiler.new_for(@site)
  listener = Nanoc::CLI::CompileListeners::Aggregate.new(
    command_runner: self,
    site: @site,
    compiler: compiler,
  )
  listener.run_while do
    compiler.run_until_end
  end

  time_after = Time.now
  puts
  puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
end
run_repeat() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 27
def run_repeat
  require 'nanoc/live'
  Nanoc::Live::LiveRecompiler.new(command_runner: self).run
end