friendly_routes 0.2.0 → 0.3.0
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: 77ed12df2420528a82f7ed13566099b1d72a95e8
|
4
|
+
data.tar.gz: 24b3222a6adc594631e82b6000773b4f373daac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95ab4a5e21c0d7f81b3f3cf3bbb137b776bee0aa59eb8a1f2c381e466b2bddf9a5157556437cadb565316493bd293f0c8da9da9aef6ae53c22514bb0b40548e7
|
7
|
+
data.tar.gz: 6fcc0e2a5ad78d02ce560233d2687d5116d8ca840af4d1684ef638ee5c16602584d5e2a8516f36e0a2c8dcc83ec76f578acb462306cba4cc2fe85d6cf59ffd94
|
data/README.md
CHANGED
@@ -34,10 +34,11 @@ dummies_route.params = [free, category]
|
|
34
34
|
|
35
35
|
friendly_url_for dummies_route, :get # '/:free/:category'
|
36
36
|
|
37
|
-
second_dummies_route = FriendlyRoutes::Route.new(
|
37
|
+
second_dummies_route = FriendlyRoutes::Route.new(controller: :dummies, action: :index)
|
38
38
|
dummies_route.params = [free, 'categories', category]
|
39
39
|
|
40
|
-
friendly_url_for dummies_route, :get # '/:free/categories/:category'
|
40
|
+
friendly_url_for dummies_route, :get, '/' # '/:free/categories/:category'
|
41
|
+
friendly_url_for dummies_route, :get, '/hello/' # '/hello/:free/categories/:category'
|
41
42
|
|
42
43
|
# app/controllers/dummies_controller.rb
|
43
44
|
class DummiesController < ApplicationController
|
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
module FriendlyRoutes
|
4
4
|
module Dispatcher
|
5
|
-
def friendly_url_for(route, method, as: '')
|
5
|
+
def friendly_url_for(route, method, path, as: '', controller: '', action: '')
|
6
6
|
public_send(
|
7
7
|
method,
|
8
|
-
route.path,
|
9
|
-
controller:
|
10
|
-
action:
|
8
|
+
path + route.path,
|
9
|
+
controller: controller,
|
10
|
+
action: action,
|
11
11
|
friendly_route: route,
|
12
12
|
constraints: route.constraints,
|
13
13
|
as: as
|
@@ -2,18 +2,15 @@
|
|
2
2
|
|
3
3
|
module FriendlyRoutes
|
4
4
|
class Route
|
5
|
-
attr_accessor :method, :
|
5
|
+
attr_accessor :method, :params, :prefix
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@original_path = path
|
9
|
-
@controller = controller
|
10
|
-
@action = action
|
7
|
+
def initialize(prefix: 'friendly_routes')
|
11
8
|
@params = []
|
12
9
|
@prefix = prefix
|
13
10
|
end
|
14
11
|
|
15
12
|
def path
|
16
|
-
|
13
|
+
FriendlyRoutes::PrefixedParams.new(@params, @prefix).call
|
17
14
|
end
|
18
15
|
|
19
16
|
def constraints
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Gritsay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|