summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-08-17 14:06:03 +0200
committermr <mr@mrautenberg.de>2011-08-17 14:06:03 +0200
commita368d3ad8015a905c0aee873c5c10c2fad4afbdb (patch)
tree3d1120f42237568f2059a19757e2d20fe7d7e761 /application.rb
parent7324d4503480fc0bfdf879475380ed197bcad213 (diff)
move data directory to folder data for A&A reasons
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/application.rb b/application.rb
index 7d3de38..96287c3 100644
--- a/application.rb
+++ b/application.rb
@@ -4,6 +4,8 @@ require 'opentox-ruby'
set :lock, true
+@@datadir = "data"
+
class PredictionCache < Ohm::Model
attribute :compound_uri
attribute :model_uri
@@ -22,7 +24,7 @@ before do
@id = @id.to_s.sub(/\//,'').to_i
@uri = uri @id
- @yaml_file = "public/#{@id}.yaml"
+ @yaml_file = "#{@@datadir}/#{@id}.yaml"
raise OpenTox::NotFoundError.new "Model #{@id} not found." unless File.exists? @yaml_file
end
@@ -35,7 +37,7 @@ require 'lazar.rb'
helpers do
def next_id
- id = Dir["./public/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.last
+ id = Dir["./#{@@datadir}/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.last
id = 0 if id.nil?
id + 1
end
@@ -59,7 +61,7 @@ end
get '/?' do # get index of models
response['Content-Type'] = 'text/uri-list'
- Dir["./public/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.collect{|n| uri n}.join("\n") + "\n"
+ Dir["./#{@@datadir}/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.collect{|n| uri n}.join("\n") + "\n"
end
delete '/:id/?' do
@@ -84,7 +86,7 @@ end
delete '/?' do
# TODO delete datasets
- FileUtils.rm Dir["public/*.yaml"]
+ FileUtils.rm Dir["#{@@datadir}/*.yaml"]
PredictionCache.all.each {|cache| cache.delete }
response['Content-Type'] = 'text/plain'
"All models and cached predictions deleted."