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.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git_go.rb', line 30

def initialize
  if ENV["GIT_GO_URI"].nil?
    puts
    puts "GIT_GO_URI not set."
    puts "Run `gg instructions` for more details."
    puts
    puts "NOTE"
    puts
    puts "GIT_GO_USER and GIT_GO_HOST have been removed."
    puts "Please use GIT_GO_URI instead. For example:"
    puts
    puts "  export [email protected]"
    puts
    puts "Or with a static IP:"
    puts
    puts "  export [email protected]"
    puts
    return exit(1)
  end

  begin
    uri = URI.parse("ssh://#{ENV["GIT_GO_URI"]}")
  rescue URI::InvalidURIError
    puts
    puts "Your GIT_GO_URI (#{ENV["GIT_GO_URI"]}) is invalid."
    puts "Run `gg instructions` for more details."
    puts
    return exit(1)
  end

  @user, @host = uri.user, uri.host
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.



23
24
25
# File 'lib/git_go.rb', line 23

def host
  @host
end

#userString (readonly)

Returns the user for the #host.

Returns:

  • (String)

    the user for the #host.



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

def user
  @user
end

Class Method Details

.instructionsObject

Prints installation instructions to the console.



91
92
93
94
# File 'lib/git_go.rb', line 91

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:



86
87
88
# File 'lib/git_go.rb', line 86

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:



72
73
74
75
76
77
78
# File 'lib/git_go.rb', line 72

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