Class: RXSD::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/rxsd/loader.rb

Overview

loads resources from uris

Class Method Summary collapse

Class Method Details

.load(source_uri) ⇒ Object

loads and return text resource from specified source uri



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rxsd/loader.rb', line 15

def self.load(source_uri)
   Logger.info "loading resource from uri #{source_uri}" 
   data = nil
   uri = URI.parse(source_uri)
   if uri.scheme == "file"
      data = File.read_all uri.path
   elsif uri.scheme == "http"
      data = Net::HTTP.get_response(uri.host, uri.path).body
   # elsif FIXME support other uri types
   end

   return data

   rescue URI::InvalidURIError
      raise Exceptions::InvalidResourceUri
end