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.
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
#host ⇒ String (readonly)
Returns the host/domain/ip of the remote machine.
20 21 22 |
# File 'lib/git_go.rb', line 20 def host @host end |
#user ⇒ String (readonly)
Returns the user for the #host.
17 18 19 |
# File 'lib/git_go.rb', line 17 def user @user end |
Class Method Details
.instructions ⇒ Object
Prints installation instructions to the console.
66 67 68 69 |
# File 'lib/git_go.rb', line 66 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.
61 62 63 |
# File 'lib/git_go.rb', line 61 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.
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 |