Sha256: 1a87698a9a6255a03256acc5afe2b245d0f885f67489bcdc40e1c965c9c41eb3
Contents?: true
Size: 945 Bytes
Versions: 4
Compression:
Stored size: 945 Bytes
Contents
require 'spire/resource/mime' module Spire class Public def initialize(opts={:render=>true}) @file = opts[:file] @render = opts[:render] mime = Mime.new @mime_types = mime.return_mimes end def extension_check file_extension = File.extname(@file) @mime_types.each do |ext, type| if file_extension == ext @content_type = type end end if @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/#{@file}" return Error.new(:status => 404) unless File.exists?(path) file = IO.read(path) @return = {} @return[:file] = file @return[:content_type] = @content_type return @return end def to_rack @return.to_rack end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
spire-0.3.3 | lib/spire/public.rb |
spire-0.3.2 | lib/spire/public.rb |
spire-0.3.0 | lib/spire/public.rb |
spire-0.2.4 | lib/spire/public.rb |