Class WSDL::XMLSchema::Importer
In: lib/wsdl/xmlSchema/importer.rb
Parent: Object

Methods

fetch   import   import   new   parse   web_client  

Public Class methods

[Source]

    # File lib/wsdl/xmlSchema/importer.rb, line 18
18:   def self.import(location, originalroot = nil)
19:     new.import(location, originalroot)
20:   end

[Source]

    # File lib/wsdl/xmlSchema/importer.rb, line 22
22:   def initialize
23:     @web_client = nil
24:   end

Public Instance methods

[Source]

    # File lib/wsdl/xmlSchema/importer.rb, line 26
26:   def import(location, originalroot = nil)
27:     unless location.is_a?(URI)
28:       location = URI.parse(location)
29:     end
30:     content = parse(fetch(location), location, originalroot)
31:     content.location = location
32:     content
33:   end

Private Instance methods

[Source]

    # File lib/wsdl/xmlSchema/importer.rb, line 45
45:   def fetch(location)
46:     warn("importing: #{location}") if $DEBUG
47:     content = nil
48:     if location.scheme == 'file' or
49:         (location.relative? and FileTest.exist?(location.path))
50:       content = File.open(location.path).read
51:     elsif location.scheme and location.scheme.size == 1 and
52:         FileTest.exist?(location.to_s)
53:       # ToDo: remove this ugly workaround for a path with drive letter
54:       # (D://foo/bar)
55:       content = File.open(location.to_s).read
56:     else
57:       client = web_client.new(nil, "WSDL4R")
58:       client.proxy = ::SOAP::Env::HTTP_PROXY
59:       client.no_proxy = ::SOAP::Env::NO_PROXY
60:       if opt = ::SOAP::Property.loadproperty(::SOAP::PropertyName)
61:         ::SOAP::HTTPConfigLoader.set_options(client,
62:           opt["client.protocol.http"])
63:       end
64:       content = client.get_content(location)
65:     end
66:     content
67:   end

[Source]

    # File lib/wsdl/xmlSchema/importer.rb, line 37
37:   def parse(content, location, originalroot)
38:     opt = {
39:       :location => location,
40:       :originalroot => originalroot
41:     }
42:     WSDL::XMLSchema::Parser.new(opt).parse(content)
43:   end

[Source]

    # File lib/wsdl/xmlSchema/importer.rb, line 69
69:   def web_client
70:     @web_client ||= begin
71:         require 'http-access2'
72:         if HTTPAccess2::VERSION < "2.0"
73:           raise LoadError.new("http-access/2.0 or later is required.")
74:         end
75:         HTTPAccess2::Client
76:       rescue LoadError
77:         warn("Loading http-access2 failed.  Net/http is used.") if $DEBUG
78:         require 'soap/netHttpClient'
79:         ::SOAP::NetHttpClient
80:       end
81:     @web_client
82:   end

[Validate]