Skip to content

Loading…

Prettier code #8

Open
wants to merge 1 commit into from

2 participants

@shurizzle

Some corrections to code (i fault in latter :P)

@rkh rkh commented on the diff
almost_sinatra.rb
@@ -1,8 +1,8 @@
%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
+$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
@rkh Owner
rkh added a note

lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rkh rkh commented on the diff
almost_sinatra.rb
((7 lines not shown))
%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}}}
+D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;params.update(Hash[q.params.dup])}}
@rkh Owner
rkh added a note

where's the #to_sym mapping?

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

    Prettier code

    shurizzle committed
Showing with 3 additions and 3 deletions.
  1. +3 −3 almost_sinatra.rb
View
6 almost_sinatra.rb
@@ -1,8 +1,8 @@
%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
+$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
@rkh Owner
rkh added a note

lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
%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)||{})}}
+Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=Hash[File.read(caller[0][/^[^:]+/]).scan(S)];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}}}
+D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;params.update(Hash[q.params.dup])}}
@rkh Owner
rkh added a note

where's the #to_sym mapping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.