Top Level Namespace

Defined Under Namespace

Modules: Database, MsDeploy, Util

Instance Method Summary collapse

Instance Method Details

#config_file_path(config_file_name) ⇒ Object



40
41
42
43
44
# File 'lib/ms_deploy/recipes/setup.rb', line 40

def config_file_path(config_file_name)
  config_file = "#{rails_root}/config/#{config_file_name}"
  raise "No config file '#{config_file}'" unless File.exists? config_file
  config_file
end

#create_databaseObject



56
57
58
59
60
61
62
# File 'lib/ms_deploy/recipes/setup.rb', line 56

def create_database
  create_sql = <<-SQL
      CREATE DATABASE #{db_name};
  SQL

  run "mysql --user=#{db_admin_user} --password=#{db_admin_password} --execute=\"#{create_sql}\""
end

#database_exits?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
# File 'lib/ms_deploy/recipes/setup.rb', line 46

def database_exits?
  exists = false

  run "mysql --user=#{db_admin_user} --password=#{db_admin_password} --execute=\"show databases;\"" do |channel, stream, data|
    exists = exists || data.include?(db_name)
  end

  exists
end

#render_erb_template(template_path, vars = {}) ⇒ Object



3
4
5
6
7
8
# File 'lib/ms_deploy/render.rb', line 3

def render_erb_template(template_path, vars={})
  raise "file '#{template_path}' not exists" unless File.exist? template_path

  template = File.open(template_path, 'r').read
  Erubis::Eruby.new(template).result(vars)
end

#setup_database_permissionsObject



64
65
66
67
68
69
70
# File 'lib/ms_deploy/recipes/setup.rb', line 64

def setup_database_permissions
  grant_sql = <<-SQL
     GRANT ALL PRIVILEGES ON #{db_name}.* TO #{db_user_name}@localhost IDENTIFIED BY '#{db_user_password}';
  SQL

  run "mysql --user=#{db_admin_user} --password=#{db_admin_password} --execute=\"#{grant_sql}\""
end