Class: GitGo::Core

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGitGo::Core

Creates a new instance of GitGo::Core. Will exit(1) the program if GIT_GO_USER or GIT_GO_HOST environment variables aren’t present.



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

def initialize
  @user = ENV["GIT_GO_USER"]
  @host = ENV["GIT_GO_HOST"]

  if [user, host].include?(nil)
    puts "GIT_GO_USER and GIT_GO_HOST not set."
    puts "Run `gg instructions` for more details."
    exit(1)
  end
end

Instance Attribute Details

#hostString (readonly)

Returns the host/domain/ip of the remote machine.

Returns:

  • (String)

    the host/domain/ip of the remote machine.



20
21
22
# File 'lib/git_go.rb', line 20

def host
  @host
end

#userString (readonly)

Returns the user for the #host.

Returns:

  • (String)

    the user for the #host.



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

def user
  @user
end

Class Method Details

.instructionsObject

Prints installation instructions to the console.



66
67
68
69
# File 'lib/git_go.rb', line 66

def self.instructions
  file = File.expand_path("../../assets/instructions", __FILE__)
  File.read(file)
end

Instance Method Details

#clear_connectionnil

Clears a previously established connection reference. After invoking this method, it is again possible to establish a new connection with the remote machine using #connection.

Returns:

  • (nil)

See Also:



61
62
63
# File 'lib/git_go.rb', line 61

def clear_connection
  @connection = nil
end

#connectionGitGo::Connection

Note:

GitGo::Connection::Local is intended for the test-suite. End-users should only use remote IP addresses.

Creates and returns a new instance of GitGo::Connection. Subsequent calls to this method will returned the same cached reference to the previously created instance.

Returns:



47
48
49
50
51
52
53
# File 'lib/git_go.rb', line 47

def connection
  if host == "127.0.0.1"
    @connection ||= Connection::Local.new(self)
  else
    @connection ||= Connection::Remote.new(self)
  end
end