Class: ThemeJuice::Tasks::WPConfig

Inherits:
ThemeJuice::Task show all
Defined in:
lib/theme-juice/tasks/wp_config.rb

Instance Attribute Summary

Attributes inherited from ThemeJuice::Task

#tasks

Instance Method Summary collapse

Methods inherited from ThemeJuice::Task

#runner, #unexecute

Constructor Details

#initialize(opts = {}) ⇒ WPConfig

Returns a new instance of WPConfig.



7
8
9
10
11
# File 'lib/theme-juice/tasks/wp_config.rb', line 7

def initialize(opts = {})
  super

  @using_wp_config_sample = false
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/theme-juice/tasks/wp_config.rb', line 13

def execute
  return if !@project.wp_config_modify || @project.no_wp || @project.no_db

  unless wp_config_is_setup?
    @io.say "Could not find wp-config file to modify", {
      :color => :yellow, :icon => :notice }

    unless wp_config_sample_is_setup?
      @io.error "Could not find a wp-config-sample file either. Are you sure one exists in the project directory?"
    end

    @util.create_file(wp_config_file, { :verbose => @env.verbose,
      :capture => @env.quiet }) { File.read(wp_config_sample_file) }

    @using_wp_config_sample = true
  end

  modify_wp_config_settings({
    :db_name     => "#{@project.db_name}",
    :db_user     => "#{@project.db_user}",
    :db_password => "#{@project.db_pass}",
    :db_host     => "#{@project.db_host}",
    :wp_debug    => true
  })
end