iamjwc-hirb 0.1.1 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hirb/app.rb +13 -11
- metadata +1 -1
data/lib/hirb/app.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
require 'rack'
|
2
2
|
|
3
3
|
class Hirb::App
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
r = Rack::Request.new(env)
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
11
|
+
if r.path_info =~ /^\/hirb\/eval/
|
12
|
+
[200, {"Content-Type" => "text/plain"}, Hirb::Eval.boom_shakalaka(r[:cmd])]
|
13
|
+
elsif r.path_info =~ /^\/hirb/
|
14
|
+
html = File.read(File.join(File.dirname(__FILE__), "..", "..", "public", "hirb", "index.html"))
|
15
|
+
[200, {"Content-Type" => "text/html", "Content-Length" => html.size.to_s}, html]
|
16
|
+
else
|
17
|
+
@app.call(env)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|