Sha256: 8f258e4fa7af8a0fe981e694d12e4b5d871861fdba7fc1901078fbf3a35220af

Contents?: true

Size: 1.11 KB

Versions: 28

Compression:

Stored size: 1.11 KB

Contents

require 'flydata/command/sync'
require 'flydata/source_mysql/command/mysql_command_base'

# Command class must be in module Flydata::Command
module Flydata
  module Command
    class Mysqldump < Sync
      include MysqlCommandBase

      def generate_command(dbconf, args)
        dbconf.delete('tables')
        dbconf[:custom_option_end] = build_custom_option_end(args)
        dbconf[:command] = 'mysqldump'
        FlydataCore::Mysql::CommandGenerator::generate_mysql_cmd(dbconf)
      end

      # Workaround to build --where options correctly
      #
      # [Background]
      # Arguments including single/double quotations don't work because those quotations
      # are removed from the system.
      #
      # User's command:
      #   flydata mysqldump table_a --where "id = 1001"
      # ARGV:
      #   ["table_a", "--where", "id", "=", "1001"]
      #
      def build_custom_option_end(args)
        ret = []
        while v = args.shift
          ret << v
          if v == '--where'
            ret << %Q|"#{args.join(' ')}"|
            break
          end
        end
        ret.join(' ')
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
flydata-0.8.10.2 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.10.1 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.9.11 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.10 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.9 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.8 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.7 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.6 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.5 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.4 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.3 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.2 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.1 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.8.0 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.7.19 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.7.18 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.7.17 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.7.16 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.7.15 lib/flydata/source_mysql/command/mysqldump.rb
flydata-0.7.14 lib/flydata/source_mysql/command/mysqldump.rb