Sha256: 4dd0c340dc06d80c7405add22e04f9b5a4ff3a1ce158f83c003e5ee442c4edb6

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 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'; end

      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
        if skip_tables = config[:skip_tables]
          [*skip_tables].map{ |t| "--ignore-table=#{@id}.#{t}" }.join(' ')
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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