firewall_constraint 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,17 +14,17 @@ Or:
14
14
  config/routes.rb:
15
15
 
16
16
  get 'dummy/index' => 'dummy#index'
17
- get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint::Constraint.new
17
+ get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint.new
18
18
 
19
- constraints FirewallConstraint::Constraint.new do
19
+ constraints FirewallConstraint.new do
20
20
  get 'dummy/blocked_by_block' => 'dummy#blocked_by_block'
21
21
  end
22
22
 
23
- constraints FirewallConstraint::Constraint.new(['127.0.0.1']) do
23
+ constraints FirewallConstraint.new(['127.0.0.1']) do
24
24
  get 'dummy/blocked_by_dynamic' => 'dummy#blocked_by_dynamic'
25
25
  end
26
26
 
27
- constraints FirewallConstraint::Constraint.new(Proc.new{['127.0.0.1']}) do
27
+ constraints FirewallConstraint.new(Proc.new{['127.0.0.1']}) do
28
28
  get 'dummy/blocked_by_proc'
29
29
  end
30
30
 
@@ -41,4 +41,4 @@ config/firewall_constraint.yml:
41
41
 
42
42
  You should be able to do DB-based whitelisting using the Proc whitelisting and an activerecord lookup or something similar to:
43
43
 
44
- constraints FirewallConstraint::Constraint.new(Proc.new{ValidIps.all.map{|x| x.ip}})
44
+ constraints FirewallConstraint.new(Proc.new{ValidIps.all.map{|x| x.ip}})
@@ -1,3 +1,3 @@
1
1
  module FirewallConstraint
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -6,11 +6,9 @@ module FirewallConstraint
6
6
  @ips = ips
7
7
  else
8
8
  ips = [ips].flatten
9
- @config = !ips.empty? ? ips :
9
+ config = !ips.empty? ? ips :
10
10
  YAML.load_file(Rails.root.join('config','firewall_constraint.yml'))[Rails.env]
11
-
12
-
13
- @ips = @config
11
+ @ips = config
14
12
  end
15
13
  end
16
14
 
@@ -40,4 +38,8 @@ module FirewallConstraint
40
38
  @ips.respond_to?(:call) ? @ips.call : @ips
41
39
  end
42
40
  end
41
+
42
+ def self.new(*args)
43
+ Constraint.new(*args)
44
+ end
43
45
  end
@@ -1,22 +1,22 @@
1
1
  RailsApp::Application.routes.draw do
2
2
  get 'dummy/index' => 'dummy#index'
3
- get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint::Constraint.new
3
+ get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint.new
4
4
 
5
- constraints FirewallConstraint::Constraint.new do
5
+ constraints FirewallConstraint.new do
6
6
  get 'dummy/blocked_by_block' => 'dummy#blocked_by_block'
7
7
  end
8
8
 
9
- constraints FirewallConstraint::Constraint.new(['127.0.0.1']) do
9
+ constraints FirewallConstraint.new(['127.0.0.1']) do
10
10
  get 'dummy/blocked_by_dynamic' => 'dummy#blocked_by_dynamic'
11
11
  end
12
12
 
13
13
  root :to => 'dummy#index'
14
14
 
15
- constraints FirewallConstraint::Constraint.new('fe80::d69a:20ff:fe0d:45fe') do
15
+ constraints FirewallConstraint.new('fe80::d69a:20ff:fe0d:45fe') do
16
16
  get 'dummy/blocked_by_ipv6'
17
17
  end
18
18
 
19
- constraints FirewallConstraint::Constraint.new(Proc.new{['127.0.0.1']}) do
19
+ constraints FirewallConstraint.new(Proc.new{['127.0.0.1']}) do
20
20
  get 'dummy/blocked_by_proc'
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firewall_constraint
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Auclair
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-20 00:00:00 Z
18
+ date: 2012-03-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails