parse_caller.rb revision 5d6db2efe44fab2f3616d0876191ce52e0600984
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Grabermodule Hets
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber class ParseCaller < Caller
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber # Server-Instances should be started with the following
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber # arguments: `hets +RTS -K1G -RTS -a none`
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber MODE_ARGUMENTS = {
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber fast_run: %w(just-structured),
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber default: %w(full-signatures full-theories)
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber }
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber CMD = 'dg'
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber METHOD = :get
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber attr_accessor :url_catalog
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber def initialize(hets_instance, url_catalog = [])
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber self.url_catalog = url_catalog
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber msg = "<#{hets_instance}> not up."
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber raise Hets::InactiveInstanceError, msg unless hets_instance.up?
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber super(hets_instance)
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber end
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber
def call(iri, with_mode: :default)
escaped_iri = Rack::Utils.escape_path(iri)
arguments = [escaped_iri, *MODE_ARGUMENTS[with_mode]]
api_uri = build_api_uri(CMD, arguments, build_query_string)
perform(api_uri, METHOD)
end
def build_query_string
query_hash = {}
query_hash[:"url-catalog"] = url_catalog.join(',') if url_catalog.present?
query_hash
end
end
end