Class: RAGE::Loader
- Inherits:
-
Object
- Object
- RAGE::Loader
- Defined in:
- lib/rage/loader.rb
Overview
Loads resources from uris
Class Method Summary collapse
-
.load(source_uri) ⇒ Object
Loads and return text resource from specified source uri.
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/rage/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 |