i-rack 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +16 -0
- data/Rakefile +5 -0
- data/TODO +0 -0
- data/lib/i-rack.rb +2 -0
- data/lib/i-rack/i.rb +21 -0
- data/lib/i-rack/version.rb +7 -0
- data/spec/i-rack/i_spec.rb +42 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +8 -0
- data/tasks/spec.rb +6 -0
- metadata +78 -0
data/History.rdoc
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Simon Harris
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
= i-rack
|
2
|
+
|
3
|
+
Rack middleware that returns 404 in response to all requests for the resource “/WMD”
|
4
|
+
|
5
|
+
Somewhere in your Rack configuration (eg. config.ru) add:
|
6
|
+
|
7
|
+
require 'i-rack'
|
8
|
+
use I::Rack
|
9
|
+
|
10
|
+
Then hit your application with the appropriate request:
|
11
|
+
|
12
|
+
> curl -i -H http://localhost:9292/WMD
|
13
|
+
|
14
|
+
HTTP/1.1 404 Not Found
|
15
|
+
Content-Length: 0
|
16
|
+
Content-Type: text/plain
|
data/Rakefile
ADDED
data/TODO
ADDED
File without changes
|
data/lib/i-rack.rb
ADDED
data/lib/i-rack/i.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
module I
|
4
|
+
|
5
|
+
class Rack
|
6
|
+
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
if env["PATH_INFO"] == "/WMD"
|
13
|
+
["404 Not Found", {"Content-Type" => "text/plain", "Content-Length" => "0"}, []]
|
14
|
+
else
|
15
|
+
@app.call(env)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe I::Rack do
|
4
|
+
|
5
|
+
def do_call(path, request_method, &block)
|
6
|
+
request = Rack::MockRequest.env_for(path, :method => request_method)
|
7
|
+
@response = I::Rack.new(block).call(request)
|
8
|
+
end
|
9
|
+
|
10
|
+
%w{POST GET PUT DELETE HEAD}.each do |method|
|
11
|
+
|
12
|
+
describe method do
|
13
|
+
|
14
|
+
describe "/flibble" do
|
15
|
+
|
16
|
+
before do
|
17
|
+
do_call("/flibble", method) { |env| :result }
|
18
|
+
end
|
19
|
+
|
20
|
+
it "forwards the request for processing" do
|
21
|
+
@response.should == :result
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "/WMD" do
|
27
|
+
|
28
|
+
before do
|
29
|
+
do_call("/WMD", method) { |env| fail "Should not forward request for processing" }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns 404 Not Found" do
|
33
|
+
@response.should == ["404 Not Found", {"Content-Type" => "text/plain", "Content-Length" => "0"}, []]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
data/tasks/spec.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: i-rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simon Harris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-16 00:00:00 +11:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rack
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: "Rack middleware that returns 404 in response to all requests for the resource \xE2\x80\x9C/WMD\xE2\x80\x9D"
|
26
|
+
email: haruki.zaemon@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
- History.rdoc
|
34
|
+
- TODO
|
35
|
+
- LICENSE
|
36
|
+
files:
|
37
|
+
- lib/i-rack/i.rb
|
38
|
+
- lib/i-rack/version.rb
|
39
|
+
- lib/i-rack.rb
|
40
|
+
- spec/i-rack/i_spec.rb
|
41
|
+
- spec/spec.opts
|
42
|
+
- spec/spec_helper.rb
|
43
|
+
- tasks/spec.rb
|
44
|
+
- Rakefile
|
45
|
+
- README.rdoc
|
46
|
+
- History.rdoc
|
47
|
+
- TODO
|
48
|
+
- LICENSE
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/harukizaemon/i-rack
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.3.5
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: "Rack middleware that returns 404 in response to all requests for the resource \xE2\x80\x9C/WMD\xE2\x80\x9D"
|
77
|
+
test_files: []
|
78
|
+
|