Class: I18nViz::Middleware
- Inherits:
-
Object
- Object
- I18nViz::Middleware
- Defined in:
- lib/i18n_viz/middleware.rb
Constant Summary collapse
- JS =
File.read(File.join(File.dirname(__FILE__), '..', '..', 'assets', 'javascripts', 'i18n_viz.js' ))
- CSS =
File.read(File.join(File.dirname(__FILE__), '..', '..', 'assets', 'stylesheets', 'i18n_viz.css' ))
Instance Attribute Summary collapse
-
#external_tool_url ⇒ Object
Returns the value of attribute external_tool_url.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) {|_self| ... } ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) {|_self| ... } ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 10 11 |
# File 'lib/i18n_viz/middleware.rb', line 7 def initialize(app, &block) @app = app yield(self) if block_given? end |
Instance Attribute Details
#external_tool_url ⇒ Object
Returns the value of attribute external_tool_url.
6 7 8 |
# File 'lib/i18n_viz/middleware.rb', line 6 def external_tool_url @external_tool_url end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/i18n_viz/middleware.rb', line 13 def call(env) @status, @headers, @body = @app.call(env) return [@status, @headers, @body] if !html? || !(env["QUERY_STRING"] =~ /i18n_viz/) response = Rack::Response.new([], @status, @headers) @body.each { |fragment| response.write inject(env, fragment) } @body.close if @body.respond_to?(:close) response.finish end |