Class: GitGo::Connection::Local

Inherits:
Base
  • Object
show all
Defined in:
lib/git_go/connection/local.rb

Instance Attribute Summary

Attributes inherited from Base

#core, #current_path

Instance Method Summary collapse

Methods inherited from Base

#cd, #close_and_exit, #directory?, #file?, #mkdir, #mv, #rm

Constructor Details

#initialize(core) ⇒ GitGo::Connection::Local

Creates a new instance of GitGo::Connection::Local.



11
12
13
# File 'lib/git_go/connection/local.rb', line 11

def initialize(core)
  super(core)
end

Instance Method Details

#bash(command) ⇒ Hash

Executes the provided COMMAND on the local machine. This is a blocking (non-asynchronous) operation.



26
27
28
29
30
31
32
33
34
35
# File 'lib/git_go/connection/local.rb', line 26

def bash(command)
  pid, _, stdout, stderr = Open4::popen4(%Q(#{source} cd "#{current_path}"; #{command}))
  _, status = Process::waitpid2(pid)

  {
    :stdout    => stdout.read.strip,
    :stderr    => stderr.read.strip,
    :exit_code => status.exitstatus
  }
end

#closeObject

Clears the ‘@connection` instance variable of this objects parent `Core` instance so new connections can be established.



17
18
19
# File 'lib/git_go/connection/local.rb', line 17

def close
  core.clear_connection
end