Skip to content

Commit

Permalink
avoiding inject with a closure saves about 8 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
riffraff committed Mar 8, 2011
1 parent 2679a34 commit e4b666b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion almost_sinatra.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
%w.rack tilt backports INT TERM..map{|l|trap(l){$r.stop}rescue require(l)} %w.rack tilt backports INT TERM..map{|l|trap(l){$r.stop}rescue require(l)}
R=Rack;$n=Sinatra=Module.new{A,O,D,H,S,F,P=R::Builder.new,Object,:define_method,Hash,/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,File,4567;Application=A} R=Rack;$n=Sinatra=Module.new{A,O,D,H,S,F,P=R::Builder.new,Object,:define_method,Hash,/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,File,4567;Application=A}
%w[get post put delete].map{|m|O.send(D,m){|u,&b|A.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[A.instance_eval(&b)]]}}}} %w[get post put delete].map{|m|O.send(D,m){|u,&b|A.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[A.instance_eval(&b)]]}}}}
Tilt.mappings.map{|k,v|O.send(D,k){|n,*o|$t||=F.read(caller.first[/^[^:]+/]).scan(S).inject({}){|h,(a,b,c)|h[a]=b;h};v.new(*o){(n.to_s==n)?(n):($t[n.to_s])}.render(A,o[0].try(:[],:locals)||{})}} Tilt.mappings.map{|k,v|O.send(D,k){|n,*o|$t||=(h={};F.read(caller.first[/^[^:]+/]).scan(S){|a,b,c|h[a]=b};h);v.new(*o){(n.to_s==n)?(n):($t[n.to_s])}.render(A,o[0].try(:[],:locals)||{})}}
%w[set enable disable configure helpers use register].map{|m|O.send(D,m){|*_,&b|b.try(:[])}};at_exit{R::Handler.get("webrick").run(A,:Port=>P){|s|$r=s}} %w[set enable disable configure helpers use register].map{|m|O.send(D,m){|*_,&b|b.try(:[])}};at_exit{R::Handler.get("webrick").run(A,:Port=>P){|s|$r=s}}
%w[params session].map{|m|O.send(D,m){$q.send(m)}};A.use(R::Session::Cookie);A.use(R::Lock) %w[params session].map{|m|O.send(D,m){$q.send(m)}};A.use(R::Session::Cookie);A.use(R::Lock)
O.send(D,:before){|&b|A.use(R::Config,&b)};before{|e|$q=R::Request.new(e);$q.params.dup.map{|k,v|params[k.to_sym]=v}} O.send(D,:before){|&b|A.use(R::Config,&b)};before{|e|$q=R::Request.new(e);$q.params.dup.map{|k,v|params[k.to_sym]=v}}
Expand Down

0 comments on commit e4b666b

Please sign in to comment.