class PgcpRunner
Public Instance Methods
cp()
click to toggle source
# File lib/pgcp.rb, line 17 def cp config = load_config_file(options['config'] || File.join(ENV['HOME'], '.pgcp.yml')) if options['log'] Pgcp.log_file = options['log'] end src = config['databases'][options['source']].symbolize_keys! dest = config['databases'][options['dest']].symbolize_keys! begin tr = Transport.new(src, dest) if options['table'].include? '*' if (not options['table'].include? '.') or (options['table'].count('.') > 1) Pgcp.logger.error 'Globbed tables must have schema name, e.g. public.test* is valid but test* is not.' return end tr.copy_tables(options['table'], force_schema: options['force_schema']) else tr.copy_table(options['table'], nil, force_schema: options['force_schema']) end rescue Exception => e Pgcp.logger.error(e.message) return end end
Private Instance Methods
load_config_file(path)
click to toggle source
# File lib/pgcp.rb, line 47 def load_config_file(path) config = {} if not path.nil? and File.exists?(path) config = YAML::load_file(path) end config end