Sha256: 3420ae99c831d93b090ea73dba6e7ce72900950e0667618a11690f79afb83fc9

Contents?: true

Size: 782 Bytes

Versions: 7

Compression:

Stored size: 782 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

7 entries across 7 versions & 3 rubygems

Version Path
astrails-safe-0.3.1 lib/astrails/safe/mysqldump.rb
astrails-safe-0.3.0 lib/astrails/safe/mysqldump.rb
netguru-safe-0.2.11 lib/astrails/safe/mysqldump.rb
netguru-safe-0.2.10 lib/astrails/safe/mysqldump.rb
netguru-safe-0.2.9 lib/astrails/safe/mysqldump.rb
darkofabijan-astrails-safe-0.2.9 lib/astrails/safe/mysqldump.rb
darkofabijan-astrails-safe-0.2.8 lib/astrails/safe/mysqldump.rb