Module DBI::Utils
In: lib/dbi/utils.rb
lib/dbi/utils/tableformatter.rb
lib/dbi/utils/xmlformatter.rb

Utility classes and methods for use by both DBDs and consumers.

Methods

Classes and Modules

Module DBI::Utils::ConvParam
Module DBI::Utils::TableFormatter
Module DBI::Utils::XMLFormatter

Public Class methods

Given a block, returns the execution time for the block.

[Source]

# File lib/dbi/utils.rb, line 13
        def self.measure
            start = ::Time.now
            yield
            ::Time.now - start
        end

parse a string of the form "database=xxx;key=val;…" or database:host and return hash of key/value pairs

Used in DBI.connect and offspring.

[Source]

# File lib/dbi/utils.rb, line 25
        def self.parse_params(str)
            # improved by John Gorman <jgorman@webbysoft.com>
            params = str.split(";")
            hash = {}
            params.each do |param| 
                key, val = param.split("=") 
                hash[key] = val if key and val
            end 
            if hash.empty?
                database, host = str.split(":")
                hash['database'] = database if database
                hash['host']     = host if host   
            end
            hash 
        end

[Validate]