Class: EpubForge::Action::CliCommand
- Inherits:
-
Object
- Object
- EpubForge::Action::CliCommand
- Defined in:
- lib/epubforge/action/cli_command.rb
Instance Method Summary collapse
- #execute(cmd = :cmd) ⇒ Object
-
#initialize(command, undo = nil, opts = {}) ⇒ CliCommand
constructor
undo is an action that would be expected to reverse the consequences of this action.
- #undo ⇒ Object
Constructor Details
#initialize(command, undo = nil, opts = {}) ⇒ CliCommand
undo is an action that would be expected to reverse the consequences of this action. You can do without it if the action can’t fail, if it has no real consequences, or if a prior action, when undone, will wipe out those consequences. For example, if an earlier command created the directory that the current command is writing a file to, the earlier command would be expected to delete the directory.
9 10 11 12 13 14 15 16 17 |
# File 'lib/epubforge/action/cli_command.rb', line 9 def initialize( command, undo = nil, opts = {} ) @command = command @undo = undo @opts = opts @remote = opts[:remote] # Is this going to be executed here, or on a different server? Usually in the form "username@host" @verbose = opts[:verbose] @local_dir = opts[:local_dir] # the local directory to cd into before executing the command @remote_dir = opts[:remote_dir] # the remote directory to cd into before executing the command end |
Instance Method Details
#execute(cmd = :cmd) ⇒ Object
19 20 21 |
# File 'lib/epubforge/action/cli_command.rb', line 19 def execute( cmd = :cmd ) @remote ? remote_exec( cmd ) : local_exec( cmd ) end |
#undo ⇒ Object
23 24 25 |
# File 'lib/epubforge/action/cli_command.rb', line 23 def undo execute( :undo ) end |