human_routes 0.0.1 → 0.0.2

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
  SHA256:
3
- metadata.gz: 2ad89763d40365e71ad1e2d6ca62e93c9d407cb4342ed0904c1b181338c5a599
4
- data.tar.gz: 076fe95f90963ab455b86559c00c0af7dd0aeb624b2a1605c12ab2cccfbd3418
3
+ metadata.gz: 4cfd4e06db3b929750903be57fb3a372463a25d176b79b61b8a6bf80093a099b
4
+ data.tar.gz: ef6be79a9800bf8aea869c9b6f0f80c29e74479c5e652e2f1650065fd6c67728
5
5
  SHA512:
6
- metadata.gz: 2af45ff4d9f08a645a0c2a367a652579ef43e24bd7bb9ad13db111b6be11b9d0952f0fcd6570797279d467948599d9cd4b92881ba48f44ea41a489d1513baad8
7
- data.tar.gz: 51122db49e0b50327e3f7dd9751e7f4051425386f5ab59b6c1504819d7d4654fa320f1896c4bb05e17d6eef4f324a5d47a5ad9865e8e174974f9f76f11275bee
6
+ metadata.gz: 0e383792de96ae4117d47411b77e92cdfb2f4f8e60e28706cab505ebda709df97df543d9718a6c2575d71943cd7f88867916df01d64f7faca0c34126b5e0b6d9
7
+ data.tar.gz: db912bd53f9433f05823e8bedf9da0f285b00e9263df598bbf49524311d322283861a1b6d1585226ea2030baf83a18e79e761d4f9f033508647401206b711dc9
data/README.md CHANGED
@@ -104,6 +104,13 @@ Rails.application.routes.draw do
104
104
  route :pages, module: "customer" do
105
105
  all
106
106
  end
107
+
108
+ # Additionally, you can use `:name` to give a different name to
109
+ # namespaced controllers. This way routes can be generated using a shallow
110
+ # path instead of the usual `admin/reports`.
111
+ route "admin/reports", name: "reports" do
112
+ all
113
+ end
107
114
  end
108
115
  ```
109
116
 
@@ -10,8 +10,12 @@ module HumanRoutes
10
10
  @options = options
11
11
  end
12
12
 
13
+ def controller_name
14
+ @controller_name ||= options.delete(:name) { controller.to_s }
15
+ end
16
+
13
17
  def singular_controller_name
14
- @singular_controller_name ||= controller.to_s.singularize
18
+ @singular_controller_name ||= controller_name.singularize
15
19
  end
16
20
 
17
21
  def routes
@@ -20,7 +24,7 @@ module HumanRoutes
20
24
 
21
25
  def create(*args)
22
26
  path, name, options = extract_route_args(
23
- default_path: "#{controller}/new",
27
+ default_path: "#{controller_name}/new",
24
28
  default_name: "new_#{singular_controller_name}",
25
29
  args: args
26
30
  )
@@ -48,7 +52,7 @@ module HumanRoutes
48
52
 
49
53
  def update(*args)
50
54
  path, name, options = extract_route_args(
51
- default_path: "#{controller}/:id/edit",
55
+ default_path: "#{controller_name}/:id/edit",
52
56
  default_name: "edit_#{singular_controller_name}",
53
57
  args: args
54
58
  )
@@ -76,7 +80,7 @@ module HumanRoutes
76
80
 
77
81
  def remove(*args)
78
82
  path, name, options = extract_route_args(
79
- default_path: "#{controller}/:id/remove",
83
+ default_path: "#{controller_name}/:id/remove",
80
84
  default_name: "remove_#{singular_controller_name}",
81
85
  args: args
82
86
  )
@@ -104,8 +108,8 @@ module HumanRoutes
104
108
 
105
109
  def list(*args)
106
110
  path, name, options = extract_route_args(
107
- default_path: controller,
108
- default_name: controller,
111
+ default_path: controller_name,
112
+ default_name: controller_name,
109
113
  args: args
110
114
  )
111
115
 
@@ -122,7 +126,7 @@ module HumanRoutes
122
126
 
123
127
  def show(*args)
124
128
  path, name, options = extract_route_args(
125
- default_path: "#{controller}/:id",
129
+ default_path: "#{controller_name}/:id",
126
130
  default_name: singular_controller_name,
127
131
  args: args
128
132
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HumanRoutes
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira