Sha256: 5e92f8502d53b07f1eacffc40746861e604c4ccf5f4d08db9c1007d77838469c

Contents?: true

Size: 1016 Bytes

Versions: 12

Compression:

Stored size: 1016 Bytes

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'],
        'database': config['database'],
      }
    end

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

    def database_name
      config['database']
    end

    def migrations_path
      @migrations_path
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubypitaya-1.7.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.6.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.6.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.6.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.5.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.4.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.4.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.3.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.3.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.2.9 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.2.7 ./lib/rubypitaya/core/database_config.rb
rubypitaya-1.1.0 ./lib/rubypitaya/core/database_config.rb