Sha256: 04eec18eea523e1c71cac31ca7ce9e66bad52e4061e3c93cc4df16490e2ae14b

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "uff_db_loader/postgresql"
require "uff_db_loader/mysql"

module UffDbLoader
  class Configuration
    attr_accessor(
      :environments,
      :ssh_host,
      :ssh_user,
      :db_name,
      :db_system,
      :app_name,
      :dumps_directory,
      :database_config_file,
      :container_name,
      :local_restore_command_path
    )

    def initialize
      @environments = nil
      @ssh_host = nil
      @ssh_user = nil
      @db_name = nil
      @db_system = nil
      @app_name = Dir.pwd.split("/").last
      @dumps_directory = File.join(Dir.pwd, "dumps")
      @database_config_file = File.join(Dir.pwd, "config", "database.yml")
      @container_name = nil
      @local_restore_command_path = nil
    end

    def database
      db_name || ssh_user
    end

    def database_system
      case db_system.to_sym
      when :postgresql
        UffDbLoader::Postgresql
      when :mysql
        UffDbLoader::Mysql
      else
        raise UnknownDatabaseSystem, "Could not identify database system. Use `config.db_system` to configure it."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uff_db_loader-3.2.0 lib/configuration.rb