Class: Plans::Command
- Inherits:
-
Object
- Object
- Plans::Command
- Includes:
- Thor::Actions, Thor::Base
- Defined in:
- lib/plans/command.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Class Method Summary collapse
-
.source_root ⇒ Object
Set the source root for Thor::Actions.
Instance Method Summary collapse
-
#check_plans_pathname_exists(path) ⇒ Object
Check to see if the .plans path exists Prints a message for the user and raises if it does not.
-
#initialize(shell, options) ⇒ Command
constructor
Initialize the command with the Thor::Shell and the options.
-
#pathname(path) ⇒ Pathname
The full current path, as a pathname object.
-
#plans_pathname(path = nil) ⇒ Object
Get the path as a pathname object to the .plans directory.
-
#raise_error(msg) ⇒ Object
Raise a formatted Thor exception.
Constructor Details
#initialize(shell, options) ⇒ Command
Initialize the command with the Thor::Shell and the options.
21 22 23 24 |
# File 'lib/plans/command.rb', line 21 def initialize(shell, ) @shell = shell @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/plans/command.rb', line 17 def @options end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
17 18 19 |
# File 'lib/plans/command.rb', line 17 def shell @shell end |
Class Method Details
.source_root ⇒ Object
Set the source root for Thor::Actions
13 14 15 |
# File 'lib/plans/command.rb', line 13 def self.source_root Plans.source_root end |
Instance Method Details
#check_plans_pathname_exists(path) ⇒ Object
Check to see if the .plans path exists Prints a message for the user and raises if it does not.
30 31 32 33 34 35 36 37 |
# 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) ⇒ Pathname
The full current path, as a pathname object.
41 42 43 |
# File 'lib/plans/command.rb', line 41 def pathname(path) Pathname.new(File.(path)) end |
#plans_pathname(path = nil) ⇒ Object
Get the path as a pathname object to the .plans directory.
50 51 52 53 |
# File 'lib/plans/command.rb', line 50 def plans_pathname(path = nil) path = path || Dir.home pathname(path) + '.plans' end |
#raise_error(msg) ⇒ Object
Raise a formatted Thor exception.
58 59 60 |
# File 'lib/plans/command.rb', line 58 def raise_error(msg) raise Thor::Error, "Error: #{msg}" end |