diff options
author | Christoph Helma <helma@in-silico.de> | 2009-11-27 18:17:21 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2009-11-27 18:17:21 +0100 |
commit | 40b4b943bbaeef4513052f729c32bba7c950e283 (patch) | |
tree | 3048f8ab3fa62bd9601dc49360e00b0bd95ebbea | |
parent | 1034d4f25cdffab093b1e9d479785fb0183867dc (diff) |
deletion of all datasets enabled
-rw-r--r-- | application.rb | 20 | ||||
-rw-r--r-- | config.ru | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/application.rb b/application.rb index f360432..10b95cf 100644 --- a/application.rb +++ b/application.rb @@ -14,6 +14,19 @@ get '/:id/?' do send_file File.join("datasets",params[:id] + ".rdf") end +get '/:id/features/?' do + + storage = Redland::MemoryStore.new + parser = Redland::Parser.new + data = Redland::Model.new storage + rdf = File.read File.join(File.dirname(__FILE__),"datasets","#{params[:id]}.rdf") + parser.parse_string_into_model(data,rdf,Redland::Uri.new('/')) + + features = [] + data.triples { |s,p,o| features << p.uri.to_s } + features.uniq.join("\n") +end + post '/?' do case request.content_type when"application/rdf+xml" @@ -54,3 +67,10 @@ delete '/:id/?' do "Dataset #{params[:id]} does not exist." end end + +delete '/?' do + Dir["datasets/*rdf"].each do |f| + File.delete f + end + "All datasets deleted." +end @@ -7,7 +7,7 @@ require 'rack/contrib' FileUtils.mkdir_p 'log' unless File.exists?('log') FileUtils.mkdir_p 'datasets' unless File.exists?('datasets') log = File.new("log/#{ENV["RACK_ENV"]}.log", "a") -$stdout.reopen(log) +#$stdout.reopen(log) $stderr.reopen(log) if ENV['RACK_ENV'] == 'production' |