Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

kill a few useless params, use 1.9ism to avoid having to write send all the time, #3

Closed
wants to merge 8 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2011
  1. @riffraff

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

    riffraff authored
    …g a bound method, remove useless reference to Object/O and use 1.9 callable.(), save 34 chars
  2. @riffraff
Commits on Mar 10, 2011
  1. @riffraff

    merge at_exit -> END

    riffraff authored
  2. @riffraff
  3. @riffraff
  4. @riffraff

    move everything inside module, extend rack so we avoid R:: and save a…

    riffraff authored
    … few chars, tnan we can use locals instead of constants and save another char by reusing previously assigned local in top assignment
  5. @riffraff

    oops, lost $n

    riffraff authored
  6. @riffraff
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 8 deletions.
  1. +9 −8 almost_sinatra.rb
View
17 almost_sinatra.rb
@@ -1,8 +1,9 @@
-%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}
-%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||=(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[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}}
-puts "== Almost #$n/No Version has taken the stage on #$p for development with backup from Webrick"
+%w.rack tilt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l}
+$n=Sinatra=Module.new{extend Rack;a,D,S,$p,q,Application=Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a
+%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)]]}}}}
+Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|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|D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}}
+%w[params session].map{|m|D.(m){q.send m}};a.use Session::Cookie;a.use Lock
+D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}
+}
+puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick"
Something went wrong with that request. Please try again.