Sha256: f661a2f74008bb531d4bab19d13420123ee3cfdcd764a1caec29648544de81c0

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

# From rack_dav
require 'builder'
require 'time'
require 'uri'
require 'rexml/document'
require 'webrick/httputils'

begin
  require 'rack_dav/builder_namespace'
  require 'rack_dav/http_status'
  require 'rack_dav/resource'
  require 'rack_dav/file_resource'
  require 'rack_dav/handler'
  require 'rack_dav/controller'
rescue LoadError => e
  raise MissingLibrary, "Rack_Dav could not be loaded (is it installed?): #{e.message}"
end 


module Capcode
  module Helpers
    
    def render_webdav( f, opts )
		  options = {
		    :resource_class => RackDAV::FileResource,
		    :root => f
		  }.merge(opts)
		  		
		  request = Rack::Request.new(env)
		  response = Rack::Response.new
    
		  begin
		    controller = RackDAV::Controller.new(request, response, options.dup)		    
		    controller.send(request.request_method.downcase)
		  rescue RackDAV::HTTPStatus::Status => status
		    response.status = status.code
		  end
      
		  # Strings in Ruby 1.9 are no longer enumerable.  Rack still expects the response.body to be
		  # enumerable, however.
		  response.body = [response.body] if not response.body.respond_to? :each
      
		  response.status = response.status ? response.status.to_i : 200
		  response.finish
		  
		  [response.status, response.header, response.body]
		end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
capcode-render-webdav-0.2.0 lib/capcode/render/webdav.rb
capcode-render-webdav-0.1.0 lib/capcode/render/webdav.rb
Capcode-0.8.9 lib/capcode/render/webdav.rb
Capcode-0.8.8 lib/capcode/render/webdav.rb