Sha256: 187d12ae52e3311e5027c73afcf83f5916eff679daa7c6727a32a0e55d0ed884
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'spire/resource/mime' module Spire class Public def initialize(opts={:render=>true}) @opts = opts mime = Mime.new @mime_types = mime.return_mimes end def extension_check file_extension = File.extname(@opts[:file]) @mime_types.each do |ext, type| if file_extension == ext @content_type = type end end if @opts[:render] self.create_response else return [false, @content_type] end end def create_response path = File.expand_path(__FILE__) path["lib/spire/public.rb"] = "public/#{@opts[:file]}" if File.exists?(path) file = IO.read(path) @return = {} @return[:file] = file @return[:content_type] = @content_type return @return else return 404 end end # this is an explicit function and should be avoided def return_file!(file) path = File.expand_path(__FILE__) path["lib/spire/public.rb"] = "public/#{file}" if File.exists?(path) file = IO.read(path) return file else return false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spire-0.4.4 | lib/spire/public.rb |