Sha256: 9109ed1e3d163c8fa20fab1792123d5a0c93ce8e6b8fc5a9ac35d268ec4638ba
Contents?: true
Size: 1.13 KB
Versions: 6
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require "hanami/cli" require "uri" module Snowpack module CLI module Application module Commands module DB module Utils class DatabaseConfig def self.for_application(application) new(application[:settings].database_url) end attr_reader :url def initialize(database_url) @url = database_url end def uri @uri ||= URI.parse(url) end def hostname uri.hostname end def db_name @db_name ||= uri.path.gsub(/^\//, '') end def cli_env_vars @cli_env_vars ||= {}.tap do |vars| vars["PGHOST"] = uri.host.to_s vars["PGPORT"] = uri.port.to_s if uri.port vars["PGUSER"] = uri.user.to_s if uri.user vars["PGPASSWORD"] = uri.password.to_s if uri.password end end end end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems