diff --git a/lib/camping-unabridged.rb b/lib/camping-unabridged.rb
index e72bca7..7f8ddf3 100644
--- a/lib/camping-unabridged.rb
+++ b/lib/camping-unabridged.rb
@@ -391,7 +391,6 @@ def URL c='/',*a
#
module Base
attr_accessor :input, :cookies, :headers, :body, :status, :root
- M = proc { |_, o, n| o.merge(n, &M) }
# Display a view, calling it by its method name +v+. If a layout
# method is found in Camping::Views, it will be used to wrap the HTML.
@@ -510,7 +509,7 @@ def to_a
@env['rack.session'] = @state
r = Rack::Response.new(@body, @status, @headers)
@cookies.each do |k, v|
- v = {:value => v, :path => self / "/"} if String===v
+ v = {:value => v, :path => self / "/"} if String === v
r.set_cookie(k, v)
end
r.to_a
@@ -518,14 +517,21 @@ def to_a
def initialize(env, m) #:nodoc:
r = @request = Rack::Request.new(@env = env)
- @root, p, @cookies, @state,
+ @root, @input, @cookies, @state,
@headers, @status, @method =
- (env['SCRIPT_NAME']||'').sub(/\/$/,''),
- H[r.params], H[r.cookies], H[r.session],
+ r.script_name.sub(/\/$/,''), n(r.params),
+ H[r.cookies], H[r.session],
{}, m =~ /r(\d+)/ ? $1.to_i : 200, m
-
- @input = p.inject(H[]) do |h, (k, v)|
- h.merge(k.split(/[\]\[]+/).reverse.inject(v) { |x, i| H[i => x] }, &M)
+ end
+
+ def n(h) # :nodoc:
+ if Hash === h
+ h.inject(H[]) do |m, (k, v)|
+ m[k] = n(v)
+ m
+ end
+ else
+ h
end
end
@@ -843,7 +849,7 @@ def goes(m)
def call(e)
X.M
p = e['PATH_INFO'] = U.unescape(e['PATH_INFO'])
- k,m,*a=X.D p,(e['REQUEST_METHOD']||'get').downcase
+ k,m,*a=X.D p,e['REQUEST_METHOD'].downcase
k.new(e,m).service(*a).to_a
rescue
r500(:I, k, m, $!, :env => e).to_a
diff --git a/lib/camping.rb b/lib/camping.rb
index d23b89a..2e0a318 100644
--- a/lib/camping.rb
+++ b/lib/camping.rb
@@ -11,7 +11,6 @@ def method_missing m,*a;m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m.to_s]:super end
p[0]==?/?@root+p:p end;def URL c='/',*a;c=R(c, *a) if c.respond_to?:urls
c=self/c;c=@request.url[/.{8,}?(?=\/)/]+c if c[0]==?/;URI c end
end;module Base;attr_accessor:input,:cookies,:headers,:body,:status,:root
-M=proc{|_,o,n|o.merge(n,&M)}
def render v,*a,&b;mab(/^_/!~v.to_s){send(v,*a,&b)} end
def mab l=nil,&b;m=Mab.new({},self);s=m.capture(&b)
s=m.capture{layout{s}} if l && m.respond_to?(:layout);s end
@@ -24,11 +23,10 @@ def r501 m;P%"#{m.upcase} not implemented"end;def to_a
r.set_cookie(k,v)}
r.to_a;end;def initialize(env,m)
r=@request=Rack::Request.new(@env=env)
-@root,p,@cookies,@state,@headers,@status,@method=
-(env['SCRIPT_NAME']||'').sub(/\/$/,''),H[r.params],
+@root,@input,@cookies,@state,@headers,@status,@method=
+r.script_name.sub(/\/$/,''),n(r.params),
H[r.cookies],H[r.session],{},m=~/r(\d+)/?$1.to_i: 200,m
-@input=p.inject(H[]){|h,(k,v)|h.merge k.split(/[\]\[]+/).reverse.inject(v){|x,i|
-H[i=>x]},&M};end;def service *a
+end;def n h;Hash===h ?h.inject(H[]){|m,(k,v)|m[k]=n(v);m}: h end;def service *a
r=catch(:halt){send(@method,*a)};@body||=r
self;end;end;module Controllers;@r=[];class<e).to_a;end
def method_missing m,c,*a;X.M;h=Hash===a[-1]?a.pop: {}
e=H[Rack::MockRequest.env_for('',h[:env]||{})]