SHOW:
|
|
- or go back to the newest paste.
1 | %w.rack tilt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} | |
2 | $n=Sinatra=Module.new | |
3 | { | |
4 | extend Rack; | |
5 | a = Builder.new | |
6 | D = Object.method(:define_method) | |
7 | $p = 4567 | |
8 | S = /@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m; | |
9 | q,Application=a | |
10 | ||
11 | %w[get post put delete].map{|m| | |
12 | D.(m){|u,&b| | |
13 | a.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[a.instance_eval(&b)]]}} | |
14 | } | |
15 | } | |
16 | Tilt.mappings.map{|k,v| | |
17 | D.(k){|n,*o| | |
18 | $t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h); | |
19 | v.new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{}) | |
20 | } | |
21 | } | |
22 | ||
23 | %w[set enable disable configure helpers use register].map{|m| | |
24 | D.(m){|*_,&b|b.try :[]} | |
25 | }; | |
26 | ||
27 | END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}} | |
28 | ||
29 | %w[params session].map{|m| | |
30 | D.(m){q.send m} | |
31 | }; | |
32 | ||
33 | a.use Session::Cookie; | |
34 | a.use Lock | |
35 | D.(:before){|&b| | |
36 | a.use Rack::Config,&b | |
37 | }; | |
38 | before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}} | |
39 | } | |
40 | puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" |