app-routes 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app-routes.rb +19 -20
- metadata +4 -4
data/lib/app-routes.rb
CHANGED
@@ -13,33 +13,32 @@ module AppRoutes
|
|
13
13
|
|
14
14
|
result = nil
|
15
15
|
|
16
|
-
@route.
|
16
|
+
route = @route.detect {|key, block| request.match(key) }
|
17
|
+
|
18
|
+
if route then
|
19
|
+
key, block = route
|
17
20
|
match = request.match(key)
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
@params[:captures] = *args
|
22
|
-
|
23
|
-
if @route[key][:s] then
|
24
|
-
raw_params = @route[key][:s].gsub(':','').match(key).captures
|
25
|
-
splat, raw_params2 = raw_params.each_with_index.partition {|x,i| x == '/*'}
|
26
|
-
@params[:splat] = splat.map {|x,i| v = args[i]; args.delete_at(i); v}
|
27
|
-
@params.merge!(Hash[raw_params2.map{|x,i| x.to_sym}.zip(args)])
|
28
|
-
end
|
22
|
+
args = match.captures
|
23
|
+
@params[:captures] = *args
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
if @route[key][:s] then
|
26
|
+
raw_params = @route[key][:s].gsub(':','').match(key).captures
|
27
|
+
splat, raw_params2 = raw_params.each_with_index.partition {|x,i| x == '/*'}
|
28
|
+
@params[:splat] = splat.map {|x,i| v = args[i]; args.delete_at(i); v}
|
29
|
+
@params.merge!(Hash[raw_params2.map{|x,i| x.to_sym}.zip(args)])
|
30
|
+
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
32
|
+
begin
|
33
|
+
result = @route[key][:block].call *args
|
34
|
+
rescue Exception => e
|
38
35
|
|
39
|
-
|
36
|
+
err_label = e.message + " :: \n" + e.backtrace.join("\n")
|
37
|
+
puts err_label
|
38
|
+
"app-routes error: " + ($!).to_s
|
40
39
|
end
|
40
|
+
|
41
41
|
end
|
42
|
-
|
43
42
|
result
|
44
43
|
end
|
45
44
|
|
metadata
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
name: app-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.8
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
|
7
|
+
authors:
|
8
|
+
- James Robertson
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-02-21 00:00:00 +00:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|