summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2012-02-20 15:15:17 +0000
committerChristoph Helma <helma@in-silico.ch>2012-02-20 15:15:17 +0000
commitcfa65920c08dec306afbce85ba376d348b45b8f3 (patch)
treeadfdf23135efb7a040812e6a25ec54338002c83f
initial skeleton
-rw-r--r--.gitignore4
-rw-r--r--Gemfile4
-rw-r--r--Rakefile1
-rw-r--r--lib/environment.rb74
-rw-r--r--lib/opentox-server.rb7
-rw-r--r--lib/opentox-server/version.rb5
-rw-r--r--opentox-server.gemspec29
7 files changed, 124 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4040c6c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..2bdc706
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+# Specify your gem's dependencies in opentox-server.gemspec
+gemspec
+gem "opentox-client", :path => "~/opentox-client"
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..2995527
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
diff --git a/lib/environment.rb b/lib/environment.rb
new file mode 100644
index 0000000..300c431
--- /dev/null
+++ b/lib/environment.rb
@@ -0,0 +1,74 @@
+# set default environment
+
+ENV['RACK_ENV'] = 'production' unless ENV['RACK_ENV']
+
+# load/setup configuration
+basedir = File.join(ENV['HOME'], ".toxbank")
+config_dir = File.join(basedir, "config")
+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)
+ raise "could not load config, config file: "+config_file.to_s unless CONFIG
+else
+ FileUtils.mkdir_p TMP_DIR
+ FileUtils.mkdir_p LOG_DIR
+ FileUtils.mkdir_p config_dir
+ puts "Please edit #{config_file} and restart your application."
+ #exit
+end
+
+logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log"
+#LOGGER = OTLogger.new(logfile,'daily') # daily rotation
+LOGGER = OTLogger.new(logfile) # no rotation
+LOGGER.formatter = Logger::Formatter.new #this is neccessary to restore the formating in case active-record is loaded
+if CONFIG[:logger] and CONFIG[:logger] == "debug"
+ LOGGER.level = Logger::DEBUG
+else
+ LOGGER.level = Logger::WARN
+end
+
+# Regular expressions for parsing classification data
+TRUE_REGEXP = /^(true|active|1|1.0|tox|activating|carcinogen|mutagenic)$/i
+FALSE_REGEXP = /^(false|inactive|0|0.0|low tox|deactivating|non-carcinogen|non-mutagenic)$/i
+
+# OWL Namespaces
+=begin
+class OwlNamespace
+
+ attr_accessor :uri
+ def initialize(uri)
+ @uri = uri
+ end
+
+ def [](property)
+ @uri+property.to_s
+ end
+
+ def type # for RDF.type
+ "#{@uri}type"
+ end
+
+ def method_missing(property)
+ @uri+property.to_s
+ end
+
+end
+=end
+
+AA_SERVER = CONFIG[:authorization] ? (CONFIG[:authorization][:server] ? CONFIG[:authorization][:server] : nil) : nil
+CONFIG[:authorization][:authenticate_request] = [""] unless CONFIG[:authorization][:authenticate_request]
+CONFIG[:authorization][:authorize_request] = [""] unless CONFIG[:authorization][:authorize_request]
+CONFIG[:authorization][:free_request] = [""] unless CONFIG[:authorization][:free_request]
+
+#RDF = OwlNamespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
+#OWL = OwlNamespace.new 'http://www.w3.org/2002/07/owl#'
+#DC = OwlNamespace.new 'http://purl.org/dc/elements/1.1/'
+#OT = OwlNamespace.new 'http://www.opentox.org/api/1.1#'
+#OTA = OwlNamespace.new 'http://www.opentox.org/algorithmTypes.owl#'
+#XSD = OwlNamespace.new 'http://www.w3.org/2001/XMLSchema#'
+
+
diff --git a/lib/opentox-server.rb b/lib/opentox-server.rb
new file mode 100644
index 0000000..fa8a37f
--- /dev/null
+++ b/lib/opentox-server.rb
@@ -0,0 +1,7 @@
+require "opentox-client"
+require 'rack'
+require 'rack/contrib'
+require 'sinatra'
+require 'sinatra/url_for'
+require File.join(File.dirname(__FILE__),"environment.rb")
+
diff --git a/lib/opentox-server/version.rb b/lib/opentox-server/version.rb
new file mode 100644
index 0000000..a637142
--- /dev/null
+++ b/lib/opentox-server/version.rb
@@ -0,0 +1,5 @@
+module Opentox
+ module Server
+ VERSION = "0.0.1"
+ end
+end
diff --git a/opentox-server.gemspec b/opentox-server.gemspec
new file mode 100644
index 0000000..66d4852
--- /dev/null
+++ b/opentox-server.gemspec
@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "opentox-server/version"
+
+Gem::Specification.new do |s|
+ s.name = "opentox-server"
+ s.version = Opentox::Server::VERSION
+ s.authors = ["Christoph Helma"]
+ s.email = ["helma@in-silico.ch"]
+ s.homepage = ""
+ s.summary = %q{Ruby library for opentox services}
+ s.description = %q{Ruby library for opentox services}
+
+ s.rubyforge_project = "opentox-server"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ s.add_runtime_dependency "opentox-client"
+ s.add_runtime_dependency 'rack'
+ s.add_runtime_dependency 'rack-contrib'
+ s.add_runtime_dependency 'sinatra'
+ s.add_runtime_dependency 'emk-sinatra-url-for'
+ s.add_runtime_dependency 'spreadsheet'
+ s.add_runtime_dependency 'roo'
+end