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, local_path) ⇒ Wpcli

Returns a new instance of Wpcli.



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

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

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

#local_pathObject (readonly)

Returns the value of attribute local_path.



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

def local_path
  @local_path
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



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

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 --path=#{local_path} #{from} #{to} --quiet "\
  "--skip-columns=guid --all-tables --allow-root"
end