class EpubForge::Action::CliSequence
Public Class Methods
new()
click to toggle source
# File lib/epubforge/action/cli_sequence.rb, line 4 def initialize @defaults = {} @local_dir @commands = [] @completed = [] end
Public Instance Methods
add_command( command, undo = "", opts = {} )
click to toggle source
# File lib/epubforge/action/cli_sequence.rb, line 46 def add_command( command, undo = "", opts = {} ) for default, setting in @defaults opts[default] ||= setting end @commands.push( CliCommand.new(command, undo, opts) ) end
add_local_command( command, undo = nil, opts = {} )
click to toggle source
# File lib/epubforge/action/cli_sequence.rb, line 19 def add_local_command( command, undo = nil, opts = {} ) add_command( command, undo, opts ) end
add_remote_command( command, undo = nil, opts = {} )
click to toggle source
# File lib/epubforge/action/cli_sequence.rb, line 23 def add_remote_command( command, undo = nil, opts = {} ) opts[:remote] ||= @remote # the default username/host can be overridden by sending a different opts[:remote] add_command( command, undo, opts) end
default( k, v )
click to toggle source
# File lib/epubforge/action/cli_sequence.rb, line 11 def default( k, v ) if k == :remote @remote = v else @defaults[k] = v end end
execute()
click to toggle source
# File lib/epubforge/action/cli_sequence.rb, line 28 def execute @failed = false while (cmd = @commands.shift) && (@failed == false) @failed = true unless cmd.execute.success? @completed.push( cmd ) end undo unless @failed == false !@failed end
undo()
click to toggle source
# File lib/epubforge/action/cli_sequence.rb, line 39 def undo while cmd = @completed.pop result = cmd.undo @commands.unshift( cmd ) end end