routing-filter 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -1
- data/README.markdown +1 -0
- data/lib/routing_filter/filters/locale.rb +28 -11
- data/lib/routing_filter/version.rb +1 -1
- metadata +19 -19
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -43,6 +43,14 @@ module RoutingFilter
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
|
47
|
+
attr_reader :exclude
|
48
|
+
def initialize(*args)
|
49
|
+
super
|
50
|
+
@exclude = options[:exclude]
|
51
|
+
end
|
52
|
+
|
53
|
+
|
46
54
|
def around_recognize(path, env, &block)
|
47
55
|
locale = extract_segment!(self.class.locales_pattern, path) # remove the locale from the beginning of the path
|
48
56
|
yield.tap do |params| # invoke the given block (calls more filters and finally routing)
|
@@ -59,23 +67,32 @@ module RoutingFilter
|
|
59
67
|
|
60
68
|
args << params
|
61
69
|
|
62
|
-
yield.tap do |result|
|
63
|
-
|
70
|
+
yield.tap do |result|
|
71
|
+
url = result.is_a?(Array) ? result.first : result
|
72
|
+
prepend_segment!(result, locale) if prepend_locale?(locale) && !excluded?(url)
|
64
73
|
end
|
65
74
|
end
|
66
75
|
|
67
76
|
protected
|
77
|
+
def valid_locale?(locale)
|
78
|
+
locale && self.class.locales.include?(locale.to_sym)
|
79
|
+
end
|
68
80
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
def default_locale?(locale)
|
74
|
-
locale && locale.to_sym == I18n.default_locale.to_sym
|
75
|
-
end
|
81
|
+
def default_locale?(locale)
|
82
|
+
locale && locale.to_sym == I18n.default_locale.to_sym
|
83
|
+
end
|
76
84
|
|
77
|
-
|
78
|
-
|
85
|
+
def prepend_locale?(locale)
|
86
|
+
locale && (self.class.include_default_locale? || !default_locale?(locale))
|
87
|
+
end
|
88
|
+
|
89
|
+
def excluded?(url)
|
90
|
+
case exclude
|
91
|
+
when Regexp
|
92
|
+
url =~ exclude
|
93
|
+
when Proc
|
94
|
+
exclude.call(url)
|
79
95
|
end
|
96
|
+
end
|
80
97
|
end
|
81
98
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routing-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.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: 2012-
|
12
|
+
date: 2012-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156259340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156259340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: appraisal
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156258620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156258620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: i18n
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156257900 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156257900
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: test_declarative
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156273620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156273620
|
58
58
|
description: Routing filters wraps around the complex beast that the Rails routing
|
59
59
|
system is, allowing for unseen flexibility and power in Rails URL recognition and
|
60
60
|
generation.
|
@@ -67,19 +67,19 @@ files:
|
|
67
67
|
- README.markdown
|
68
68
|
- MIT-LICENSE
|
69
69
|
- lib/routing/filter.rb
|
70
|
+
- lib/routing-filter.rb
|
71
|
+
- lib/routing_filter/adapters/rails_2.rb
|
72
|
+
- lib/routing_filter/adapters/rails_3.rb
|
73
|
+
- lib/routing_filter/adapters/routers/journey.rb
|
74
|
+
- lib/routing_filter/adapters/routers/rack_mount.rb
|
70
75
|
- lib/routing_filter/chain.rb
|
76
|
+
- lib/routing_filter/filter.rb
|
77
|
+
- lib/routing_filter/filters/extension.rb
|
71
78
|
- lib/routing_filter/filters/locale.rb
|
72
|
-
- lib/routing_filter/filters/uuid.rb
|
73
79
|
- lib/routing_filter/filters/pagination.rb
|
74
|
-
- lib/routing_filter/filters/
|
80
|
+
- lib/routing_filter/filters/uuid.rb
|
75
81
|
- lib/routing_filter/version.rb
|
76
|
-
- lib/routing_filter/filter.rb
|
77
|
-
- lib/routing_filter/adapters/rails_3.rb
|
78
|
-
- lib/routing_filter/adapters/routers/journey.rb
|
79
|
-
- lib/routing_filter/adapters/routers/rack_mount.rb
|
80
|
-
- lib/routing_filter/adapters/rails_2.rb
|
81
82
|
- lib/routing_filter.rb
|
82
|
-
- lib/routing-filter.rb
|
83
83
|
homepage: http://github.com/svenfuchs/routing-filter
|
84
84
|
licenses: []
|
85
85
|
post_install_message:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project: ! '[none]'
|
103
|
-
rubygems_version: 1.8.
|
103
|
+
rubygems_version: 1.8.17
|
104
104
|
signing_key:
|
105
105
|
specification_version: 3
|
106
106
|
summary: Routing filters wraps around the complex beast that the Rails routing system
|