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 383
def initialize(options, arguments, command, params = {})
  super(options, arguments, command)
  @listener_classes = params.fetch(:listener_classes, default_listener_classes)
end

Public Instance Methods

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

  load_site
  check_for_deprecated_usage

  puts 'Compiling site…'
  run_listeners_while do
    site.compile
    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 451
def check_for_deprecated_usage
  # Check presence of --all option
  if options.key?(:all) || options.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 413
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 431
def listeners
  @listeners
end
prune() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 407
def prune
  if site.config[:prune][:auto_prune]
    Nanoc::Extra::Pruner.new(site, :exclude => prune_config_exclude).run
  end
end
prune_config() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 465
def prune_config
  site.config[:prune] || {}
end
prune_config_exclude() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 469
def prune_config_exclude
  prune_config[:exclude] || {}
end
reps() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 446
def reps
  site.items.map { |i| i.reps }.flatten
end
run_listeners_while() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 435
def run_listeners_while
  setup_listeners
  yield
ensure
  teardown_listeners
end
setup_listeners() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 423
def setup_listeners
  @listeners = @listener_classes.
    select { |klass| klass.enable_for?(self) }.
    map    { |klass| klass.new(:reps => reps) }

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.