diff options
-rwxr-xr-x[-rw-r--r--] | application.rb | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/application.rb b/application.rb index adff452..248a2d6 100644..100755 --- a/application.rb +++ b/application.rb @@ -17,24 +17,14 @@ class Dataset data = YAML.load(yaml) owl = OpenTox::Owl.create 'Dataset', uri owl.set "title", data.title - #owl.set "source", data.source -=begin - ['title', 'source'].each do |method| - #eval "owl.#{method} = data.#{method}" - owl.set(method, "data.#{method}" - end -=end if data.data data.data.each do |compound,features| owl.add_data_entries compound,features end - end + end owl.rdf end - #def from_owl - #end - end DataMapper.auto_upgrade! @@ -43,7 +33,7 @@ DataMapper.auto_upgrade! get '/?' do response['Content-Type'] = 'text/uri-list' - Dataset.all.collect{|d| d.uri}.join("\n") + "\n" + Dataset.all(params).collect{|d| d.uri}.join("\n") + "\n" end get '/:id' do @@ -53,7 +43,7 @@ get '/:id' do case params[:id] when /.yaml$/ params[:id].sub!(/.yaml$/,'') - accept = 'application/x-yaml' + accept = 'text/x-yaml' when /.rdf$/ params[:id].sub!(/.rdf$/,'') accept = 'application/rdf+xml' @@ -63,6 +53,7 @@ get '/:id' do end begin dataset = Dataset.get(params[:id]) + halt 404, "Dataset #{params[:id]} not found." unless dataset rescue => e raise e.message + e.backtrace halt 404, "Dataset #{params[:id]} not found." @@ -77,7 +68,7 @@ get '/:id' do end dataset.owl when /yaml/ - response['Content-Type'] = 'application/x-yaml' + response['Content-Type'] = 'text/x-yaml' dataset.yaml when /ms-excel/ require 'spreadsheet' |