cylon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/.rvmrc +2 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/Rakefile.rb +10 -0
- data/lib/cylon.rb +11 -0
- data/lib/cylon/rack.rb +16 -0
- data/lib/cylon/rails.rb +4 -0
- data/spec/rack_spec.rb +35 -0
- data/spec/spec_helper.rb +13 -0
- metadata +73 -0
data/.bundle/config
ADDED
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
rack (1.2.1)
|
6
|
+
rack-test (0.5.7)
|
7
|
+
rack (>= 1.0)
|
8
|
+
rspec (2.4.0)
|
9
|
+
rspec-core (~> 2.4.0)
|
10
|
+
rspec-expectations (~> 2.4.0)
|
11
|
+
rspec-mocks (~> 2.4.0)
|
12
|
+
rspec-core (2.4.0)
|
13
|
+
rspec-expectations (2.4.0)
|
14
|
+
diff-lcs (~> 1.1.2)
|
15
|
+
rspec-mocks (2.4.0)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
rack-test
|
22
|
+
rspec (= 2.4.0)
|
data/Rakefile.rb
ADDED
data/lib/cylon.rb
ADDED
data/lib/cylon/rack.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Cylon
|
2
|
+
class Rack
|
3
|
+
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
if env["PATH_INFO"] == "/robots.txt" && RACK_ENV != "production"
|
10
|
+
[200, {"Content-Type" => "text/plain"}, ["User-Agent: *\nDisallow: /"]]
|
11
|
+
else
|
12
|
+
@app.call(env)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/cylon/rails.rb
ADDED
data/spec/rack_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Cylon Rack Middleware" do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
let(:app) { Cylon::Rack.new(Cylon::TestingRackApp.new) }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Object.send(:remove_const, :RACK_ENV)
|
9
|
+
RACK_ENV = "test"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not be indexable" do
|
13
|
+
get '/robots.txt'
|
14
|
+
last_response.should be_ok
|
15
|
+
last_response.body.should eql("User-Agent: *\nDisallow: /")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should not change the content if we are not in /robots.txt" do
|
19
|
+
get '/'
|
20
|
+
last_response.body.should_not eql("User-Agent: *\nDisallow: /")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should also not match in subdirectories" do
|
24
|
+
get '/testing/robots.txt'
|
25
|
+
last_response.body.should_not eql("User-Agent: *\nDisallow: /")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be indexable if we are in production" do
|
29
|
+
Object.send(:remove_const, :RACK_ENV)
|
30
|
+
RACK_ENV = "production"
|
31
|
+
get '/robots.txt'
|
32
|
+
last_response.should be_ok
|
33
|
+
last_response.body.should_not eql("User-Agent: *\nDisallow: /")
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cylon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Damien Mathieu
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-15 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Rack middleware and Rails Engine to avoid indexing your application in staging
|
22
|
+
email: 42@dmathieu.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- .bundle/config
|
31
|
+
- .rvmrc
|
32
|
+
- Gemfile
|
33
|
+
- Gemfile.lock
|
34
|
+
- Rakefile.rb
|
35
|
+
- lib/cylon.rb
|
36
|
+
- lib/cylon/rack.rb
|
37
|
+
- lib/cylon/rails.rb
|
38
|
+
- spec/rack_spec.rb
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/dmathieu/cylon
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: cylon
|
68
|
+
rubygems_version: 1.3.7
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Rack middleware and Rails Engine to avoid indexing your application in staging
|
72
|
+
test_files: []
|
73
|
+
|