require 'yaml' require 'net/http' module Hydra class UnknownProxyType < RuntimeError end class ProxyConfig def self.load(config_yml) config = YAML::load(config_yml) if config.has_key?('proxy') proxy_info = config['proxy'] #only file supported so far if proxy_info['type'] == "file" YAML::load_file(proxy_info['path']) elsif proxy_info['type'] == "http" YAML::load(Net::HTTP.get(URI.parse(proxy_info['path']))) else raise UnknownProxyType.new("Proxy config file does not know what to do with type '#{proxy_info["type"]}'.") end else config end end end end