lib/dbi/dbrc.rb in dbi-dbrc-1.4.1 vs lib/dbi/dbrc.rb in dbi-dbrc-1.5.0

- old
+ new

@@ -16,11 +16,11 @@ # This error is raised if anything fails trying to read the config file. class Error < StandardError; end # The version of the dbi-dbrc library - VERSION = '1.4.1'.freeze + VERSION = '1.5.0'.freeze WINDOWS = File::ALT_SEPARATOR # :no-doc: # The database or host to be connected to. attr_accessor :database @@ -116,10 +116,11 @@ home = '/' end end @dbrc_file = File.join(home, '.dbrc') + dbrc_dir = home else raise Error, 'bad directory' unless File.directory?(dbrc_dir) @dbrc_file = File.join(dbrc_dir, '.dbrc') end @@ -218,11 +219,11 @@ end # Parse the text out of the .dbrc file. This is the only method you # need to redefine if writing your own config handler. def parse_dbrc_config_file(file=@dbrc_file) - IO.foreach(file){ |line| + File.foreach(file){ |line| next if line =~ /^#/ # Ignore comments db, user, pwd, driver, timeout, max, interval = line.split next unless @database == db @@ -251,11 +252,11 @@ end # A subclass of DBRC designed to handle .dbrc files in XML format. The # public methods of this class are identical to DBRC. - class XML < DBRC + class DBRC::XML < DBRC require 'rexml/document' # Good enough for small files include REXML private @@ -280,10 +281,10 @@ end end # A subclass of DBRC designed to handle .dbrc files in YAML format. The # public methods of this class are identical to DBRC. - class YML < DBRC + class DBRC::YML < DBRC require 'yaml' private def parse_dbrc_config_file(file=@dbrc_file)