parse_caller.rb revision 6cf3ba1dcf972672069f0826427619587d32d9e6
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainenmodule Hets
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen class ParseCaller < Caller
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen # Server-Instances should be started with the following
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen # arguments: `hets +RTS -K1G -RTS -a none`
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen MODE_ARGUMENTS = {
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen fast_run: %w(just-structured),
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen default: %w(full-signatures full-theories)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen CMD = 'dg'
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen METHOD = :get
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen attr_accessor :url_catalog
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
ab1e5b156d1b5480d36ed6e8e06197339d803038Timo Sirainen def initialize(hets_instance, url_catalog=[])
ab1e5b156d1b5480d36ed6e8e06197339d803038Timo Sirainen self.url_catalog = url_catalog
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen super(hets_instance)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
e8fd7988ec183fb6c104aed19a61f1a096c51d34Timo Sirainen def call(iri, with_mode: :default)
e8fd7988ec183fb6c104aed19a61f1a096c51d34Timo Sirainen escaped_iri = Rack::Utils.escape_path(iri)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen arguments = [escaped_iri, *MODE_ARGUMENTS[with_mode]]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen api_uri = build_api_uri(CMD, arguments, build_query_string)
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainen perform(api_uri, METHOD)
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainen end
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainen
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainen def build_query_string
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainen query_hash = {}
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainen query_hash[:"url-catalog"] = url_catalog.join(',') if url_catalog.present?
d35fee8d1e5e31614dba5e64d45ed23c7d6bfa53Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainen end
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainenend
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainen