Sha256: 7536dfd16ca955f3a2bdbd5a4faec3444ed19272a0eff5b42cdb9acabb1caa26

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

module Astrails
  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
        Astrails::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

1 entries across 1 versions & 1 rubygems

Version Path
akupchanko-astrails-safe-0.3.1 lib/astrails/safe/mysqldump.rb