Module: ExecJS::Xtrn::Rack
- Defined in:
- lib/execjs/xtrn/routing.rb
Constant Summary collapse
- Formats =
YAML.load " -:\n mime: text/x-yaml\n dump: YAML\n json:\n mime: appication/json\n dump: JSON\n html:\n mime: text/html\n dump: self\n"
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 |
.stats ⇒ Object
16 17 18 |
# File 'lib/execjs/xtrn/routing.rb', line 16 def self.stats ExecJS::Xtrn.stats.as_json end |