Sha256: 5a82bb038531aa809e0a35a9ae2c5537ad8d529ce4b98c0a7cc8b0ec104e0762

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

module Wordmove
  module SqlAdapter
    class Wpcli
      attr_accessor :sql_content
      attr_reader :from, :to, :local_path

      def initialize(source_config, dest_config, config_key, local_path)
        @from = source_config[config_key]
        @to = dest_config[config_key]
        @local_path = local_path
      end

      def command
        unless wp_in_path?
          raise UnmetPeerDependencyError, "WP-CLI is not installed or not in your $PATH"
        end

        "wp search-replace --path=#{local_path} #{from} #{to} --quiet "\
        "--skip-columns=guid --all-tables --allow-root"
      end

      private

      def wp_in_path?
        system('which wp > /dev/null 2>&1')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wordmove-5.0.2 lib/wordmove/sql_adapter/wpcli.rb
wordmove-5.0.1 lib/wordmove/sql_adapter/wpcli.rb