Class: Rack::Robotz
- Inherits:
-
Object
- Object
- Rack::Robotz
- Defined in:
- lib/rack/robotz/middleware.rb
Constant Summary collapse
- VERSION =
'0.0.4'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, items = {"User-Agent" => "*", "Disallow" => "/"}) ⇒ Robotz
constructor
A new instance of Robotz.
- #to_s ⇒ Object
Constructor Details
#initialize(app, items = {"User-Agent" => "*", "Disallow" => "/"}) ⇒ Robotz
Returns a new instance of Robotz.
7 8 9 10 |
# File 'lib/rack/robotz/middleware.rb', line 7 def initialize(app, items = {"User-Agent" => "*", "Disallow" => "/"}) @app = app @items = items end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rack/robotz/middleware.rb', line 16 def call(env) if env['PATH_INFO'] == '/robots.txt' [200, { 'Content-Type' => 'text/plain' }, [to_s]] else @app.call(env) end end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/rack/robotz/middleware.rb', line 12 def to_s @items.map { |key, value| "#{key}: #{value}" }.join("\n") end |