Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 24 lines (22 sloc) 0.551 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# Returns a data structure representing the currently configured database in
# "database.yml" for this "RAILS_ENV".
#
# Examples:
#
# # Return current database information:
# struct = DatabaseYmlReader.read
#
# # Print currently-configured database name:
# p struct.database
class DatabaseYmlReader
  require 'erb'
  require 'yaml'
  require 'ostruct'

  def self.read
    return OpenStruct.new(
      YAML.load(
        ERB.new(
          File.read(
            File.join(RAILS_ROOT, "config", "database.yml"))).result)[RAILS_ENV])
  end
end
Something went wrong with that request. Please try again.