strong_routes 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d6b1526fd0f847bb4bfda2d3e1dfb1fb236e186
4
- data.tar.gz: 2487bf0af56d8fc1649649d1b5d4f8c46384b890
3
+ metadata.gz: c94e9edd16d3195d9bc6cfb4a2d58e986c7b1ff6
4
+ data.tar.gz: 75842ddaa1c581b70a15373f543a42d95ec9dde3
5
5
  SHA512:
6
- metadata.gz: 65d87b0e55b2d4b91a3d2b977bcceaba2d7c009a4717c793e70eb5677c6d787f1a555061b8312971b5628a8480b30b1a3a1010e2d65361d6d1e83ae646ff035f
7
- data.tar.gz: f98962e0f6bae04d7ac292ff4be989015aac7a6cc7d271687b412edf98bfe95587a917530933b2da957fa495df4ba8ce081dbdc63ca7bcd4b20e34e514973fb3
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\/(?<path>[-:\w\/]+)\/*.*\Z/) }
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\/#{route}/i)
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
- segments = route.to_s.split('/')
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
@@ -1,3 +1,3 @@
1
1
  module StrongRoutes
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  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
- 'bar/sandwich',
10
- 'comments/:id',
11
- 'comments/:id/edit',
12
- 'posts/:id',
13
- 'posts/:id/edit',
14
- 'posts/:post_id/comments',
15
- 'posts/:post_id/comments/new',
16
- 'trading-post',
17
- 'user_posts/:id',
18
- 'users',
19
- 'users/:user_id/posts',
20
- 'users/:user_id/posts/new'
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.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-04 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack