Class URI::MySQL
In: lib/uri/mysql.rb
Parent: GenericEx

Methods

Constants

SCHEME = 'mysql'.freeze
DEFAULT_HOST = 'localhost'.freeze
DEFAULT_PORT = 3306
DEFAULT_QUERY = ''.freeze
COMPONENT = [ :scheme, :userinfo, :host, :path, :query

Public Instance methods

[Source]

# File lib/uri/mysql.rb, line 24
    def mk_connection_opts
      opts = []
      opts << '-h' << @host
      opts << '-P' << @port if @port != DEFAULT_PORT
      opts << '-p' << @password if @password
      opts << '-u' << @user if @user
      opts
    end

[Source]

# File lib/uri/mysql.rb, line 34
    def mk_dump_opts ( out=nil )
      opts = %w[ -C ]
      opts << '-r' << out if out
      base, table = pathname.split
      base, table = base.to_s, table.to_s
      if base =~ /[\.\/]/
        opts << table
      else
        if base =~ /\//
          raise ArgumentError, "Use database/table not #{pathname}"
        end
        opts << base << table
      end
      opts
    end

[Source]

# File lib/uri/mysql.rb, line 51
    def save
      out = TempPath.new('dump', pathname.basename.to_s)
      d = shell.mysqldump! mk_connection_opts, mk_dump_opts(out), mk_custom_opts
      [out, d]
    end

[Validate]