Sha256: 0c0c2198b6a00d009fc0bd1be087e7c0ba3b4f91a7e4ab5a22c2052037efe78e

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

module WebTranslateIt

  module Safe

    class Mysqldump < Source

      def command
        "mysqldump --defaults-extra-file=#{mysql_password_file} #{config[:options]} #{mysql_skip_tables} #{@id}"
      end

      def extension = '.sql'

      protected

      def mysql_password_file
        WebTranslateIt::Safe::TmpFile.create('mysqldump') do |file|
          file.puts '[mysqldump]'
          %w[user password socket host port].each do |k|
            v = config[k]
            # values are quoted if needed
            file.puts "#{k} = #{v.inspect}" if v
          end
        end
      end

      def mysql_skip_tables
        return unless (skip_tables = config[:skip_tables])

        [*skip_tables].map { |t| "--ignore-table=#{@id}.#{t}" }.join(' ')
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webtranslateit-safe-0.4.0 lib/webtranslateit/safe/mysqldump.rb