Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

functional code means never to repeat yourself. Kill O.send(D by usin…

…g a bound method, remove useless reference to Object/O and use 1.9 callable.(), save 34 chars
  • Loading branch information...
commit 454de0d9a0075ba8a4e934c2fc19bd6e2799cef6 1 parent f68ca76
gabriele renzi authored March 09, 2011

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. 12  almost_sinatra.rb
12  almost_sinatra.rb
... ...
@@ -1,8 +1,8 @@
1 1
 %w.rack tilt backports INT TERM..map{|l|trap(l){$r.stop}rescue require(l)}
2  
-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}
3  
-%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)]]}}}}
4  
-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)||{})}}
5  
-%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}}
6  
-%w[params session].map{|m|O.send(D,m){$q.send(m)}};A.use(R::Session::Cookie);A.use(R::Lock)
7  
-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}}
  2
+R=Rack;$n=Sinatra=Module.new{A,D,H,S,F,$p=R::Builder.new,Object.method(:define_method),Hash,/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,File,4567;Application=A}
  3
+%w[get post put delete].map{|m|D.(m){|u,&b|A.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[A.instance_eval(&b)]]}}}}
  4
+Tilt.mappings.map{|k,v|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)||{})}}
  5
+%w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try(:[])}};at_exit{R::Handler.get("webrick").run(A,Port:$p){|s|$r=s}}
  6
+%w[params session].map{|m|D.(m){$q.send(m)}};A.use(R::Session::Cookie);A.use(R::Lock)
  7
+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}}
8 8
 puts "== Almost #$n/No Version has taken the stage on #$p for development with backup from Webrick"

0 notes on commit 454de0d

Please sign in to comment.
Something went wrong with that request. Please try again.