human_routes 0.0.5 → 0.0.6

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
  SHA256:
3
- metadata.gz: 3c9732c44671356336d93d93f66551dc7ac4f05e430b0abe73cbff5d4aa32fe9
4
- data.tar.gz: ec8df768c2dfbdea30fd6e020545fc9df04669da1236c1266877a4046e987589
3
+ metadata.gz: 599c1d4f7022f37dd7a8c87f89e01480c95ea8f04d89137034139d87beabd8a5
4
+ data.tar.gz: e26db1816cc2b383938b5f2adf7e5d6c1955c8d25996c0913a2bb7def1c8f61e
5
5
  SHA512:
6
- metadata.gz: 1c66820fb3a6224c242ce241f7d9256946e96d4c27e855b7b5ef5548e7a8ad2c91b036faf6897c2442bb0d33ca6b5889d6e865de8dca5ba85430713f36afc32f
7
- data.tar.gz: 594bbc22352cd07cc313768f7768c308f1f965763d4ed6da2d773ef2b7132e76aba914c95f8fc6413a4335467e2f7ec6e590d30df777601be4d11daaec8bf496
6
+ metadata.gz: af48d012d17e2c1525a524c68e14e6a72f8626fd4804d9a9252b923850547bf39eefcfe54966410ef5fe1619f3c510d92cd0271691e9e29c43ad6c4a02193849
7
+ data.tar.gz: 789d18466d195a4afb4490567a38ad8c72d0f489b9485ffbb3a9c3cbcd2b09f63a58f49a5968b366ea07a28fca126ca191b663f5d1a43768c1d20b4fd08371c7
data/README.md CHANGED
@@ -159,6 +159,24 @@ Rails.application.routes.draw do
159
159
  end
160
160
  ```
161
161
 
162
+ For nested paths, you can use `:parent`:
163
+
164
+ ```ruby
165
+ Rails.application.routes.draw do
166
+ route :posts do
167
+ all
168
+ end
169
+
170
+ route :comments, parent: "posts/:post_id" do
171
+ remove #=> /posts/:post_id/comments/:id/remove
172
+ list #=> /posts/:post_id/comments
173
+
174
+ # or
175
+ all
176
+ end
177
+ end
178
+ ```
179
+
162
180
  ## Development
163
181
 
164
182
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -180,7 +180,16 @@ module HumanRoutes
180
180
  .merge(route_options)
181
181
 
182
182
  path = args.first || path_for(segment, route_options)
183
- path = path.to_s.dasherize
183
+
184
+ path = [
185
+ route_options[:parent].to_s.split("/"),
186
+ path.to_s.split("/")
187
+ ].flatten.compact
188
+
189
+ path = path.map do |s|
190
+ s.start_with?(":") ? s : s.dasherize
191
+ end.join("/")
192
+
184
193
  name = route_options.delete(:as) { default_name.underscore.tr("/", "_") }
185
194
 
186
195
  route_options.delete(:bare)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HumanRoutes
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-08 00:00:00.000000000 Z
11
+ date: 2022-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.3.3
170
+ rubygems_version: 3.3.17
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: I say no to REST for client-facing urls.