Class: Nanoc::CLI::CommandRunner Private
- Inherits:
-
Cri::CommandRunner
- Object
- Cri::CommandRunner
- Nanoc::CLI::CommandRunner
- Defined in:
- lib/nanoc/cli/command_runner.rb
Overview
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.
A command runner subclass for Nanoc commands that adds Nanoc-specific convenience methods and error handling.
Direct Known Subclasses
Nanoc::CLI::Commands::Check, Nanoc::CLI::Commands::Compile, Nanoc::CLI::Commands::CreateSite, Nanoc::CLI::Commands::Deploy, Nanoc::CLI::Commands::Prune, Nanoc::CLI::Commands::Shell, Nanoc::CLI::Commands::ShowData, Nanoc::CLI::Commands::ShowPlugins, Nanoc::CLI::Commands::ShowRules, Nanoc::CLI::Commands::View
Instance Method Summary collapse
- #call ⇒ void private
-
#debug? ⇒ Boolean
private
True if debug output is enabled, false if not.
-
#in_site_dir? ⇒ Boolean
(also: #is_in_site_dir?)
private
True if the current working directory is a Nanoc site directory, false otherwise.
-
#load_site(preprocess: false) ⇒ void
private
Asserts that the current working directory contains a site and loads the site into memory.
-
#site ⇒ Nanoc::Int::Site
private
Gets the site (Int::Site instance) in the current directory and loads its data.
-
#site=(new_site) ⇒ Object
private
For debugging purposes.
Instance Method Details
#call ⇒ void
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.
This method returns an undefined value.
10 11 12 13 14 |
# File 'lib/nanoc/cli/command_runner.rb', line 10 def call Nanoc::CLI::ErrorHandler.handle_while(command: self) do run end end |
#debug? ⇒ Boolean
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.
Returns true if debug output is enabled, false if not.
65 66 67 |
# File 'lib/nanoc/cli/command_runner.rb', line 65 def debug? Nanoc::CLI.debug? end |
#in_site_dir? ⇒ Boolean Also known as: is_in_site_dir?
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.
Returns true if the current working directory is a Nanoc site directory, false otherwise.
39 40 41 |
# File 'lib/nanoc/cli/command_runner.rb', line 39 def in_site_dir? Nanoc::Int::SiteLoader.cwd_is_nanoc_site? end |
#load_site(preprocess: false) ⇒ void
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.
This method returns an undefined value.
Asserts that the current working directory contains a site and loads the site into memory.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nanoc/cli/command_runner.rb', line 47 def load_site(preprocess: false) 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 if preprocess site.compiler.action_provider.preprocess(site) end puts 'done' end |
#site ⇒ Nanoc::Int::Site
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.
Gets the site (Int::Site instance) in the current directory and loads its data.
20 21 22 23 24 25 26 27 28 |
# 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) ⇒ Object
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.
For debugging purposes.
33 34 35 |
# File 'lib/nanoc/cli/command_runner.rb', line 33 def site=(new_site) @site = new_site end |