Class: DeploYML::Shell
- Inherits:
-
Object
- Object
- DeploYML::Shell
- Includes:
- Shellwords, Thor::Shell
- Defined in:
- lib/deployml/shell.rb
Overview
Provides common methods used by both LocalShell and RemoteShell.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
The URI of the Shell.
Instance Method Summary collapse
-
#echo(message) ⇒ Object
Place holder method.
-
#exec(command) ⇒ Object
Runs a command in the shell.
-
#initialize(uri) {|session| ... } ⇒ Shell
constructor
Initializes a shell session.
-
#rake(task, *arguments) ⇒ Object
Executes a Rake task.
-
#rake_task(name, *arguments) ⇒ Object
protected
Builds a
raketask name. -
#run(program, *arguments) ⇒ Object
Place holder method.
-
#status(message) ⇒ Object
Prints a status message.
Constructor Details
#initialize(uri) {|session| ... } ⇒ Shell
Initializes a shell session.
28 29 30 31 32 33 34 35 36 |
# File 'lib/deployml/shell.rb', line 28 def initialize(uri) @uri = uri if block_given? status "Entered #{@uri}." yield self status "Leaving #{@uri} ..." end end |
Instance Attribute Details
#uri ⇒ Object (readonly)
The URI of the Shell.
14 15 16 |
# File 'lib/deployml/shell.rb', line 14 def uri @uri end |
Instance Method Details
#echo(message) ⇒ Object
Place holder method.
65 66 |
# File 'lib/deployml/shell.rb', line 65 def echo() end |
#exec(command) ⇒ Object
Runs a command in the shell.
56 57 58 |
# File 'lib/deployml/shell.rb', line 56 def exec(command) run(*shellwords(command)) end |
#rake(task, *arguments) ⇒ Object
Executes a Rake task.
77 78 79 |
# File 'lib/deployml/shell.rb', line 77 def rake(task,*arguments) run 'rake', rake_task(task,*arguments) end |
#rake_task(name, *arguments) ⇒ Object (protected)
Builds a rake task name.
107 108 109 110 111 112 113 114 115 |
# File 'lib/deployml/shell.rb', line 107 def rake_task(name,*arguments) name = name.to_s unless arguments.empty? name += ('[' + arguments.join(',') + ']') end return name end |
#run(program, *arguments) ⇒ Object
Place holder method.
43 44 |
# File 'lib/deployml/shell.rb', line 43 def run(program,*arguments) end |
#status(message) ⇒ Object
Prints a status message.
89 90 91 |
# File 'lib/deployml/shell.rb', line 89 def status() echo "#{Color::GREEN}>>> #{}#{Color::CLEAR}" end |