Class: ThemeJuice::Tasks::Database

Inherits:
Entry show all
Defined in:
lib/theme-juice/tasks/database.rb

Instance Attribute Summary

Attributes inherited from Entry

#entry

Attributes inherited from ThemeJuice::Task

#tasks

Instance Method Summary collapse

Methods inherited from ThemeJuice::Task

#runner

Constructor Details

#initialize(opts = {}) ⇒ Database

Returns a new instance of Database.



7
8
9
10
11
12
13
14
15
16
# File 'lib/theme-juice/tasks/database.rb', line 7

def initialize(opts = {})
  super

  @entry = {
    :project => @project.name,
    :file    => "#{@env.vm_path}/database/init-custom.sql",
    :name    => "database",
    :id      => "DB"
  }
end

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
26
# File 'lib/theme-juice/tasks/database.rb', line 18

def execute
  if @project.db_host && @project.db_name && @project.db_user && @project.db_pass
    create_entry_file
    create_entry do
%Q{CREATE DATABASE IF NOT EXISTS `#{@project.db_name}`;
GRANT ALL PRIVILEGES ON `#{@project.db_name}`.* TO '#{@project.db_user}'@'localhost' IDENTIFIED BY '#{@project.db_pass}';}
    end
  end
end

#unexecuteObject



28
29
30
31
# File 'lib/theme-juice/tasks/database.rb', line 28

def unexecute
  remove_entry
  drop_database
end