strong_routes 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c94e9edd16d3195d9bc6cfb4a2d58e986c7b1ff6
|
4
|
+
data.tar.gz: 75842ddaa1c581b70a15373f543a42d95ec9dde3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcb15910abd4dbc75cc4b5b6a5492505be1bb50984985f40c100bcae664f91c532d47ff1abd367c9174c2717d0e08a6ee83e958c8fb69bf1b3c050d5d9e0d3cd
|
7
|
+
data.tar.gz: f3d7fc3c1fe71768563c663069466721df0d70abad327dac1386fb9bd77d5f08744ff4e3d30c8051dfc847d3d49b99b16b4b7a871e2b0b25e2e9e003d231b108
|
@@ -27,7 +27,7 @@ module StrongRoutes
|
|
27
27
|
# Convert the path strings into match data objects, capturing all segments
|
28
28
|
# except optional ones (e.g. :format).
|
29
29
|
def matches
|
30
|
-
matches = paths.map { |path| path.match(/\A
|
30
|
+
matches = paths.map { |path| path.match(/\A(?<path>[-:\w\/]+)\/*.*\Z/) }
|
31
31
|
matches.compact!
|
32
32
|
matches.uniq!
|
33
33
|
matches
|
@@ -5,8 +5,9 @@ module StrongRoutes
|
|
5
5
|
super(route)
|
6
6
|
else
|
7
7
|
route = map_dynamic_segments(route)
|
8
|
+
route = "/#{route}" unless route =~ /\A\//
|
8
9
|
escaped_route = Regexp.escape(route)
|
9
|
-
super(/\A
|
10
|
+
super(/\A#{route}/i)
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
@@ -16,16 +17,7 @@ module StrongRoutes
|
|
16
17
|
# becomes /.*/users/.*)
|
17
18
|
#
|
18
19
|
def map_dynamic_segments(route)
|
19
|
-
|
20
|
-
segments.map! do |segment|
|
21
|
-
if segment =~ /:/
|
22
|
-
'.*'
|
23
|
-
else
|
24
|
-
segment
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
segments.join('/')
|
20
|
+
route.to_s.gsub(/:\w+/, '.*')
|
29
21
|
end
|
30
22
|
end
|
31
23
|
end
|
@@ -6,18 +6,19 @@ require 'strong_routes/rails/route_mapper'
|
|
6
6
|
describe ::StrongRoutes::Rails::RouteMapper do
|
7
7
|
let(:paths) {
|
8
8
|
[
|
9
|
-
'
|
10
|
-
'
|
11
|
-
'comments/:id
|
12
|
-
'
|
13
|
-
'posts/:id
|
14
|
-
'posts/:
|
15
|
-
'posts/:post_id/comments
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'users
|
20
|
-
'users/:user_id/posts
|
9
|
+
'/',
|
10
|
+
'/bar/sandwich',
|
11
|
+
'/comments/:id',
|
12
|
+
'/comments/:id/edit',
|
13
|
+
'/posts/:id',
|
14
|
+
'/posts/:id/edit',
|
15
|
+
'/posts/:post_id/comments',
|
16
|
+
'/posts/:post_id/comments/new',
|
17
|
+
'/trading-post',
|
18
|
+
'/user_posts/:id',
|
19
|
+
'/users',
|
20
|
+
'/users/:user_id/posts',
|
21
|
+
'/users/:user_id/posts/new',
|
21
22
|
]
|
22
23
|
}
|
23
24
|
let(:route_set) {
|
@@ -33,6 +34,8 @@ describe ::StrongRoutes::Rails::RouteMapper do
|
|
33
34
|
|
34
35
|
get 'bar/sandwich', :to => 'users#index'
|
35
36
|
get 'trading-post', :to => 'posts#show'
|
37
|
+
|
38
|
+
root :to => 'posts#index'
|
36
39
|
end
|
37
40
|
route_set
|
38
41
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strong_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hutchison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|