rack-block 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-block (0.0.1.pre1)
4
+ rack-block (0.1.1)
5
5
  rack (>= 1.3)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
+ coderay (0.9.8)
10
11
  diff-lcs (1.1.3)
11
- guard (0.8.8)
12
+ ffi (1.0.11)
13
+ guard (0.9.4)
14
+ ffi (>= 0.5.0)
12
15
  thor (~> 0.14.6)
13
- guard-rspec (0.5.9)
16
+ guard-rspec (0.5.10)
14
17
  guard (>= 0.8.4)
18
+ method_source (0.6.7)
19
+ ruby_parser (>= 2.3.1)
20
+ pry (0.9.7.4)
21
+ coderay (~> 0.9.8)
22
+ method_source (~> 0.6.7)
23
+ ruby_parser (>= 2.3.1)
24
+ slop (~> 2.1.0)
15
25
  rack (1.3.5)
16
26
  rack-protection (1.1.4)
17
27
  rack
@@ -26,10 +36,14 @@ GEM
26
36
  rspec-expectations (2.7.0)
27
37
  diff-lcs (~> 1.1.2)
28
38
  rspec-mocks (2.7.0)
39
+ ruby_parser (2.3.1)
40
+ sexp_processor (~> 3.0)
41
+ sexp_processor (3.0.9)
29
42
  sinatra (1.3.1)
30
43
  rack (~> 1.3, >= 1.3.4)
31
44
  rack-protection (~> 1.1, >= 1.1.2)
32
45
  tilt (~> 1.3, >= 1.3.3)
46
+ slop (2.1.0)
33
47
  thor (0.14.6)
34
48
  tilt (1.3.3)
35
49
 
@@ -37,7 +51,9 @@ PLATFORMS
37
51
  ruby
38
52
 
39
53
  DEPENDENCIES
54
+ bundler (~> 1.1.rc)
40
55
  guard-rspec
56
+ pry
41
57
  rack-block!
42
58
  rack-test (> 0)
43
59
  rake (> 0)
data/README.md CHANGED
@@ -78,7 +78,8 @@ No doubt it depends on `rack` (>= 1.3).
78
78
  use Rack::Block do
79
79
  bot_access do
80
80
  path '/secret/*' do
81
- double { Dummy.new # is a Rack-compatible app }
81
+ # TheDummy is a Rack-compatible app
82
+ double { TheDummy.new }
82
83
  end
83
84
  end
84
85
  end
data/Rakefile CHANGED
@@ -16,4 +16,10 @@ begin
16
16
  rescue LoadError
17
17
  end
18
18
 
19
-
19
+ desc "running pry console with rack-block gem and console helpers loaded"
20
+ task :pry do
21
+ $LOAD_PATH.unshift('./lib')
22
+ require 'pry'
23
+ require 'rack-block'
24
+ Pry.start
25
+ end
@@ -17,6 +17,7 @@ module Rack
17
17
  @app = app
18
18
  end
19
19
 
20
+ attr_reader :app
20
21
  attr_accessor :ua_matchers, :ip_matchers
21
22
 
22
23
  def call(env)
@@ -69,7 +69,7 @@ module Rack::Block::DSL
69
69
 
70
70
  def do_dummy_app(req, app_proc, opts={})
71
71
  case app_proc.arity
72
- when 0
72
+ when -1, 0
73
73
  return app_proc.call.call(req.env)
74
74
  else
75
75
  return app_proc.call(req.env)
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Block
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_runtime_dependency "rack", '>= 1.3'
22
22
 
23
+ s.add_development_dependency "bundler", '~> 1.1.rc'
24
+ s.add_development_dependency "pry"
23
25
  s.add_development_dependency "rake", '> 0'
24
26
  s.add_development_dependency "rspec", '>= 2'
25
27
  s.add_development_dependency "rack-test", '> 0'
@@ -12,3 +12,12 @@ require 'rack/builder'
12
12
  def mock_app(&block)
13
13
  @app = Rack::Builder.new(&block)
14
14
  end
15
+
16
+ if RUBY_VERSION < '1.9'
17
+ require 'sinatra/base'
18
+ class DummySinatra < Sinatra::Base
19
+ get '/' do
20
+ "This is a dummy access to: #{request.path_info}"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/mock_app_helper')
3
+
4
+ describe "Passing through accesses" do
5
+ describe "Normal browser's access" do
6
+
7
+ it "should pass the server response" do
8
+ mock_app {
9
+ use Rack::Block do
10
+ bot_access do
11
+ halt 404
12
+ end
13
+ end
14
+ run DEFAULT_APP
15
+ }
16
+
17
+ header "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)"
18
+ ['/', '/any', '/path/blocked'].each do |path|
19
+ get path
20
+ last_response.should be_ok
21
+ last_response.body.should match /It is summer/
22
+ end
23
+ end
24
+ end
25
+ end
@@ -62,12 +62,16 @@ describe "Response value verbs" do
62
62
 
63
63
  context 'doubling application' do
64
64
  require 'sinatra/base'
65
- let :dummy do
66
- Class.new(Sinatra::Base) do
67
- get '/' do
68
- "This is a dummy access to: #{request.path_info}"
65
+ if RUBY_VERSION >= '1.9'
66
+ let :dummy do
67
+ Class.new(Sinatra::Base) do
68
+ get '/' do
69
+ "This is a dummy access to: #{request.path_info}"
70
+ end
69
71
  end
70
72
  end
73
+ else
74
+ let(:dummy) { DummySinatra }
71
75
  end
72
76
 
73
77
  it 'can point access to a dummy application' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-24 00:00:00.000000000Z
12
+ date: 2012-01-31 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &85009500 !ruby/object:Gem::Requirement
16
+ requirement: &72148790 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,32 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *85009500
24
+ version_requirements: *72148790
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &72148500 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.rc
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *72148500
36
+ - !ruby/object:Gem::Dependency
37
+ name: pry
38
+ requirement: &72148210 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *72148210
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: rake
27
- requirement: &85009210 !ruby/object:Gem::Requirement
49
+ requirement: &72147600 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ! '>'
@@ -32,10 +54,10 @@ dependencies:
32
54
  version: '0'
33
55
  type: :development
34
56
  prerelease: false
35
- version_requirements: *85009210
57
+ version_requirements: *72147600
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: rspec
38
- requirement: &85008940 !ruby/object:Gem::Requirement
60
+ requirement: &72147090 !ruby/object:Gem::Requirement
39
61
  none: false
40
62
  requirements:
41
63
  - - ! '>='
@@ -43,10 +65,10 @@ dependencies:
43
65
  version: '2'
44
66
  type: :development
45
67
  prerelease: false
46
- version_requirements: *85008940
68
+ version_requirements: *72147090
47
69
  - !ruby/object:Gem::Dependency
48
70
  name: rack-test
49
- requirement: &85008680 !ruby/object:Gem::Requirement
71
+ requirement: &72141630 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ! '>'
@@ -54,10 +76,10 @@ dependencies:
54
76
  version: '0'
55
77
  type: :development
56
78
  prerelease: false
57
- version_requirements: *85008680
79
+ version_requirements: *72141630
58
80
  - !ruby/object:Gem::Dependency
59
81
  name: sinatra
60
- requirement: &85008300 !ruby/object:Gem::Requirement
82
+ requirement: &72141270 !ruby/object:Gem::Requirement
61
83
  none: false
62
84
  requirements:
63
85
  - - ! '>'
@@ -65,10 +87,10 @@ dependencies:
65
87
  version: '1.0'
66
88
  type: :development
67
89
  prerelease: false
68
- version_requirements: *85008300
90
+ version_requirements: *72141270
69
91
  - !ruby/object:Gem::Dependency
70
92
  name: guard-rspec
71
- requirement: &85008070 !ruby/object:Gem::Requirement
93
+ requirement: &72140870 !ruby/object:Gem::Requirement
72
94
  none: false
73
95
  requirements:
74
96
  - - ! '>='
@@ -76,7 +98,7 @@ dependencies:
76
98
  version: '0'
77
99
  type: :development
78
100
  prerelease: false
79
- version_requirements: *85008070
101
+ version_requirements: *72140870
80
102
  description: A rack middleware for controlling accesses by search bot or not, remote
81
103
  ip address, etc.
82
104
  email:
@@ -108,6 +130,7 @@ files:
108
130
  - spec/integrations/ip_blocking_spec.rb
109
131
  - spec/integrations/mock_app_helper.rb
110
132
  - spec/integrations/mock_app_works_spec.rb
133
+ - spec/integrations/normally_passes_access.rb
111
134
  - spec/integrations/path_matching_spec.rb
112
135
  - spec/integrations/response_verbs_spec.rb
113
136
  - spec/integrations/ua_blocking_spec.rb