opentox-server 0.0.2pre → 1.0.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/ChangeLog +2 -0
- data/Gemfile +1 -1
- data/VERSION +1 -0
- data/lib/4store.rb +121 -0
- data/lib/authorization-helper.rb +6 -5
- data/lib/opentox-server.rb +2 -5
- data/lib/opentox.rb +71 -26
- data/opentox-server.gemspec +1 -5
- metadata +39 -29
- data/lib/environment.rb +0 -41
data/.gitignore
CHANGED
data/ChangeLog
ADDED
data/Gemfile
CHANGED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0pre1
|
data/lib/4store.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
module OpenTox
|
2
|
+
module Backend
|
3
|
+
class FourStore
|
4
|
+
|
5
|
+
@@accept_formats = [ "application/rdf+xml", "text/turtle", "text/plain", "text/uri-list", "text/html", 'application/sparql-results+xml' ]
|
6
|
+
@@content_type_formats = [ "application/rdf+xml", "text/turtle", "text/plain" ]
|
7
|
+
|
8
|
+
def self.list service_uri, mime_type
|
9
|
+
mime_type = "text/html" if mime_type.match(%r{\*/\*})
|
10
|
+
bad_request_error "'#{mime_type}' is not a supported mime type. Please specify one of #{@@accept_formats.join(", ")} in the Accept Header." unless @@accept_formats.include? mime_type
|
11
|
+
if mime_type =~ /uri-list/
|
12
|
+
sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {?s <#{RDF.type}> <#{klass}>; ?p ?o. } }"
|
13
|
+
else
|
14
|
+
sparql = "CONSTRUCT {?s ?p ?o.} WHERE {?s <#{RDF.type}> <#{klass}>; ?p ?o. }"
|
15
|
+
end
|
16
|
+
query sparql, mime_type
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.get uri, mime_type
|
20
|
+
mime_type = "text/html" if mime_type.match(%r{\*/\*})
|
21
|
+
bad_request_error "'#{mime_type}' is not a supported mime type. Please specify one of #{@@accept_formats.join(", ")} in the Accept Header." unless @@accept_formats.include? mime_type
|
22
|
+
sparql = "CONSTRUCT {?s ?p ?o.} FROM <#{uri}> WHERE { ?s ?p ?o. }"
|
23
|
+
rdf = query sparql, mime_type
|
24
|
+
resource_not_found_error "#{uri} not found." if rdf.empty?
|
25
|
+
rdf
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.post uri, rdf, mime_type
|
29
|
+
bad_request_error "'#{mime_type}' is not a supported content type. Please use one of #{@@content_type_formats.join(", ")}." unless @@content_type_formats.include? mime_type or mime_type == "multipart/form-data"
|
30
|
+
bad_request_error "Reqest body empty." unless rdf
|
31
|
+
mime_type = "application/x-turtle" if mime_type == "text/plain" # ntriples is turtle in 4store
|
32
|
+
begin
|
33
|
+
RestClient.post File.join(four_store_uri,"data")+"/", :data => rdf, :graph => uri, "mime-type" => mime_type
|
34
|
+
rescue
|
35
|
+
bad_request_error $!.message, File.join(four_store_uri,"data")+"/"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.put uri, rdf, mime_type
|
40
|
+
bad_request_error "'#{mime_type}' is not a supported content type. Please use one of #{@@content_type_formats.join(", ")}." unless @@content_type_formats.include? mime_type
|
41
|
+
bad_request_error "Reqest body empty." unless rdf
|
42
|
+
mime_type = "application/x-turtle" if mime_type == "text/plain"
|
43
|
+
#begin
|
44
|
+
RestClientWrapper.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type
|
45
|
+
#rescue
|
46
|
+
#bad_request_error $!.message, File.join(four_store_uri,"data",uri)
|
47
|
+
#end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.delete uri
|
51
|
+
RestClientWrapper.delete data_uri(uri)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.update sparql
|
55
|
+
RestClient.post(update_uri, :update => sparql )
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.query sparql, mime_type
|
59
|
+
if sparql =~ /SELECT/i
|
60
|
+
# return list unless mime_type
|
61
|
+
case mime_type
|
62
|
+
when 'application/sparql-results+xml'
|
63
|
+
RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => mime_type).body
|
64
|
+
when "text/uri-list"
|
65
|
+
RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => "text/plain").body.gsub(/"|<|>/,'').split("\n").drop(1).join("\n")
|
66
|
+
else
|
67
|
+
bad_request_error "#{mime_type} is not a supported mime type for SELECT statements."
|
68
|
+
end
|
69
|
+
elsif sparql =~ /CONSTRUCT/i
|
70
|
+
case mime_type
|
71
|
+
when "text/plain", "application/rdf+xml"
|
72
|
+
RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => mime_type).body
|
73
|
+
when /html|turtle/
|
74
|
+
# TODO: fix and improve
|
75
|
+
nt = RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => "text/plain").body # 4store returns ntriples for turtle
|
76
|
+
|
77
|
+
rdf = RDF::Graph.new
|
78
|
+
RDF::Reader.for(:ntriples).new(nt) do |reader|
|
79
|
+
reader.each_statement { |statement| rdf << statement }
|
80
|
+
end
|
81
|
+
prefixes = {:rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}
|
82
|
+
['OT', 'DC', 'XSD', 'OLO'].each{|p| prefixes[p.downcase.to_sym] = eval("RDF::#{p}.to_s") }
|
83
|
+
# TODO: fails for large datasets?? multi_cell_call
|
84
|
+
turtle = RDF::N3::Writer.for(:turtle).buffer(:prefixes => prefixes) do |writer|
|
85
|
+
rdf.each{|statement| writer << statement}
|
86
|
+
end
|
87
|
+
turtle = "<html><body>" + turtle.gsub(%r{<(.*)>},'<<a href="\1">\1</a>>').gsub(/\n/,'<br/>') + "</body></html>" if mime_type =~ /html/ and !turtle.empty?
|
88
|
+
turtle
|
89
|
+
end
|
90
|
+
else
|
91
|
+
# TODO: check if this prevents SPARQL injections
|
92
|
+
bad_request_error "Only SELECT and CONSTRUCT are accepted SPARQL statements."
|
93
|
+
end
|
94
|
+
rescue
|
95
|
+
bad_request_error $!.message, sparql_uri
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.klass
|
99
|
+
RDF::OT[SERVICE.capitalize]
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.four_store_uri
|
103
|
+
# credentials are removed from uri in error.rb
|
104
|
+
$four_store[:uri].sub(%r{//},"//#{$four_store[:user]}:#{$four_store[:password]}@")
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.sparql_uri
|
108
|
+
File.join(four_store_uri, "sparql") + '/'
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.update_uri
|
112
|
+
File.join(four_store_uri, "update") + '/'
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.data_uri uri
|
116
|
+
File.join(four_store_uri, "data","?graph=#{uri}")
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/lib/authorization-helper.rb
CHANGED
@@ -56,10 +56,10 @@ module OpenTox
|
|
56
56
|
elsif !env["session"] && subjectid
|
57
57
|
unless authorized?(subjectid)
|
58
58
|
$logger.debug "URI not authorized: clean: " + clean_uri("#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']}").sub("http://","https://").to_s + " full: #{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']} with request: #{request.env['REQUEST_METHOD']}"
|
59
|
-
|
59
|
+
unauthorized_error "Not authorized #{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']} with request: #{request.env['REQUEST_METHOD']}"
|
60
60
|
end
|
61
61
|
else
|
62
|
-
|
62
|
+
unauthorized_error "Not authorized" unless authorized?(subjectid)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -67,7 +67,7 @@ module OpenTox
|
|
67
67
|
# @param [String]subjectid
|
68
68
|
def authorized?(subjectid)
|
69
69
|
request_method = request.env['REQUEST_METHOD']
|
70
|
-
uri = clean_uri("#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']}")
|
70
|
+
uri = clean_uri("#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']}") #.sub("http://","https://")
|
71
71
|
request_method = "GET" if request_method == "POST" && uri =~ /\/model\/\d+\/?$/
|
72
72
|
return OpenTox::Authorization.authorized?(uri, request_method, subjectid)
|
73
73
|
end
|
@@ -78,7 +78,8 @@ module OpenTox
|
|
78
78
|
uri = uri.sub(" ", "%20") #dirty hacks => to fix
|
79
79
|
uri = uri[0,uri.index("InChI=")] if uri.index("InChI=")
|
80
80
|
out = URI.parse(uri)
|
81
|
-
out.path = out.path[0, out.path.length - (out.path.reverse.rindex(/\/{1}\d+\/{1}/))] if out.path.index(/\/{1}\d+\/{1}/) #cuts after /id/ for a&a
|
81
|
+
out.path = out.path[0, out.path.length - (out.path.reverse.rindex(/\/{1}\d+\/{1}/))] if out.path.index(/\/{1}\d+\/{1}/) #cuts after numeric /id/ for a&a
|
82
|
+
out.path.sub! /(\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}).*/, '\1' # cut after uuid
|
82
83
|
out.path = out.path.split('.').first #cut extension
|
83
84
|
port = (out.scheme=="http" && out.port==80)||(out.scheme=="https" && out.port==443) ? "" : ":#{out.port.to_s}"
|
84
85
|
"#{out.scheme}://#{out.host}#{port}#{out.path.chomp("/")}" #"
|
@@ -128,4 +129,4 @@ module OpenTox
|
|
128
129
|
end
|
129
130
|
end
|
130
131
|
end
|
131
|
-
end
|
132
|
+
end
|
data/lib/opentox-server.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'opentox-client'
|
2
2
|
require 'rack'
|
3
3
|
require 'rack/contrib'
|
4
4
|
require 'sinatra'
|
5
|
-
require
|
6
|
-
require 'roo'
|
7
|
-
require File.join(File.dirname(__FILE__),"environment.rb")
|
5
|
+
require File.join(File.dirname(__FILE__),"4store.rb")
|
8
6
|
require File.join(File.dirname(__FILE__),"opentox.rb")
|
9
|
-
require File.join(File.dirname(__FILE__),"file-store.rb")
|
10
7
|
require File.join(File.dirname(__FILE__),"authorization-helper.rb")
|
data/lib/opentox.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require "sinatra/reloader"
|
2
|
+
require "sinatra/reloader"
|
3
|
+
ENV["RACK_ENV"] ||= "production"
|
4
|
+
require File.join(ENV["HOME"],".opentox","config","#{SERVICE}.rb")
|
5
|
+
|
6
|
+
|
7
|
+
logfile = File.join(ENV['HOME'], ".opentox","log","#{ENV["RACK_ENV"]}.log")
|
8
|
+
$logger = OTLogger.new(logfile)
|
3
9
|
|
4
10
|
module OpenTox
|
5
11
|
|
6
12
|
# Base class for OpenTox services
|
7
13
|
class Service < Sinatra::Base
|
14
|
+
include Backend
|
8
15
|
|
9
|
-
helpers Sinatra::UrlForHelper
|
10
16
|
# use OpenTox error handling
|
11
17
|
set :raise_errors, false
|
12
18
|
set :show_exceptions, false
|
@@ -14,38 +20,41 @@ module OpenTox
|
|
14
20
|
|
15
21
|
configure :development do
|
16
22
|
register Sinatra::Reloader
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def uri
|
21
|
-
params[:id] ? url_for("/#{params[:id]}", :full) : "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}"
|
22
|
-
end
|
23
|
+
also_reload "./*.rb"
|
24
|
+
also_reload "../opentox-client/lib/*.rb"
|
25
|
+
also_reload File.join(ENV["HOME"],".opentox","config","#{SERVICE}.rb")
|
23
26
|
end
|
24
27
|
|
25
28
|
before do
|
29
|
+
request.content_type ? response['Content-Type'] = request.content_type : response['Content-Type'] = request.env['HTTP_ACCEPT']
|
30
|
+
parse_input if request.request_method =~ /POST|PUT/
|
26
31
|
@accept = request.env['HTTP_ACCEPT']
|
27
|
-
response['Content-Type'] = @accept
|
28
|
-
# TODO: A+A
|
29
32
|
end
|
30
33
|
|
34
|
+
before "/#{SERVICE}/:id" do
|
35
|
+
@uri = uri("/#{SERVICE}/#{params[:id]}")
|
36
|
+
end
|
37
|
+
|
38
|
+
helpers do
|
39
|
+
def parse_input
|
40
|
+
case request.content_type
|
41
|
+
when /multipart/
|
42
|
+
@body = params[:file][:tempfile].read
|
43
|
+
# sdf files are incorrectly detected
|
44
|
+
@content_type = params[:file][:type]
|
45
|
+
@content_type = "chemical/x-mdl-sdfile" if File.extname(params[:file][:filename]) == ".sdf"
|
46
|
+
else
|
47
|
+
@body = request.body.read
|
48
|
+
@content_type = request.content_type
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attention: Error within tasks are catched by Task.create
|
31
54
|
error do
|
32
|
-
# TODO: convert to OpenTox::Error and set URI
|
33
55
|
error = request.env['sinatra.error']
|
34
|
-
#error.uri = uri
|
35
56
|
if error.respond_to? :report
|
36
|
-
|
37
|
-
case @accept
|
38
|
-
when 'application/rdf+xml'
|
39
|
-
body = error.report.to_rdfxml
|
40
|
-
when /html/
|
41
|
-
# TODO
|
42
|
-
# body = error.report.to_html
|
43
|
-
body = error.report.to_turtle
|
44
|
-
when "text/n3"
|
45
|
-
body = error.report.to_ntriples
|
46
|
-
else
|
47
|
-
body = error.report.to_turtle
|
48
|
-
end
|
57
|
+
body = error.report.to_turtle
|
49
58
|
else
|
50
59
|
response['Content-Type'] = "text/plain"
|
51
60
|
body = error.message
|
@@ -54,6 +63,42 @@ module OpenTox
|
|
54
63
|
error.respond_to?(:http_code) ? code = error.http_code : code = 500
|
55
64
|
halt code, body
|
56
65
|
end
|
66
|
+
|
67
|
+
# Default methods, may be overwritten by derived services
|
68
|
+
# see http://jcalcote.wordpress.com/2008/10/16/put-or-post-the-rest-of-the-story/
|
69
|
+
|
70
|
+
# Get a list of objects at the server
|
71
|
+
get "/#{SERVICE}/?" do
|
72
|
+
FourStore.list uri("/#{SERVICE}"), @accept
|
73
|
+
end
|
74
|
+
|
75
|
+
# Create a new resource
|
76
|
+
post "/#{SERVICE}/?" do
|
77
|
+
@uri = uri("/#{SERVICE}/#{SecureRandom.uuid}")
|
78
|
+
FourStore.put(@uri, @body, @content_type)
|
79
|
+
response['Content-Type'] = "text/uri-list"
|
80
|
+
@uri
|
81
|
+
end
|
82
|
+
|
83
|
+
# Get resource representation
|
84
|
+
get "/#{SERVICE}/:id/?" do
|
85
|
+
FourStore.get(@uri, @accept)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Modify (i.e. add rdf statments to) a resource
|
89
|
+
post "/#{SERVICE}/:id/?" do
|
90
|
+
FourStore.post @uri, @body, @content_type
|
91
|
+
end
|
92
|
+
|
93
|
+
# Create or updata a resource
|
94
|
+
put "/#{SERVICE}/:id/?" do
|
95
|
+
FourStore.put @uri, @body, @content_type
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete a resource
|
99
|
+
delete "/#{SERVICE}/:id/?" do
|
100
|
+
FourStore.delete @uri
|
101
|
+
end
|
102
|
+
|
57
103
|
end
|
58
104
|
end
|
59
|
-
|
data/opentox-server.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "opentox-server"
|
6
|
-
s.version =
|
6
|
+
s.version = File.read("./VERSION")
|
7
7
|
s.authors = ["Christoph Helma, Martin Guetlein, Andreas Maunz, Micha Rautenberg, David Vorgrimmler"]
|
8
8
|
s.email = ["helma@in-silico.ch"]
|
9
9
|
s.homepage = "http://github.com/opentox/opentox-server"
|
@@ -14,8 +14,6 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.rubyforge_project = "opentox-server"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
17
|
s.require_paths = ["lib"]
|
20
18
|
|
21
19
|
# specify any dependencies here; for example:
|
@@ -24,7 +22,5 @@ Gem::Specification.new do |s|
|
|
24
22
|
s.add_runtime_dependency 'rack-contrib'
|
25
23
|
s.add_runtime_dependency 'sinatra'
|
26
24
|
s.add_runtime_dependency 'sinatra-contrib'
|
27
|
-
s.add_runtime_dependency 'emk-sinatra-url-for'
|
28
|
-
s.add_runtime_dependency 'roo'
|
29
25
|
s.add_runtime_dependency 'unicorn'
|
30
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentox-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0pre1
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opentox-client
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rack
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rack-contrib
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: sinatra
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,21 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: sinatra-contrib
|
60
|
-
requirement: &84853820 !ruby/object:Gem::Requirement
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
73
|
none: false
|
62
74
|
requirements:
|
63
75
|
- - ! '>='
|
64
76
|
- !ruby/object:Gem::Version
|
65
77
|
version: '0'
|
66
|
-
type: :runtime
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *84853820
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement:
|
79
|
+
name: sinatra-contrib
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
72
81
|
none: false
|
73
82
|
requirements:
|
74
83
|
- - ! '>='
|
@@ -76,21 +85,15 @@ dependencies:
|
|
76
85
|
version: '0'
|
77
86
|
type: :runtime
|
78
87
|
prerelease: false
|
79
|
-
version_requirements:
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: roo
|
82
|
-
requirement: &84851990 !ruby/object:Gem::Requirement
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
89
|
none: false
|
84
90
|
requirements:
|
85
91
|
- - ! '>='
|
86
92
|
- !ruby/object:Gem::Version
|
87
93
|
version: '0'
|
88
|
-
type: :runtime
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *84851990
|
91
94
|
- !ruby/object:Gem::Dependency
|
92
95
|
name: unicorn
|
93
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
94
97
|
none: false
|
95
98
|
requirements:
|
96
99
|
- - ! '>='
|
@@ -98,7 +101,12 @@ dependencies:
|
|
98
101
|
version: '0'
|
99
102
|
type: :runtime
|
100
103
|
prerelease: false
|
101
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
102
110
|
description: Ruby library for opentox services
|
103
111
|
email:
|
104
112
|
- helma@in-silico.ch
|
@@ -107,12 +115,14 @@ extensions: []
|
|
107
115
|
extra_rdoc_files: []
|
108
116
|
files:
|
109
117
|
- .gitignore
|
118
|
+
- ChangeLog
|
110
119
|
- Gemfile
|
111
120
|
- LICENSE
|
112
121
|
- README
|
113
122
|
- Rakefile
|
123
|
+
- VERSION
|
124
|
+
- lib/4store.rb
|
114
125
|
- lib/authorization-helper.rb
|
115
|
-
- lib/environment.rb
|
116
126
|
- lib/file-store.rb
|
117
127
|
- lib/opentox-server.rb
|
118
128
|
- lib/opentox.rb
|
@@ -138,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
148
|
version: 1.3.1
|
139
149
|
requirements: []
|
140
150
|
rubyforge_project: opentox-server
|
141
|
-
rubygems_version: 1.8.
|
151
|
+
rubygems_version: 1.8.18
|
142
152
|
signing_key:
|
143
153
|
specification_version: 3
|
144
154
|
summary: Ruby library for opentox services
|
data/lib/environment.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# set default environment
|
2
|
-
ENV['RACK_ENV'] = 'production' unless ENV['RACK_ENV']
|
3
|
-
|
4
|
-
# load/setup configuration
|
5
|
-
basedir = File.join(ENV['HOME'], ".opentox")
|
6
|
-
config_dir = File.join(basedir, "config")
|
7
|
-
config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml")
|
8
|
-
|
9
|
-
TMP_DIR = File.join(basedir, "tmp")
|
10
|
-
LOG_DIR = File.join(basedir, "log")
|
11
|
-
|
12
|
-
=begin
|
13
|
-
if File.exist?(config_file)
|
14
|
-
CONFIG = YAML.load_file(config_file)
|
15
|
-
not_found_error "Could not load configuration from \"#{config_file.to_s}\"" unless CONFIG
|
16
|
-
else
|
17
|
-
FileUtils.mkdir_p TMP_DIR
|
18
|
-
FileUtils.mkdir_p LOG_DIR
|
19
|
-
FileUtils.mkdir_p config_dir
|
20
|
-
puts "Please edit #{config_file} and restart your application."
|
21
|
-
exit
|
22
|
-
end
|
23
|
-
=end
|
24
|
-
|
25
|
-
logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log"
|
26
|
-
$logger = OTLogger.new(logfile)
|
27
|
-
|
28
|
-
=begin
|
29
|
-
if CONFIG[:logger] and CONFIG[:logger] == "debug"
|
30
|
-
$logger.level = Logger::DEBUG
|
31
|
-
else
|
32
|
-
$logger.level = Logger::WARN
|
33
|
-
end
|
34
|
-
|
35
|
-
# TODO: move to opentox-client???
|
36
|
-
AA_SERVER = CONFIG[:authorization] ? (CONFIG[:authorization][:server] ? CONFIG[:authorization][:server] : nil) : nil
|
37
|
-
CONFIG[:authorization][:authenticate_request] = [""] unless CONFIG[:authorization][:authenticate_request]
|
38
|
-
CONFIG[:authorization][:authorize_request] = [""] unless CONFIG[:authorization][:authorize_request]
|
39
|
-
CONFIG[:authorization][:free_request] = [""] unless CONFIG[:authorization][:free_request]
|
40
|
-
=end
|
41
|
-
|