Class: Anvil::Mysql::DatabaseCreator

Inherits:
Struct
  • Object
show all
Defined in:
lib/anvil/mysql/database_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#db_nameObject

Returns the value of attribute db_name

Returns:

  • (Object)

    the current value of db_name



7
8
9
# File 'lib/anvil/mysql/database_creator.rb', line 7

def db_name
  @db_name
end

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



7
8
9
# File 'lib/anvil/mysql/database_creator.rb', line 7

def host
  @host
end

#mysql_hostObject

Returns the value of attribute mysql_host

Returns:

  • (Object)

    the current value of mysql_host



7
8
9
# File 'lib/anvil/mysql/database_creator.rb', line 7

def mysql_host
  @mysql_host
end

#mysql_passwordObject

Returns the value of attribute mysql_password

Returns:

  • (Object)

    the current value of mysql_password



7
8
9
# File 'lib/anvil/mysql/database_creator.rb', line 7

def mysql_password
  @mysql_password
end

#mysql_portObject

Returns the value of attribute mysql_port

Returns:

  • (Object)

    the current value of mysql_port



7
8
9
# File 'lib/anvil/mysql/database_creator.rb', line 7

def mysql_port
  @mysql_port
end

#mysql_userObject

Returns the value of attribute mysql_user

Returns:

  • (Object)

    the current value of mysql_user



7
8
9
# File 'lib/anvil/mysql/database_creator.rb', line 7

def mysql_user
  @mysql_user
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



7
8
9
# File 'lib/anvil/mysql/database_creator.rb', line 7

def user
  @user
end

Instance Method Details

#callObject



8
9
10
# File 'lib/anvil/mysql/database_creator.rb', line 8

def call
  ScriptRunner.new(script, user, host, logger).call
end

#db_scriptObject



12
13
14
# File 'lib/anvil/mysql/database_creator.rb', line 12

def db_script
  "CREATE DATABASE #{db_name};"
end

#loggerObject



20
21
22
# File 'lib/anvil/mysql/database_creator.rb', line 20

def logger
  Anvil::Logger.new(self.class.name)
end

#scriptObject



16
17
18
# File 'lib/anvil/mysql/database_creator.rb', line 16

def script
  "mysql -u#{mysql_user} -p#{mysql_password} -h #{mysql_host} -P #{mysql_port} -e \"#{db_script}\""
end