Class: Useless::Doc::Proxy::CSS

Inherits:
Object
  • Object
show all
Defined in:
lib/useless/doc/proxy/css.rb

Overview

Doc::Proxy::CSS serves the stylesheet for the current Doc::UI iff the request path is ‘/doc.css’. Otherwise, it passes the request down the stack.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CSS

Returns a new instance of CSS.



10
11
12
# File 'lib/useless/doc/proxy/css.rb', line 10

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/useless/doc/proxy/css.rb', line 14

def call(env)
  if env["PATH_INFO"].to_s == '/doc.css'
    if env['useless.doc.logger']
      env['useless.doc.logger'].info "serving CSS for #{env['useless.doc.ui'].class.name}"
    end

    [200, {'Content-Type' => 'text/css'}, [env['useless.doc.ui'].css]]
  else
    @app.call(env)
  end
end