lib/plezi/handlers/http_router.rb in plezi-0.12.1 vs lib/plezi/handlers/http_router.rb in plezi-0.12.2

- old
+ new

@@ -45,17 +45,17 @@ params[:assets_public] ||= '/assets' params[:assets_public].chomp! '/' params[:public] ||= params[:root] # backwards compatability host_name = (host_name.is_a?(String) ? host_name.to_s.downcase : (host_name.is_a?(Regexp) ? host_name : :default)) @active_host = get_host(host_name) || ( @hosts[host_name] = Host.new(params) ) - add_alias host_name, *params[:alias] if params[:alias] + add_alias host_name, *params[:alias] if params[:alias] # && host_name != :default @active_host end # adds an alias to an existing host name (normally through the :alias parameter in the `add_host` method). def add_alias host_name, *aliases host = get_host host_name - raise "Couldn't find requested host to add alias." unless host. + raise "Couldn't find requested host to add alias." unless host aliases.each {|a| @hosts[a.to_s.downcase] = host} true end # adds a route to the active host. The active host is the last host referenced by the `add_host`. @@ -118,10 +118,14 @@ # set where to store the rendered asset target_file = File.join( params[:public].to_s, *request.path.split('/') ) # send the file if it exists (no render needed) if File.exists?(source_file) - data = Plezi.cache_needs_update?(source_file) ? Plezi.save_file(target_file, Plezi.reload_file(source_file), (params[:public] && params[:save_assets])) : Plezi.load_file(source_file) + data = if ::Plezi::Cache::CACHABLE.include?(::File.extname(source_file)[1..-1]) + Plezi.cache_needs_update?(source_file) ? Plezi.save_file(target_file, Plezi.reload_file(source_file), (params[:public] && params[:save_assets])) : Plezi.load_file(source_file) + else + ::File.new source_file, 'rb' + end return (data ? Base::HTTPSender.send_raw_data(request, response, data, MimeTypeHelper::MIME_DICTIONARY[::File.extname(source_file)]) : false) end # render the file if it's a registered asset data = ::Plezi::AssetManager.render source_file, binding