diff options
author | Martin Gütlein <martin.guetlein@gmail.com> | 2010-02-26 09:54:04 +0100 |
---|---|---|
committer | Martin Gütlein <martin.guetlein@gmail.com> | 2010-02-26 09:54:04 +0100 |
commit | 420efdf93cc335c8adbdba38a71fa36b797188b0 (patch) | |
tree | f6bf677c065003a26a3380af166997287ed85c47 /lib/environment.rb | |
parent | 1a2116574c356241a55fb0bb7d922a042ffd4465 (diff) | |
parent | 7b59d1f07bf8cf0e23f3070f97f940af3bfad843 (diff) |
Merge remote branch 'helma/test' into test
Diffstat (limited to 'lib/environment.rb')
-rw-r--r-- | lib/environment.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/environment.rb b/lib/environment.rb index c4de0b5..27da072 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -6,6 +6,7 @@ ENV['RACK_ENV'] = 'test' unless ENV['RACK_ENV'] basedir = File.join(ENV['HOME'], ".opentox") config_dir = File.join(basedir, "config") config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml") +user_file = File.join(config_dir, "users.yaml") TMP_DIR = File.join(basedir, "tmp") LOG_DIR = File.join(basedir, "log") @@ -15,6 +16,7 @@ if File.exist?(config_file) else FileUtils.mkdir_p TMP_DIR FileUtils.mkdir_p LOG_DIR + FileUtils.mkdir_p config_dir FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/config.yaml'), config_file) puts "Please edit #{config_file} and restart your application." exit @@ -100,6 +102,21 @@ LOGGER = MyLogger.new(logfile,'daily') # daily rotation LOGGER.level = Logger::DEBUG +if File.exist?(user_file) + @@users = YAML.load_file(user_file) +else + FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/users.yaml'), user_file) + puts "Please edit #{user_file} and restart your application." + exit +end + +begin + 0 < @@users[:users].keys.length +rescue + puts "Please edit #{user_file} and restart your application. Create at least one user with password." + exit +end + # RDF namespaces RDF = Redland::Namespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' OWL = Redland::Namespace.new 'http://www.w3.org/2002/07/owl#' |