Class: GitGo::Core
- Inherits:
-
Object
- Object
- GitGo::Core
- Defined in:
- lib/git_go.rb
Instance Attribute Summary collapse
-
#host ⇒ String
readonly
The host/domain/ip of the remote machine.
-
#user ⇒ String
readonly
The user for the #host.
Class Method Summary collapse
-
.instructions ⇒ Object
Prints installation instructions to the console.
Instance Method Summary collapse
-
#clear_connection ⇒ nil
Clears a previously established connection reference.
-
#connection ⇒ GitGo::Connection
Creates and returns a new instance of GitGo::Connection.
-
#initialize ⇒ GitGo::Core
constructor
Creates a new instance of GitGo::Core.
Constructor Details
#initialize ⇒ GitGo::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
#host ⇒ String (readonly)
Returns the host/domain/ip of the remote machine.
23 24 25 |
# File 'lib/git_go.rb', line 23 def host @host end |
#user ⇒ String (readonly)
Returns the user for the #host.
20 21 22 |
# File 'lib/git_go.rb', line 20 def user @user end |
Class Method Details
.instructions ⇒ Object
Prints installation instructions to the console.
91 92 93 94 |
# File 'lib/git_go.rb', line 91 def self.instructions file = File.("../../assets/instructions", __FILE__) File.read(file) end |
Instance Method Details
#clear_connection ⇒ nil
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.
86 87 88 |
# File 'lib/git_go.rb', line 86 def clear_connection @connection = nil end |
#connection ⇒ GitGo::Connection
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.
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 |