0
%w[tempfile uri].map{|l|require l};class Object;def meta_def m,&b
0
-(class<<self;self end).
instance_eval{define_method(m,&b)}end end
0
+(class<<self;self end).
send(:define_method,m,&b)end end
0
module Camping;C=self;S=IO.read(__FILE__)rescue nil;P="Cam\ping Problem!"
0
class H<Hash;def method_missing m,*a
0
-m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m.to_s]:super end;alias u merge!;end
0
-module Helpers def R c,*g;p,h=/\(.+?\)/,g.grep(Hash)
0
-(g-=h).inject(c.urls.find{|x|x.scan(p).size==g.size}.dup){|s,a|s.sub p,C.
0
-escape((a[a.class.primary_key]rescue a))}+(h.any?? "?"+h[0].map{|x|x.map{|z|C.
0
-escape z}*"="}*"&": "")end;def /(p);p[/^\//]?@root+p:p;end;def URL c='/',*a
0
+m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m.to_s]:super end;alias u merge!
0
+module Helpers def R c,*g;p,h=/\(.+?\)/,g.grep(Hash);g-=h;
0
+raise"bad route"unless u=c.urls.find{|x|break x if x.scan(p).size==g.size&&
0
+/^#{x}\/?$/=~(x=g.inject(x){|x,a|x.sub p,C.escape((a[a.class.primary_key
0
+h.any?? u+"?"+h[0].map{|x|x.map{|z|C.escape z}*"="}*"&":u end
0
+def /(p);p[/^\//]?@root+p:p;end;def URL c='/',*a
0
c=R(c,*a)if c.respond_to?:urls;c=self/c;c="//"+@env.HTTP_HOST+c if c[/^\//]
0
URI(c) end end;module Base;attr_accessor:input,:cookies,:env,:headers,:body,
0
:status,:root;Z="\r\n";def method_missing*a,&b;a.shift if a[0]==:render
0
m=Mab.new({},self);s=m.capture{send(*a,&b)};s=m.capture{send(:layout){s}}if
0
/^_/!~a[0].to_s and m.respond_to?:layout;s end;def redirect*a
0
-r 302,'','Location'=>URL(*a)end;def r s,b,h={};@status=s;headers.
merge!h
0
+r 302,'','Location'=>URL(*a)end;def r s,b,h={};@status=s;headers.
u h
0
@body=b end;def to_a;[status,body,headers]end;def initialize r,e,m
0
-@status,@method,@env,@headers,@root=200,m.downcase,e,{
0
-'Content-Type'=>"text/html"},e.SCRIPT_NAME.sub(/\/$/,'');@k=C.kp e.HTTP_COOKIE
0
+@status,@method,@env,@headers,@root=200,m.downcase,e,H[
0
+'Content-Type',"text/html"],e.SCRIPT_NAME.sub(/\/$/,'');@k=C.kp e.HTTP_COOKIE
0
q=C.qsp e.QUERY_STRING;@in=r;case e.CONTENT_TYPE
0
when %r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n
0
b=/(?:\r?\n|\A)#{Regexp::quote"--#$1"}(?:--)?\r$/;until
0
@@ -49,7 +52,7 @@ def kp s;c=qsp(s,';,')end;def run r=$stdin,e=ENV;X.M;e=H[e.to_hash]
0
k,a=X.D e.PATH_INFO=un("/#{e.PATH_INFO}".gsub(/\/+/,'/'));k.new(
0
r,e,(m=e.REQUEST_METHOD||"GET")).Y.service(*a);rescue=>x;X::ServerError.new(
0
r,e,'get').service(k,m,x)end;def method_missing m,c,*a;X.M;k=X.const_get(c).
0
-new(StringIO.new,H['HTTP_HOST','','SCRIPT_NAME','','HTTP_COOKIE',''],m.to_s);H.
0
-new(a.pop).each{|e,f|k.send("#{e}=",f)}if Hash===a[-1];k.service(*a);end;end
0
+new(StringIO.new,H['HTTP_HOST','','SCRIPT_NAME','','HTTP_COOKIE',''],m.to_s)
0
+H[a.pop].each{|e,f|k.send("#{e}=",f)}if Hash===a[-1];k.service(*a);end;end
0
module Views;include X,Helpers;end;module Models;autoload:Base,'camping/db';def
0
Y;self;end;end;autoload:Mab,'camping/mab'end
Comments
No one has commented yet.