def open(input)
case
when input.respond_to?(:read)
@location = nil
@asset = input.read
when input.to_s =~ /^\s*</
@location = nil
@asset = input.to_s.dup
else
case
when File.exist?(input)
@location = input
when File.exist?(self.class.extend_name(input))
@location = self.class.extend_name(input)
when File.exist?(self.class.extend_path(input))
@location = self.class.extend_path(input)
else
@location = input
end
Kernel.open(@location, 'r:UTF-8') do |io|
@asset = io.read
end
end
self
rescue => e
raise ArgumentError, "failed to open asset #@location (#{input.inspect}): #{e.message}"
end