Class: Nanoc::CLI::Commands::Compile Private

Inherits:
Nanoc::CLI::CommandRunner show all
Defined in:
lib/nanoc/cli/commands/compile.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Nanoc::CLI::CommandRunner

#call, #debug?, enter_site_dir, find_site_dir, #in_site_dir?, #load_site

Instance Attribute Details

#listener_classesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/nanoc/cli/commands/compile.rb', line 16

def listener_classes
  @listener_classes
end

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
24
25
26
# File 'lib/nanoc/cli/commands/compile.rb', line 18

def run
  self.class.enter_site_dir

  if options[:watch]
    run_repeat
  else
    run_once
  end
end

#run_onceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/nanoc/cli/commands/compile.rb', line 33

def run_once
  time_before = Time.now

  @site = load_site

  puts 'Compiling siteā€¦'
  compiler = Nanoc::Core::Compiler.new_for(@site, focus: options[:focus])
  listener = Nanoc::CLI::CompileListeners::Aggregate.new(
    command_runner: self,
    site: @site,
    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."

  if options[:focus]
    warn 'CAUTION: A --focus option is specified. Not the entire site has been compiled.'
    warn 'Re-run without --focus to compile the entire site.'
  end
end

#run_repeatObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
# File 'lib/nanoc/cli/commands/compile.rb', line 28

def run_repeat
  require 'nanoc/live'
  Nanoc::Live::LiveRecompiler.new(command_runner: self, focus: options[:focus]).run
end