Class: Wordmove::SqlAdapter::Wpcli

Inherits:
Object
  • Object
show all
Defined in:
lib/wordmove/sql_adapter/wpcli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_config, dest_config, config_key) ⇒ Wpcli

Returns a new instance of Wpcli.



7
8
9
10
# File 'lib/wordmove/sql_adapter/wpcli.rb', line 7

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

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



5
6
7
# File 'lib/wordmove/sql_adapter/wpcli.rb', line 5

def from
  @from
end

#sql_contentObject

Returns the value of attribute sql_content.



4
5
6
# File 'lib/wordmove/sql_adapter/wpcli.rb', line 4

def sql_content
  @sql_content
end

#toObject (readonly)

Returns the value of attribute to.



5
6
7
# File 'lib/wordmove/sql_adapter/wpcli.rb', line 5

def to
  @to
end

Instance Method Details

#commandObject



12
13
14
15
16
17
18
# File 'lib/wordmove/sql_adapter/wpcli.rb', line 12

def command
  unless system('which wp > /dev/null 2>&1')
    raise UnmetPeerDependencyError, "WP-CLI is not installed or not in your $PATH"
  end

  "wp search-replace #{from} #{to} --quiet --skip-columns=guid --all-tables"
end