Sha256: 95d08bd64b8ba7cee7fdc898a9a1d50e32a1c18f66e4c0a9b6d3fa01f01a6ac7
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require "httpi" module Wasabi # = Wasabi::Resolver # # Resolves local and remote WSDL documents. class Resolver class HTTPError < StandardError def initialize(message, response=nil) super(message) @response = response end attr_reader :response end URL = /^http[s]?:/ XML = /^</ def initialize(document, request = nil, adapter = nil) @document = document @request = request || HTTPI::Request.new @adapter = adapter end attr_reader :document, :request, :adapter def resolve raise ArgumentError, "Unable to resolve: #{document.inspect}" unless document case document when URL then load_from_remote when XML then document else load_from_disc end end private def load_from_remote request.url = document response = HTTPI.get(request, adapter) raise HTTPError.new("Error: #{response.code} for url #{request.url}", response) if response.error? response.body end def load_from_disc File.read(document) end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
wasabi-4.0.0 | lib/wasabi/resolver.rb |
wasabi-3.8.0 | lib/wasabi/resolver.rb |
wasabi-3.7.0 | lib/wasabi/resolver.rb |
wasabi-3.6.1 | lib/wasabi/resolver.rb |
wasabi-3.6.0 | lib/wasabi/resolver.rb |