Sha256: 641df4be1cc9912d0bfba007a835d0239f78097e3d0c607ee3a507d2700d466b
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'terrapin' require 'json' module Fairdom module OpenbisApi class JavaExecution attr_reader :query_object def initialize(query_object) @query_object = query_object end def execute(options) command = execute_command(options) output = Terrapin::CommandLine.new(command).run JSON.parse(output.strip) rescue Terrapin::ExitStatusError => exception raise OpenbisQueryException, exception.message end private def execute_command(options) "#{java_root_command} -#{query_object.command_option_key} {#{command_from_options(options)}}" end def command_from_options(options) options.collect do |key, value| "%#{key}%:%#{value.tr(' ', '+')}%" end.join("\,") end def java_root_command "java -jar #{jar_path} #{query_object.root_command_options}" end def jar_path File.join(File.dirname(__dir__), "../../jars/#{jar_file}") end def jar_file "openseek-api-#{Fairdom::OpenbisApi::JAR_VERSION}.jar" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openseek-api-0.17.1 | lib/fairdom/openbis_api/java_execution.rb |
openseek-api-0.11.1 | lib/fairdom/openbis_api/java_execution.rb |