Class/Module Index [+]

Quicksearch

Nanoc::CLI::Commands::Compile

Public Class Methods

new(options, arguments, command, params={}) click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 349
def initialize(options, arguments, command, params={})
  super(options, arguments, command)
  @listener_classes = params.fetch(:listener_classes, self.default_listener_classes)
end

Public Instance Methods

run() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 354
def run
  time_before = Time.now

  self.load_site
  self.check_for_deprecated_usage

  puts "Compiling site…"
  self.run_listeners_while do
    self.site.compile
    self.prune
  end

  time_after = Time.now
  puts
  puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
end

Protected Instance Methods

check_for_deprecated_usage() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 417
def check_for_deprecated_usage
  # Check presence of --all option
  if options.has_key?(:all) || options.has_key?(:force)
    $stderr.puts "Warning: the --force option (and its deprecated --all alias) are, as of nanoc 3.2, no longer supported and have no effect."
  end

  # Warn if trying to compile a single item
  if arguments.size == 1
    $stderr.puts '-' * 80
    $stderr.puts 'Note: As of nanoc 3.2, it is no longer possible to compile a single item. When invoking the “compile” command, all items in the site will be compiled.'
    $stderr.puts '-' * 80
  end
end
default_listener_classes() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 379
def default_listener_classes
  [
    Nanoc::CLI::Commands::Compile::DiffGenerator,
    Nanoc::CLI::Commands::Compile::DebugPrinter,
    Nanoc::CLI::Commands::Compile::TimingRecorder,
    Nanoc::CLI::Commands::Compile::GCController,
    Nanoc::CLI::Commands::Compile::FileActionPrinter
  ]
end
listeners() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 397
def listeners
  @listeners
end
prune() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 373
def prune  
  if self.site.config[:prune][:auto_prune]
    Nanoc::Extra::Pruner.new(self.site, :exclude => self.prune_config_exclude).run
  end
end
prune_config() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 431
def prune_config
  self.site.config[:prune] || {}
end
prune_config_exclude() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 435
def prune_config_exclude
  self.prune_config[:exclude] || {}
end
reps() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 412
def reps
  self.site.items.map { |i| i.reps }.flatten
end
run_listeners_while() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 401
def run_listeners_while
  self.setup_listeners
  yield
ensure
  self.teardown_listeners
end
setup_listeners() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 389
def setup_listeners
  @listeners = @listener_classes.
    select { |klass| klass.enable_for?(self) }.
    map    { |klass| klass.new(:reps => self.reps) }

  @listeners.each { |s| s.start }
end
teardown_listeners() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 408
def teardown_listeners
  @listeners.each { |s| s.stop }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.