rack-robots 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -0
- data/lib/rack/robots.rb +25 -0
- metadata +47 -0
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
rack-robots
|
2
|
+
===========
|
3
|
+
|
4
|
+
Rack middleware that denies all robots for staging and development environments.
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
|
9
|
+
Flag your staging and development environments:
|
10
|
+
|
11
|
+
``` bash
|
12
|
+
export DISABLE_ROBOTS=true
|
13
|
+
```
|
14
|
+
|
15
|
+
In a `config.ru` or equivalent:
|
16
|
+
|
17
|
+
``` ruby
|
18
|
+
use Rack::Instruments
|
19
|
+
run Sinatra::Application
|
20
|
+
```
|
21
|
+
|
22
|
+
Testing
|
23
|
+
-------
|
24
|
+
|
25
|
+
``` bash
|
26
|
+
rake test
|
27
|
+
```
|
data/lib/rack/robots.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rack
|
2
|
+
class Robots
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
if env["REQUEST_PATH"] == "/robots.txt"
|
9
|
+
status, body = if %w{1 true}.include?(ENV["DISABLE_ROBOTS"])
|
10
|
+
[200, <<-eos]
|
11
|
+
# this is a staging environment. please index the main site instead.
|
12
|
+
User-agent: *
|
13
|
+
Disallow: /
|
14
|
+
eos
|
15
|
+
else
|
16
|
+
[404, "Not found"]
|
17
|
+
end
|
18
|
+
[status, { 'Content-Length' => body.length,
|
19
|
+
'Content-Type' => 'text/plain' }, body]
|
20
|
+
else
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-robots
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brandur
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email: brandur@mutelight.org
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- README.md
|
21
|
+
- lib/rack/robots.rb
|
22
|
+
homepage: https://github.com/brandur/rack-robots
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.23
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Rack middleware that denies all robots for staging and development environments.
|
47
|
+
test_files: []
|