Sha256: 52741b8c620b6f2486cfdcb60944e7570c3fab51d731a9ad14a6d923511b3c4b
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module WordPressTools class Database < Thor include CLIHelper include SharedOptions attr_reader :db_name desc "create [DB_NAME]", "create MySQL database for WordPress" add_method_options(shared_options) def create(db_name = "wordpress") @db_name = db_name info("Creating database '#{db_name}'...") test_login create_database success("Database #{db_name} created") end no_tasks do def create_database run_command(mysql_create_command) || error("Cannot create database '#{db_name}'. Already exists?") end def test_login run_command("#{mysql_command} --execute='QUIT'") || error("Cannot login to MySQL. Wrong credentials?") end def mysql_create_command [ mysql_command, "--execute='CREATE DATABASE", db_name, "DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'" ].join(' ') end def mysql_command "mysql --user='#{db_user}' --password='#{db_password}'" end def db_user options[:db_user] end def db_password options[:db_password] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wordpress_tools-1.4.1 | lib/wordpress_tools/database.rb |