Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

second round #6

Open
wants to merge 19 commits into from

3 participants

@janlelis

No description provided.

@rkh
Owner

this causes an "can't modify hash while iterating" exception on the latest 1.9

@riffraff

does using R for $r work? I believed constants are looked up lexically at parse time so the trap block would fail

works fine :]

@rkh
Owner

@riffraff: They are looked up lexically, but not at parse time. (Also, except if you use ActiveSupport autoloading, they are also looked up in the inheritance chain.)

@janlelis: Sorry, but 13 lines is a no go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 5 deletions.
  1. +9 −5 almost_sinatra.rb
View
14 almost_sinatra.rb
@@ -1,9 +1,13 @@
-%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.rack tilt backports INT TERM..map{|l|trap(l){R.stop}rescue require l}
+$n=Sinatra=Module.new{extend Rack;a=Application=Builder.new;D,P,q=Object.method(:define_method),4567
%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}}
+Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(/@@ *([^
+]+)
+(((?!@@)[^
+]*
+)*)/m){h[$1]=$2};h);v.new(*o){n==(z=n.to_s)?n:$t[z]}.render(a,o[0].try(:[],:locals)||{})}}
+%w[set enable disable configure helpers use register].map{|m|D.(m){|*,&b|b.try :[]}};END{Handler.get(W).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"
+puts"== almost #$n/No Version has taken the stage on #{P} for development with backup from "+W="WEBrick"
Something went wrong with that request. Please try again.