lib/dumper/database/postgresql.rb in dumper-1.0.2 vs lib/dumper/database/postgresql.rb in dumper-1.1.0

- old
+ new

@@ -3,30 +3,30 @@ class PostgreSQL < Base DUMP_TOOL = 'pg_dump' FILE_EXT = 'sql.gz' def command - "cd #{tmpdir} && #{password_variable} #{dump_tool_path} #{connection_options} #{@config.database} | gzip > #{filename}" + "cd #{tmpdir} && #{password_variable} #{dump_tool_path} #{connection_options} #{@config[:database]} | gzip > #{filename}" end def connection_options [ :host, :port, :socket ].map do |option| - next if @config.send(option).blank? - "--#{option}='#{@config.send(option)}'".gsub('--socket', '--host') + next if @config[option].blank? + "--#{option}='#{@config[option]}'".gsub('--socket', '--host') end.compact.join(' ') end def password_variable - @config.password.blank? ? '' : "PGPASSWORD='#{@config.password}'" + @config[:password].blank? ? '' : "PGPASSWORD='#{@config[:password]}'" end - def config_for(rails_env=nil) + def set_config_for(rails_env=nil) return unless defined?(ActiveRecord::Base) && ActiveRecord::Base.configurations && (config = ActiveRecord::Base.configurations[rails_env]) && (config['adapter'] == 'postgresql') - { + @config = { :host => config['host'], :port => config['port'], :username => config['username'], :password => config['password'], :database => config['database'],