Class: Pgchief::Command::RetrieveConnectionString

Inherits:
Base
  • Object
show all
Defined in:
lib/pgchief/command/retrieve_connection_string.rb

Overview

Class to view database connection string

Instance Attribute Summary collapse

Attributes inherited from Base

#conn, #params

Instance Method Summary collapse

Methods inherited from Base

call

Constructor Details

#initialize(username, database = nil) ⇒ RetrieveConnectionString

Returns a new instance of RetrieveConnectionString.



9
10
11
12
13
# File 'lib/pgchief/command/retrieve_connection_string.rb', line 9

def initialize(username, database = nil)
  @username = username
  @database = database
  @connection_string = nil
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



7
8
9
# File 'lib/pgchief/command/retrieve_connection_string.rb', line 7

def database
  @database
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/pgchief/command/retrieve_connection_string.rb', line 7

def username
  @username
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
# File 'lib/pgchief/command/retrieve_connection_string.rb', line 15

def call
  File.foreach(Config.credentials_file) do |line|
    @connection_string = line if regex.match?(line)
  end

  @connection_string.nil? ? 'No connection string found' : @connection_string
end