Module: Robotron
- Defined in:
- lib/robotron.rb,
lib/robotron/version.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
- .call(env) ⇒ Object
- .default_body ⇒ Object
- .default_headers ⇒ Object
- .environment ⇒ Object
- .robots_directory ⇒ Object
- .robots_path ⇒ Object
Class Method Details
.call(env) ⇒ Object
3 4 5 6 7 8 9 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/robotron.rb', line 23 def default_body "User-Agent: *\nDisallow: /" end |
.default_headers ⇒ Object
27 28 29 30 31 32 |
# File 'lib/robotron.rb', line 27 def default_headers { 'Content-Type' => 'text/plain', 'Cache-Control' => 'public, max-age=31557600' } end |
.environment ⇒ Object
11 12 13 |
# File 'lib/robotron.rb', line 11 def environment ENV['RACK_ENV'] || 'development' end |
.robots_directory ⇒ Object
15 16 17 |
# File 'lib/robotron.rb', line 15 def robots_directory defined?(Rails) ? Rails.root.join('config') : File.join('spec') end |
.robots_path ⇒ Object
19 20 21 |
# File 'lib/robotron.rb', line 19 def robots_path File.join(robots_directory, "robots.txt.#{ environment }") end |