lib/dbi/dbrc.rb in dbi-dbrc-1.0.1 vs lib/dbi/dbrc.rb in dbi-dbrc-1.1.0

- old
+ new

@@ -1,8 +1,7 @@ -if File::ALT_SEPARATOR +if PLATFORM.match("mswin") require "win32/file" - include Win32 end require "sys/admin" include Sys @@ -12,11 +11,11 @@ # the error that is raised. A subclass of StandardError. class DBRCError < StandardError; end # The main class. class DBRC - VERSION = "1.0.1" + VERSION = "1.1.0" attr_accessor :database, :user, :password, :driver, :dsn attr_accessor :maximum_reconnects, :timeout, :interval, :dbrc_dir # Returns a new DBRC object. The contents of the object depend on the # arguments passed to the constructor. If only a database name is @@ -32,11 +31,11 @@ # combination, then a DBRCError is raised. If the .dbrc file cannot # be found, or is setup improperly with regards to permissions or # properties, a DBRCError is raised. def initialize(database,user=nil,dbrc_dir=nil) if dbrc_dir.nil? - if File::ALT_SEPARATOR + if PLATFORM.match("mswin") home = ENV["USERPROFILE"] || ENV["HOME"] file = nil if home file = home + "\\.dbrc" @@ -58,22 +57,22 @@ encrypted = false # Win32 only check_file() # If on Win32 and the file is encrypted, decrypt it. - if File::ALT_SEPARATOR && File.encrypted?(@dbrc_file) + if PLATFORM.match("mswin") && File.encrypted?(@dbrc_file) encrypted = true File.decrypt(@dbrc_file) end parse_dbrc_config_file() validate_data() convert_numeric_strings() create_dsn_string() # If on Win32 and the file was encrypted, re-encrypt it - if File::ALT_SEPARATOR && encrypted + if PLATFORM.match("mswin") && encrypted File.encrypt(@dbrc_file) end end private @@ -105,10 +104,10 @@ def check_file(file=@dbrc_file) File.open(file){ |f| # Permissions must be set to 600 or better on Unix systems. # Must be hidden on Win32 systems. - if File::ALT_SEPARATOR + if PLATFORM.match("mswin") unless File.hidden?(file) raise DBRCError, "The .dbrc file must be hidden" end else unless (f.stat.mode & 077) == 0