Sha256: 78dda4f247c36885d67a7feaafd65d7c80e8b7bf341b63980a53d906aae03358

Contents?: true

Size: 1.07 KB

Versions: 51

Compression:

Stored size: 1.07 KB

Contents

require 'erb'
require 'yaml'

require 'rubypitaya/core/path'

module RubyPitaya

  class DatabaseConfig

    def initialize(environment_name, database_config_path)
      @environment_name = environment_name

      yaml_contents = File.open(database_config_path).read
      @config = YAML.load( ERB.new(yaml_contents).result )
    end

    def config
      @config[@environment_name]
    end

    def connection_data
      {
        'adapter': config['adapter'],
        'encoding': config['encoding'],
        'pool': config['pool'],
        'host': config['host'],
        'user': config['user'],
        'password': config['password'],
        'database': config['database'],
      }
    end

    def connection_data_without_database
      {
        'adapter': config['adapter'],
        'encoding': config['encoding'],
        'pool': config['pool'],
        'host': config['host'],
        'user': config['user'],
        'password': config['password'],
      }
    end

    def database_name
      config['database']
    end

    def migrations_path
      @migrations_path
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
rubypitaya-2.20.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.19.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.19.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.18.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.17.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.16.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.15.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.14.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.14.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.13.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.13.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.12.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.11.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.11.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.11.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.10.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.9.3 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.9.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.9.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.9.0 ./lib/rubypitaya/core/database_config.rb