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
21
22
23
24
25
26
27
28
29
# File 'lib/wordmove/sql_adapter/wpcli.rb', line 13

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

  opts = [
    "--path=#{cli_config_path}",
    from,
    to,
    "--quiet",
    "--skip-columns=guid",
    "--all-tables",
    "--allow-root"
  ]

  "wp search-replace #{opts.join(' ')}"
end