Created
March 27, 2009 09:48
-
-
Save wjessop/86623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ultrasphinx | |
class Configure | |
class << self | |
def setup_source_database(klass) | |
# Supporting Postgres now | |
connection_settings = klass.connection.instance_variable_get("@config") | |
raise ConfigurationError, "Unsupported database adapter" unless connection_settings || defined?(JRUBY_VERSION) | |
adapter_defaults = DEFAULTS[ADAPTER] | |
raise ConfigurationError, "Unsupported database adapter" unless adapter_defaults | |
conf = [adapter_defaults] | |
connection_settings.reverse_merge(CONNECTION_DEFAULTS).each do |key, value| | |
value = YAML.parse_file( "#{RAILS_ROOT}/config/database.yml" )['production_replica']['host'].value if (RAILS_ENV == 'production' and key == :host) | |
conf << "#{CONFIG_MAP[key]} = #{value}" if CONFIG_MAP[key] | |
end | |
conf.sort.join("\n") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment