module DbAgent
Constants
- LOGGER
Logger instance to use
- ROOT_FOLDER
Root folder of the project structure
- VERSION
Current version of
DbAgent
Public Class Methods
_!(path)
click to toggle source
Simply checks that a path exists of raise an error
# File lib/db_agent.rb, line 11 def self._!(path) Path(path).tap do |p| raise "Missing #{p.basename}." unless p.exists? end end
default_config()
click to toggle source
What database configuration to use for normal access
# File lib/db_agent.rb, line 29 def self.default_config cfg = { adapter: ENV['DBAGENT_ADAPTER'] || 'postgres', port: ENV['DBAGENT_PORT'] || 5432, database: ENV['DBAGENT_DB'] || 'suppliers-and-parts', user: ENV['DBAGENT_USER'] || 'dbagent', password: ENV['DBAGENT_PASSWORD'] || 'dbagent', test: false } # Favor a socket approach if specified, otherwise fallback to # host with default to postgres if socket = ENV['DBAGENT_SOCKET'] cfg[:socket] = socket else cfg[:host] = ENV['DBAGENT_HOST'] || 'localhost' end # Set a logger if explicitly requested if ENV['DBAGENT_LOGSQL'] == 'yes' cfg[:loggers] = [LOGGER] end cfg end
default_handler()
click to toggle source
# File lib/db_agent.rb, line 65 def self.default_handler DbHandler.factor({ config: default_config, superconfig: default_superconfig, root: ROOT_FOLDER }) end
default_superconfig()
click to toggle source
What database configuration to use for superuser access
# File lib/db_agent.rb, line 56 def self.default_superconfig cfg = default_config cfg.merge({ user: ENV['DBAGENT_SUPER_USER'] || cfg[:user], database: ENV['DBAGENT_SUPER_DB'] || cfg[:database], password: ENV['DBAGENT_SUPER_PASSWORD'] || cfg[:password] }) end