diff options
author | Christoph Helma <helma@in-silico.de> | 2009-12-19 13:51:03 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2009-12-19 13:51:03 +0100 |
commit | fbdb435a1375513c9bfee4f208d7a175a524c8fe (patch) | |
tree | d38408da6af0e7532025f19e90523111fefa5b9d /application.rb | |
parent | 777dc162d4058764a652f66bb61e141b6b5b1345 (diff) |
.owl as dataset extension
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/application.rb b/application.rb index 6032bfa..176d965 100644 --- a/application.rb +++ b/application.rb @@ -5,12 +5,12 @@ require 'opentox-ruby-api-wrapper' ## REST API get '/?' do - Dir["datasets/*"].collect{|dataset| url_for("/", :full) + File.basename(dataset,".rdf")}.sort.join("\n") + Dir["datasets/*"].collect{|dataset| url_for("/", :full) + File.basename(dataset,".owl")}.sort.join("\n") end get '/:id/?' do uri = url_for("/#{params[:id]}", :full) - path = File.join("datasets",params[:id] + ".rdf") + path = File.join("datasets",params[:id] + ".owl") halt 404, "Dataset #{uri} not found." unless File.exists? path accept = request.env['HTTP_ACCEPT'] accept = 'application/rdf+xml' if accept == '*/*' or accept == '' or accept.nil? @@ -33,7 +33,7 @@ get '/:id/features/?' do end post '/?' do - id = Dir["datasets/*"].collect{|dataset| File.basename(dataset,".rdf").to_i}.sort.last + id = Dir["datasets/*"].collect{|dataset| File.basename(dataset,".owl").to_i}.sort.last id = id.nil? ? 1 : id + 1 uri = url_for("/#{id}", :full) content_type = request.content_type @@ -41,7 +41,7 @@ post '/?' do case request.content_type =begin when /yaml/ - File.open(File.join("datasets",id.to_s + ".rdf"),"w+") { |f| f.write model.to_string } + File.open(File.join("datasets",id.to_s + ".owl"),"w+") { |f| f.write model.to_string } url_for("/#{id}", :full) =end when "application/rdf+xml" @@ -52,7 +52,7 @@ post '/?' do else halt 404, "MIME type \"#{request.content_type}\" not supported." end - File.open(File.join("datasets",id.to_s + ".rdf"),"w+") { |f| f.write dataset.rdf } + File.open(File.join("datasets",id.to_s + ".owl"),"w+") { |f| f.write dataset.rdf } uri end @@ -81,7 +81,7 @@ end =end delete '/:id/?' do - path = File.join("datasets",params[:id] + ".rdf") + path = File.join("datasets",params[:id] + ".owl") if File.exists? path File.delete path "Dataset #{params[:id]} deleted." |