Clean that up a little - make it readable, use exception, and all that deliciousness

master
Silverwizard 10 years ago
parent ca14d44dd1
commit 5bb6c62b97
  1. 5
      config.rb

@ -1,6 +1,6 @@
#!/usr/local/bin/ruby #!/usr/local/bin/ruby
config = File.new("db.rb", "w") config = File.new("db.rb", "w")
config.print("require mysql\n") config.print("require 'mysql'\n")
print "hostname: " print "hostname: "
hostname = gets hostname = gets
print "username: " print "username: "
@ -9,4 +9,5 @@ print "password: "
password = gets password = gets
print "dbname: " print "dbname: "
dbname = gets 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")

Loading…
Cancel
Save