module BenchmarkDriver
def parse(config, working_directory: nil)
-
working_directory
(Hash
) -- - YAML-specific special parameter for "command_stdout" and a relative path in type -
config
(Hash
) --
def parse(config, working_directory: nil) config = symbolize_keys(config) type = config.fetch(:type) if !type.is_a?(String) raise ArgumentError.new("Invalid type: #{config[:type].inspect} (expected String)") elsif !type.match(/\A[A-Za-z0-9_\/]+\z/) raise ArgumentError.new("Invalid type: #{config[:type].inspect} (expected to include only [A-Za-z0-9_\/])") end config.delete(:type) # Dynamic dispatch for plugin support if type.include?('/') require File.join(working_directory || '.', type) type = File.basename(type) else require "benchmark_driver/runner/#{type}" end job = ::BenchmarkDriver.const_get("Runner::#{camelize(type)}::JobParser", false).parse(**config) if job.respond_to?(:working_directory) && job.respond_to?(:working_directory=) && job.working_directory.nil? job.working_directory = working_directory end job end