diff options
Diffstat (limited to 'lib/environment.rb')
-rw-r--r-- | lib/environment.rb | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/lib/environment.rb b/lib/environment.rb index 6100928..a9d0797 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -1,21 +1,27 @@ +require 'logger' # set default environment ENV['RACK_ENV'] = 'test' unless ENV['RACK_ENV'] # load configuration basedir = File.join(ENV['HOME'], ".opentox") config_dir = File.join(basedir, "config") -@@tmp_dir = File.join(basedir, "tmp") config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml") +TMP_DIR = File.join(basedir, "tmp") +LOG_DIR = File.join(basedir, "log") + if File.exist?(config_file) @@config = YAML.load_file(config_file) else - FileUtils.mkdir_p config_dir - FileUtils.mkdir_p @@tmp_dir + FileUtils.mkdir_p TMP_DIR + FileUtils.mkdir_p LOG_DIR FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/config.yaml'), config_file) puts "Please edit #{config_file} and restart your application." exit end +logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log" +LOGGER = Logger.new(logfile,'daily') # daily rotation +LOGGER.level = Logger::DEBUG # RDF namespaces RDF = Redland::Namespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' @@ -23,19 +29,6 @@ OWL = Redland::Namespace.new 'http://www.w3.org/2002/07/owl#' DC = Redland::Namespace.new 'http://purl.org/dc/elements/1.1/' OT = Redland::Namespace.new 'http://www.opentox.org/api/1.1#' -# configure redis database -=begin -begin - case ENV['RACK_ENV'] - when 'production' - @@redis = Redis.new :db => 0 - when 'development' - @@redis = Redis.new :db => 1 - when 'test' - @@redis = Redis.new :db => 2 - @@redis.flush_db - end -rescue - puts "Redis database not running, please start it with 'rake redis:start'." -end -=end +# Regular expressions for parsing classification data +TRUE_REGEXP = /^(true|active|1)/ +FALSE_REGEXP = /^(false|inactive|0)/ |