lib/appengine-tools/web-xml.rb in appengine-tools-0.0.11 vs lib/appengine-tools/web-xml.rb in appengine-tools-0.0.12

- old
+ new

@@ -21,44 +21,43 @@ require 'appengine-rack/java' class WebXmlBuilder < Rack::Builder DUMMY_APP = Proc.new{|env|} - + def initialize(&block) @path = "/" @paths = Hash.new {|h, k| h[k] = []} @skip_defaults = false @mime_mapping = {} instance_eval(&block) if block_given? end - + def add_mime_mapping(doc) @mime_mapping.each_pair do |key,val| mime = doc.add_element('mime-mapping') mime.add_element('extension').add_text(key.to_s) mime.add_element('mime-type').add_text(val) end end - - def add_jruby_rack_defaults(rackup) - use JavaContextParams, :rackup => rackup + + def add_jruby_rack_defaults unless @skip_defaults - use JavaServletFilter, 'org.jruby.rack.RackFilter', + use JavaServletFilter, 'org.jruby.rack.RackFilter', { :name => 'RackFilter', :wildcard => true } end use JavaContextListener, 'com.google.appengine.jruby.LazyContextListener' end - + def use(middleware, *args, &block) if middleware.respond_to? :append_xml @paths[@path] << [middleware, args, block] else @paths[@path] << [middleware.new(DUMMY_APP, *args, &block)] end end - + def map(path, &block) if URI.parse(path).scheme.nil? # we can only natively support path matching saved_path = @path @path = [@path, path].join('/').squeeze('/') begin @@ -66,11 +65,11 @@ ensure @path = saved_path end end end - + def run(app) @paths[@path] << [app, [], nil] end def to_xml @@ -87,10 +86,10 @@ end end add_mime_mapping(doc) doc end - + private def each_path @paths.sort {|a, b| b[0].length - a[0].length}.each do |path, value| yield path, value end