Class: SchemaEvolutionManager::ConnectionData

Inherits:
Object
  • Object
show all
Defined in:
lib/schema-evolution-manager/connection_data.rb

Constant Summary collapse

DEFAULT_PORT =
5432

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, name, opts = {}) ⇒ ConnectionData

Returns a new instance of ConnectionData.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/schema-evolution-manager/connection_data.rb', line 9

def initialize(host, name, opts={})
  @host = host
  @name = name

  port = opts.delete(:port).to_s
  if port.to_s.empty?
    @port = DEFAULT_PORT
  else
    @port = port.to_i
  end
  Preconditions.check_argument(@port > 0, "Port must be > 0")

  @user = opts.delete(:user)
  Preconditions.assert_empty_opts(opts)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/schema-evolution-manager/connection_data.rb', line 7

def host
  @host
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/schema-evolution-manager/connection_data.rb', line 7

def name
  @name
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/schema-evolution-manager/connection_data.rb', line 7

def port
  @port
end

#userObject (readonly)

Returns the value of attribute user.



7
8
9
# File 'lib/schema-evolution-manager/connection_data.rb', line 7

def user
  @user
end

Instance Method Details

#pgpass(password = nil) ⇒ Object

Returns a valid pgpass line entry representing this connection.

Parameters:

  • password:

    Optional password to include in the connection string



28
29
30
# File 'lib/schema-evolution-manager/connection_data.rb', line 28

def pgpass(password=nil)
  [@host, @port, @name, @user, password.to_s].join(":")
end