Module: ExecJS::Xtrn::Rack
- Defined in:
- lib/execjs/xtrn/routing.rb
Constant Summary collapse
- Formats =
YAML.load <<-EOY -: mime: text/x-yaml dump: YAML json: mime: appication/json dump: JSON html: mime: text/html dump: self EOY
Class Method Summary collapse
- .call(req) ⇒ Object
-
.dump(s) ⇒ Object
Dump as HTML.
- .stats ⇒ Object
Class Method Details
.call(req) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/execjs/xtrn/routing.rb', line 20 def self.call req f=Formats[req['action_dispatch.request.path_parameters'][:format]] || Formats['-'] [ 200, {"Content-Type"=> f['mime']}, [f['dump'].dump(stats)], ] end |
.dump(s) ⇒ Object
Dump as HTML
31 32 33 34 35 36 37 |
# File 'lib/execjs/xtrn/routing.rb', line 31 def self.dump s '<ul>'+ s.map do |k, v| "<li><b>#{k}</b>#{Hash===v ? dump(v) : ": #{v}"}</li>" end .join('')+'</ul>' end |