class Nanoc::CLI::Commands::View

Public Instance Methods

run() click to toggle source
# File lib/nanoc/cli/commands/view.rb, line 19
def run
  load_adsf

  config = Nanoc::Core::ConfigLoader.new.new_from_cwd

  # Create output dir so that viewer/watcher doesn’t explode.
  FileUtils.mkdir_p(config.output_dir)

  server =
    Adsf::Server.new(
      root: File.absolute_path(config.output_dir),
      live: options[:'live-reload'],
      index_filenames: config[:index_filenames],
      host: options[:host],
      port: options[:port],
      handler: options[:handler],
    )

  server.run
end

Protected Instance Methods

load_adsf() click to toggle source
# File lib/nanoc/cli/commands/view.rb, line 42
def load_adsf
  # Load adsf
  begin
    require 'adsf'
    return
  rescue LoadError
    $stderr.puts "Could not find the required 'adsf' gem, " \
      'which is necessary for the view command.'
  end

  # Check asdf
  begin
    require 'asdf'
    $stderr.puts "You appear to have 'asdf' installed, " \
      "but not 'adsf'. Please install 'adsf' (check the spelling)!"
  rescue LoadError
  end

  # Done
  exit 1
end