class Nanoc::CLI::CommandRunner
A command runner subclass for Nanoc commands that adds Nanoc-specific convenience methods and error handling.
@api private
Public Instance Methods
call()
click to toggle source
@see rubydoc.info/gems/cri/Cri/CommandRunner#call-instance_method
@return [void]
# File lib/nanoc/cli/command_runner.rb, line 10 def call Nanoc::CLI::ErrorHandler.handle_while(command: self) do run end end
debug?()
click to toggle source
@return [Boolean] true if debug output is enabled, false if not
@see Nanoc::CLI.debug?
# File lib/nanoc/cli/command_runner.rb, line 61 def debug? Nanoc::CLI.debug? end
in_site_dir?()
click to toggle source
@return [Boolean] true if the current working directory is a Nanoc site
directory, false otherwise
# File lib/nanoc/cli/command_runner.rb, line 39 def in_site_dir? Nanoc::Int::SiteLoader.cwd_is_nanoc_site? end
Also aliased as: is_in_site_dir?
load_site()
click to toggle source
Asserts that the current working directory contains a site and loads the site into memory.
@return [void]
# File lib/nanoc/cli/command_runner.rb, line 47 def load_site print 'Loading site⦠' $stdout.flush if site.nil? raise ::Nanoc::Int::Errors::GenericTrivial, 'The current working directory does not seem to be a Nanoc site.' end puts 'done' end
site()
click to toggle source
Gets the site ({Nanoc::Int::Site} instance) in the current directory and loads its data.
@return [Nanoc::Int::Site] The site in the current working directory
# File lib/nanoc/cli/command_runner.rb, line 20 def site # Load site if possible @site ||= nil if is_in_site_dir? && @site.nil? @site = Nanoc::Int::SiteLoader.new.new_from_cwd end @site end
site=(new_site)
click to toggle source
For debugging purposes.
@api private
# File lib/nanoc/cli/command_runner.rb, line 33 def site=(new_site) @site = new_site end
Protected Instance Methods
stack()
click to toggle source
@return [Array] The compilation stack.
# File lib/nanoc/cli/command_runner.rb, line 68 def stack (site && site.compiler.stack) || [] end