Sha256: ef96ecd2a163ded04e2efc7d75d2ce09576b545250a2a1bb560df109c2983fd0

Contents?: true

Size: 740 Bytes

Versions: 3

Compression:

Stored size: 740 Bytes

Contents

module WebTranslateIt
  module Safe
    class Pgdump < Source

      def command
        if config['password']
          ENV['PGPASSWORD'] = config['password']
        else
          ENV['PGPASSWORD'] = nil
        end
        "pg_dump #{postgres_options} #{postgres_username} #{postgres_host} #{postgres_port} #{@id}"
      end

      def extension; '.sql'; end

      protected

      def postgres_options
        config[:options]
      end

      def postgres_host
        config['host'] && "--host='#{config["host"]}'"
      end

      def postgres_port
        config['port'] && "--port='#{config["port"]}'"
      end

      def postgres_username
        config['user'] && "--username='#{config["user"]}'"
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webtranslateit-safe-0.4.3 lib/webtranslateit/safe/pgdump.rb
webtranslateit-safe-0.4.2 lib/webtranslateit/safe/pgdump.rb
webtranslateit-safe-0.4.1 lib/webtranslateit/safe/pgdump.rb