Module: GitRunner::Command

Extended by:
Command
Included in:
Command
Defined in:
lib/git-runner/command.rb,
lib/git-runner/command.rb

Defined Under Namespace

Classes: Failure, Result

Instance Method Summary collapse

Instance Method Details

#execute(*commands) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/git-runner/command.rb', line 8

def execute(*commands)
  # Extract options (if any)
  opts = commands.last.is_a?(Hash) ? commands.pop : {}

  # Set session callback procs
  session.outproc = opts[:outproc]
  session.errproc = opts[:errproc]

  # Cycle through and run commands
  execute_commands(commands)

  # Clear session callback procs
  session.outproc = nil
  session.errproc = nil

  # Return full output of the last ran command (should this be all commands perhaps?)
  history.last.out
end

#historyObject



27
28
29
# File 'lib/git-runner/command.rb', line 27

def history
  @history ||= []
end

#history_to_sObject



31
32
33
# File 'lib/git-runner/command.rb', line 31

def history_to_s
  history.map(&:to_s).join("\n#{'-' * 20}\n")
end