stop_it 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -19,7 +19,7 @@ class StopIt
19
19
 
20
20
  if response == true
21
21
  [200, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, []]
22
- elsif response == false
22
+ elsif !response
23
23
  @app.call(env)
24
24
  else
25
25
  response
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
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
12
12
  gem.name = "stop_it"
13
13
  gem.require_paths = ["lib"]
14
- gem.version = "1.0.0"
14
+ gem.version = "1.0.1"
15
15
 
16
16
  gem.add_development_dependency 'rspec'
17
17
  end
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.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: &70316692893900 !ruby/object:Gem::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: *70316692893900
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: