Class: BradyW::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/database.rb

Overview

TODO: Merge this in with Base_Config Retrieves database related settings from our YAML configuration files

Constant Summary collapse

CREDENTIALS =
[:system, :objectcreation, :general]

Instance Method Summary collapse

Constructor Details

#initializeDatabase

Returns a new instance of Database.



9
10
11
# File 'lib/database.rb', line 9

def initialize
  @config = Config.instance.values
end

Instance Method Details

#connect_codeObject

Using the template in the YAML files, produces a .NET connect string



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/database.rb', line 46

def connect_code
  if @config.db_general_authmode == :winauth
    @config.db_connect_string_winauth.gsub(/@host@/, host).
        gsub(/@initialcatalog@/, name)
  else
    @config.db_connect_string_sqlauth.gsub(/@host@/, host).
        gsub(/@initialcatalog@/, name).
        gsub(/@user@/, user).
        gsub(/@password@/, @config.db_general_password)
  end
end

#hostObject

The hostname where the database lives (db: => hostname:)



24
25
26
# File 'lib/database.rb', line 24

def host
  @config.db_hostname
end

#nameObject

The name of the database/catalog (db: => name:)



29
30
31
32
# File 'lib/database.rb', line 29

def name
  @config.db_name.gsub(/@thismachinehostname@/, Socket.gethostname).
      gsub(/@prefix@/, prefix)
end

#passwordObject

General user’s password



41
42
43
# File 'lib/database.rb', line 41

def password
  @config.db_general_password
end

#userObject

General user’s username



35
36
37
38
# File 'lib/database.rb', line 35

def user
  @config.db_general_user.gsub(/@thismachinehostname@/, Socket.gethostname).
      gsub(/@prefix@/, prefix)
end