route_matcher 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,16 +8,26 @@ module RouteMatcher
8
8
 
9
9
  def initialize(name, &block)
10
10
  @name, @block = name, block
11
- Rails.cache.write(CACHE_KEY % @name), Time.now, :unless_exists => true)
11
+ Rails.cache.write(CACHE_KEY % @name, Time.now, :unless_exists => true)
12
12
  end
13
13
 
14
14
  def matches?(request)
15
15
  reload if @timestamp != get_stamp
16
- @urls.include?(request.path.downcase) #TODO: decide if we need to downcase...
16
+
17
+ path = request.path.downcase
18
+ case @matcher
19
+ when Array
20
+ @matcher.include? path
21
+ when String
22
+ @matcher = Regexp.new(@matcher)
23
+ @matcher =~ request.path
24
+ when Regexp
25
+ @matcher =~ request.path
26
+ end
17
27
  end
18
28
 
19
29
  def reload
20
- @urls = @block.call
30
+ @matcher = @block.call
21
31
  @timestamp = get_stamp
22
32
  end
23
33
 
@@ -1,3 +1,3 @@
1
1
  module RouteMatcher
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: route_matcher
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
4
+ prerelease:
5
+ version: 0.0.5
10
6
  platform: ruby
11
7
  authors:
12
8
  - Raymond Vellener
@@ -15,8 +11,7 @@ autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
13
 
18
- date: 2011-06-04 00:00:00 +02:00
19
- default_executable:
14
+ date: 2011-06-04 00:00:00 Z
20
15
  dependencies: []
21
16
 
22
17
  description: " Constraint object to allow only certain url's "
@@ -37,7 +32,6 @@ files:
37
32
  - lib/route_matcher/url_matcher.rb
38
33
  - lib/route_matcher/version.rb
39
34
  - route_matcher.gemspec
40
- has_rdoc: true
41
35
  homepage: http://brightin.nl
42
36
  licenses: []
43
37
 
@@ -51,21 +45,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
45
  requirements:
52
46
  - - ">="
53
47
  - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
48
  version: "0"
57
49
  required_rubygems_version: !ruby/object:Gem::Requirement
58
50
  none: false
59
51
  requirements:
60
52
  - - ">="
61
53
  - !ruby/object:Gem::Version
62
- segments:
63
- - 0
64
54
  version: "0"
65
55
  requirements: []
66
56
 
67
57
  rubyforge_project: route_matcher
68
- rubygems_version: 1.3.7
58
+ rubygems_version: 1.8.5
69
59
  signing_key:
70
60
  specification_version: 3
71
61
  summary: Constraint object to allow only certain url's