Class: GitCommander::System::Command Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/git_commander/system.rb

Overview

This class is abstract.

Wraps a system command with logging, stderr, and stdout capture

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_with_arguments, options = {}) ⇒ Command

Returns a new instance of Command.



17
18
19
20
21
# File 'lib/git_commander/system.rb', line 17

def initialize(command_with_arguments, options = {})
  @command_with_arguments = command_with_arguments
  @name = command_with_arguments.split(/\w/i).first
  @options = DEFAULT_RUN_OPTIONS.merge(options)
end

Instance Attribute Details

#command_with_argumentsObject (readonly)

Returns the value of attribute command_with_arguments.



16
17
18
# File 'lib/git_commander/system.rb', line 16

def command_with_arguments
  @command_with_arguments
end

#errorObject

Returns the value of attribute error.



15
16
17
# File 'lib/git_commander/system.rb', line 15

def error
  @error
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/git_commander/system.rb', line 16

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/git_commander/system.rb', line 16

def options
  @options
end

#outputObject

Returns the value of attribute output.



15
16
17
# File 'lib/git_commander/system.rb', line 15

def output
  @output
end

#statusObject

Returns the value of attribute status.



15
16
17
# File 'lib/git_commander/system.rb', line 15

def status
  @status
end

Instance Method Details

#runObject



23
24
25
26
27
# File 'lib/git_commander/system.rb', line 23

def run
  log_command_initiated
  @output, @error, @status = Open3.capture3(command_with_arguments)
  log_command_completed
end