From 5bb6c62b97ef7050b51ddd4f78f729becd1c0871 Mon Sep 17 00:00:00 2001 From: Silverwizard Date: Tue, 13 Jan 2015 11:18:24 -0500 Subject: [PATCH] Clean that up a little - make it readable, use exception, and all that deliciousness --- config.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config.rb b/config.rb index 2e06f1f..aefa1c2 100755 --- a/config.rb +++ b/config.rb @@ -1,6 +1,6 @@ #!/usr/local/bin/ruby config = File.new("db.rb", "w") -config.print("require mysql\n") +config.print("require 'mysql'\n") print "hostname: " hostname = gets print "username: " @@ -9,4 +9,5 @@ print "password: " password = gets print "dbname: " dbname = gets -config.print("print 'Could not connect to DB' unless $my = Mysql.connect('" + hostname.strip + "', '" + username.strip + "', '" + password.strip + "', '" + dbname.strip + "')\n") +config.print("begin\nraise 'DB Error' unless $my = Mysql.connect('" + hostname.strip + "', '" + username.strip + "', '" + password.strip + "', '" + dbname.strip + "')\n") +config.print("rescue\nprint 'Please double check db settings or contact the administrator'\nend")