rack-robots 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -1
- data/lib/rack/robots.rb +3 -8
- metadata +3 -3
data/README.md
CHANGED
@@ -10,12 +10,15 @@ Flag your staging and development environments:
|
|
10
10
|
|
11
11
|
``` bash
|
12
12
|
export DISABLE_ROBOTS=true
|
13
|
+
|
14
|
+
# or on Heroku
|
15
|
+
heroku config:add DISABLE_ROBOTS=true
|
13
16
|
```
|
14
17
|
|
15
18
|
In a `config.ru` or equivalent:
|
16
19
|
|
17
20
|
``` ruby
|
18
|
-
use Rack::
|
21
|
+
use Rack::Robots
|
19
22
|
run Sinatra::Application
|
20
23
|
```
|
21
24
|
|
data/lib/rack/robots.rb
CHANGED
@@ -5,18 +5,13 @@ module Rack
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def call(env)
|
8
|
-
if env["REQUEST_PATH"] == "/robots.txt"
|
9
|
-
|
10
|
-
[200, <<-eos]
|
8
|
+
if env["REQUEST_PATH"] == "/robots.txt" &&
|
9
|
+
%w{1 true yes}.include?(ENV["DISABLE_ROBOTS"])
|
10
|
+
[200, { 'Content-Type' => 'text/plain' }, <<-eos]
|
11
11
|
# this is a staging environment. please index the main site instead.
|
12
12
|
User-agent: *
|
13
13
|
Disallow: /
|
14
14
|
eos
|
15
|
-
else
|
16
|
-
[404, "Not found"]
|
17
|
-
end
|
18
|
-
[status, { 'Content-Length' => body.length.to_s,
|
19
|
-
'Content-Type' => 'text/plain' }, body]
|
20
15
|
else
|
21
16
|
@app.call(env)
|
22
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-robots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: brandur@mutelight.org
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 1.8.
|
43
|
+
rubygems_version: 1.8.24
|
44
44
|
signing_key:
|
45
45
|
specification_version: 3
|
46
46
|
summary: Rack middleware that denies all robots for staging and development environments.
|