class Plans::Command
Attributes
options[R]
shell[R]
Public Class Methods
new(shell, options)
click to toggle source
Initialize the command with the Thor::Shell and the options.
# File lib/plans/command.rb, line 21 def initialize(shell, options) @shell = shell @options = options end
source_root()
click to toggle source
Set the source root for Thor::Actions
# File lib/plans/command.rb, line 13 def self.source_root Plans.source_root end
Public Instance Methods
check_plans_pathname_exists(path)
click to toggle source
Check to see if the .plans path exists Prints a message for the user and raises if it does not.
@param [Pathname] path the proposed path to the .plans directory.
# File lib/plans/command.rb, line 30 def check_plans_pathname_exists(path) unless path.exist? say 'The .plans directory does not exist.', :red say 'Run `plans init` to create a .plans folder in your home directory and initialize it with the default document templates.' say " #{@path}" raise_error('Plans directory does not exist.') end end
pathname(path)
click to toggle source
The full current path, as a pathname object. @return [Pathname] The full path to the directory where the command is to be executed.
# File lib/plans/command.rb, line 41 def pathname(path) Pathname.new(File.expand_path(path)) end
plans_pathname(path = nil)
click to toggle source
Get the path as a pathname object to the .plans directory.
@param [String] path The string path to the .plans directory
or nil if the users home directory should be used.
# File lib/plans/command.rb, line 50 def plans_pathname(path = nil) path = path || Dir.home pathname(path) + '.plans' end
raise_error(msg)
click to toggle source
Raise a formatted Thor exception.
@param [String] msg the message to include in the exception.
# File lib/plans/command.rb, line 58 def raise_error(msg) raise Thor::Error, "Error: #{msg}" end