module Robotron
Constants
- VERSION
Public Class Methods
call(env)
click to toggle source
# File lib/robotron.rb, line 3 def call(env) body = File.read(robots_path) [200, default_headers, [body]] rescue Errno::ENOENT [200, default_headers, [default_body]] end
default_body()
click to toggle source
# File lib/robotron.rb, line 23 def default_body "User-Agent: *\nDisallow: /" end
default_headers()
click to toggle source
# File lib/robotron.rb, line 27 def default_headers { 'Content-Type' => 'text/plain', 'Cache-Control' => 'public, max-age=31557600' } end
environment()
click to toggle source
# File lib/robotron.rb, line 11 def environment ENV['RACK_ENV'] || 'development' end
robots_directory()
click to toggle source
# File lib/robotron.rb, line 15 def robots_directory defined?(Rails) ? Rails.root.join('config') : File.join('spec') end
robots_path()
click to toggle source
# File lib/robotron.rb, line 19 def robots_path File.join(robots_directory, "robots.txt.#{ environment }") end