Sha256: d78e0918f6bd6c47fef5f575671fd41d00f5e2cba58043b4e3cdc1c9b3c76e90
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
require 'rest-client' module XsdReader class Import include Shared def namespace node.attributes['namespace'] ? node.attributes['namespace'].value : nil end def schema_location node.attributes['schemaLocation'] ? node.attributes['schemaLocation'].value : nil end def reader return @reader || options[:reader] if @reader || options[:reader] if download_path File.write(download_path, download) if !File.file?(download_path) return @reader = XsdReader::XML.new(:xsd_file => download_path) end return @reader = XsdReader::XML.new(:xsd_xml => download) end def uri if namespace =~ /\.xsd$/ namespace else namespace.gsub(/#{File.basename(schema_location, '.*')}$/, '').to_s + schema_location end end def download @download ||= download_uri(self.uri) end def download_path # we need the parent XSD's path return nil if options[:xsd_file].nil? parent_path = File.dirname(options[:xsd_file]) File.join(parent_path, File.basename(schema_location)) end def local_xml File.file?(download_path) ? File.read(download_path) : download end private def download_uri(uri) logger.info "Downloading import schema from (uri)" response = RestClient.get uri return response.body end end # class Import end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
xsd-reader-0.4.0 | lib/xsd_reader/import.rb |
xsd-reader-0.3.0 | lib/xsd_reader/import.rb |
xsd-reader-0.2.0 | lib/xsd_reader/import.rb |
xsd-reader-0.1.0 | lib/xsd_reader/import.rb |