route_matcher 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in route_matcher.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,37 @@
1
+ # TODO: This works only on a shared cache
2
+ # like one development server or production with a memcacheserver
3
+ # NOT on production with few mongrels and an in-memory-cache)
4
+
5
+ module RouteMatcher
6
+ class UrlMatcher
7
+
8
+ def initialize(name, &block)
9
+ @name, @block = name, block
10
+ Rails.cache.write(cache_key, Time.now, :unless_exists => true)
11
+ end
12
+
13
+ def matches?(request)
14
+ reload if @timestamp != get_stamp
15
+ @urls.include?(request.path.downcase) #TODO: decide if we need to downcase...
16
+ end
17
+
18
+ def reload
19
+ @urls = @block.call
20
+ @timestamp = get_stamp
21
+ end
22
+
23
+ def self.mark_dirty(name)
24
+ Rails.cache.write(cache_key(name), Time.now)
25
+ end
26
+
27
+ private
28
+ def cache_key(name=nil)
29
+ "route_matcher_urls_#{name || @name}"
30
+ end
31
+
32
+ def get_stamp
33
+ Rails.cache.read(cache_key)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module RouteMatcher
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "route_matcher/url_matcher"
2
+ require "route_matcher/version"
3
+
4
+ module RouteMatcher
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "route_matcher/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "route_matcher"
7
+ s.version = RouteMatcher::VERSION
8
+ s.authors = ["Raymond Vellener", "Jaap van der Plas"]
9
+ s.email = ["raymond@brightin.nl", "jaap@brightin.nl"]
10
+ s.homepage = "http://brightin.nl"
11
+ s.summary = %q{ Constraint object to allow only certain url's }
12
+ s.description = %q{ Constraint object to allow only certain url's }
13
+
14
+ s.rubyforge_project = "route_matcher"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: route_matcher
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Raymond Vellener
9
+ - Jaap van der Plas
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-06-03 00:00:00 Z
15
+ dependencies: []
16
+
17
+ description: " Constraint object to allow only certain url's "
18
+ email:
19
+ - raymond@brightin.nl
20
+ - jaap@brightin.nl
21
+ executables: []
22
+
23
+ extensions: []
24
+
25
+ extra_rdoc_files: []
26
+
27
+ files:
28
+ - .gitignore
29
+ - Gemfile
30
+ - Rakefile
31
+ - lib/route_matcher.rb
32
+ - lib/route_matcher/url_matcher.rb
33
+ - lib/route_matcher/version.rb
34
+ - route_matcher.gemspec
35
+ homepage: http://brightin.nl
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ requirements: []
56
+
57
+ rubyforge_project: route_matcher
58
+ rubygems_version: 1.8.5
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Constraint object to allow only certain url's
62
+ test_files: []
63
+