stop_it 1.0.0 → 1.0.1
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/README.md +10 -0
- data/lib/stop_it.rb +1 -1
- data/spec/stop_it_spec.rb +5 -0
- data/stop_it.gemspec +1 -1
- metadata +4 -3
data/README.md
CHANGED
@@ -48,6 +48,16 @@ If the block in stop method returns true then the request will be blocked. If it
|
|
48
48
|
|
49
49
|
Requests can be blocked by request path, remote address, query string, HTTP method, and user agent.
|
50
50
|
|
51
|
+
The block in stop method may return a rake app response like this:
|
52
|
+
|
53
|
+
StopIt.stop do |path_info, remote_addr, query_string, request_method, user_agent|
|
54
|
+
if remote_addr == "127.0.0.2"
|
55
|
+
[403, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, []]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
In this case the request will be blocked and the requestor will receive the returned response.
|
60
|
+
|
51
61
|
## Contributing
|
52
62
|
|
53
63
|
Your contribution is welcome.
|
data/lib/stop_it.rb
CHANGED
data/spec/stop_it_spec.rb
CHANGED
@@ -20,6 +20,11 @@ describe StopIt do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "middleware response" do
|
23
|
+
context "stop block not specified" do
|
24
|
+
before { StopIt.instance_variable_set("@stop", nil) }
|
25
|
+
it_should_behave_like "non-blocker", {}
|
26
|
+
end
|
27
|
+
|
23
28
|
context "stop block returns false" do
|
24
29
|
before { StopIt.stop { |path_info, remote_addr, query_string, request_method, user_agent| false } }
|
25
30
|
it_should_behave_like "non-blocker", {}
|
data/stop_it.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stop_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-10-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70174348138700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70174348138700
|
25
25
|
description: ''
|
26
26
|
email:
|
27
27
|
- andrew.gridnev@gmail.com
|
@@ -66,3 +66,4 @@ summary: Middleware for blocking requests to rake apps.
|
|
66
66
|
test_files:
|
67
67
|
- spec/spec_helper.rb
|
68
68
|
- spec/stop_it_spec.rb
|
69
|
+
has_rdoc:
|