Class: URI::PgSQL
Constant Summary
collapse
- SCHEME =
'pgsql'.freeze
- DEFAULT_HOST =
'localhost'.freeze
- DEFAULT_PORT =
5432
- DEFAULT_QUERY =
''.freeze
- DUMP =
'pg_dump'.to_cmd.freeze
- COMPONENT =
[
:scheme,
:userinfo,
:host,
:path,
:query
].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Generic
#add_query, #checkout, #commit, #mk_custom_opts, #pathname, #pathname=, #to_yaml, #to_yaml_type
Class Method Details
.build(args) ⇒ Object
27
28
29
30
|
# File 'lib/uri/pgsql.rb', line 27
def self.build ( args )
tmp = Util::make_components_hash(self, args)
return super(tmp)
end
|
Instance Method Details
#mk_connection_opts ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/uri/pgsql.rb', line 33
def mk_connection_opts
opts = []
opts << '-h' << @host
opts << '-p' << @port if @port != DEFAULT_PORT
opts << '-U' << @user if @user
opts
end
|
#mk_dump_opts(out = nil) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/uri/pgsql.rb', line 42
def mk_dump_opts ( out=nil )
opts = %w[ -F c -Z 9 -C ]
opts << '-f' << 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 << '-t' << table << base
end
opts
end
|
59
60
61
62
63
64
|
# File 'lib/uri/pgsql.rb', line 59
def save
out = TempPath.new('dump', pathname.basename.to_s)
cmd = DUMP + mk_connection_opts + mk_dump_opts(out) + mk_custom_opts
cmd.run(self.runner)
out
end
|