Class: Rack::Favicon
- Inherits:
-
Object
- Object
- Rack::Favicon
- Defined in:
- lib/rack/favicon.rb,
lib/rack/favicon/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Favicon
constructor
A new instance of Favicon.
Constructor Details
#initialize(app, options = {}) ⇒ Favicon
Returns a new instance of Favicon.
7 8 9 10 |
# File 'lib/rack/favicon.rb', line 7 def initialize(app, = {}) @app = app @options = end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/favicon.rb', line 12 def call(env) status, headers, response = @app.call(env) if env['PATH_INFO'] =~ (/favicon\.ico$/) if @options[:image] path = ::File.join(Dir.getwd, @options[:image]) else path = ::File.('../favicon.ico', __FILE__) end response = [ ::File.open(path, 'rb') { |file| file.read } ] end [status, headers, response] end |