Class: GitCompound::Repository::GitCommand
- Inherits:
-
Object
- Object
- GitCompound::Repository::GitCommand
- Extended by:
- Logger::Debugger
- Defined in:
- lib/git_compound/repository/git_command.rb,
lib/git_compound/logger/debug/repository.rb
Overview
Debug messages for GitCommand
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #execute ⇒ Object
- #execute! ⇒ Object
-
#initialize(cmd, args, workdir = nil) ⇒ GitCommand
constructor
A new instance of GitCommand.
- #valid? ⇒ Boolean
Methods included from Logger::Debugger
Constructor Details
#initialize(cmd, args, workdir = nil) ⇒ GitCommand
Returns a new instance of GitCommand.
10 11 12 13 |
# File 'lib/git_compound/repository/git_command.rb', line 10 def initialize(cmd, args, workdir = nil) @command = "git #{cmd} #{args}" @workdir = workdir end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
8 9 10 |
# File 'lib/git_compound/repository/git_command.rb', line 8 def command @command end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
8 9 10 |
# File 'lib/git_compound/repository/git_command.rb', line 8 def output @output end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/git_compound/repository/git_command.rb', line 8 def status @status end |
Instance Method Details
#execute ⇒ Object
22 23 24 25 26 |
# File 'lib/git_compound/repository/git_command.rb', line 22 def execute execute! raise GitCommandError, @output unless valid? @output end |
#execute! ⇒ Object
15 16 17 18 19 20 |
# File 'lib/git_compound/repository/git_command.rb', line 15 def execute! path = @workdir ? @workdir : Dir.pwd Dir.chdir(path) { @output = `(#{@command}) 2>&1` } @status = $CHILD_STATUS.exitstatus @output.sub!(/\n\Z/, '') end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/git_compound/repository/git_command.rb', line 28 def valid? @status == 0 end |