bullet_train-super_scaffolding 1.6.8 → 1.6.9

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: 83562ede1a8ba63e0c7ce22d2ad4b847966bad0c1cd9b768aa7eec899587181d
4
- data.tar.gz: 403160c7f8f5fe3250c8c2874272d9db05c95a52a38c516a206746f4180df8be
3
+ metadata.gz: bdb72d4e418e35117006cbc2bde82d94fa388771c2eec71444abcf51d793f985
4
+ data.tar.gz: 63d86d99b7520dfb506c2d78608fbf2bf4448ef40c89123006c5dd45c4240fcb
5
5
  SHA512:
6
- metadata.gz: 1c6c3a03a78758c8347c1a3a1c841382ab55b486453bf7008358c6c42d6afff6159cf5f150f9cfba1684c91ade3b2c32f3ea26f766832badd2684fc3e875445d
7
- data.tar.gz: d019a81d9810e3586ba355e011dd1fbf19779963ca049b4df88a65ccb274387c488e7e74e4593f31fc20335e46359b86019f7b418336bfb71e1e0d83fe30b317
6
+ metadata.gz: dc8a4ba76d763ad6167e20c742a357376e54a0de4a9f9e345891c29435dbac3ac506be1d7da29920d872c44a9accec0de9d76b9d50732e6f607d398b3ddb076c
7
+ data.tar.gz: cafb5f4eb58dc6e1f074302ef885fccb313459b56998f360621822212d48cf18c5eabd67db694baee157261d9921859a534ee372a097ee5e55da9d83ef3cf20a
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.6.8"
3
+ VERSION = "1.6.9"
4
4
  end
5
5
  end
@@ -326,7 +326,7 @@ class Scaffolding::RoutesFileManipulator
326
326
  within = find_or_create_namespaces(base_namespaces)
327
327
 
328
328
  # e.g. Project and Projects::Deliverable
329
- if parent_namespaces.empty? && child_namespaces.one? && parent_resource == child_namespaces.first
329
+ if parent_namespaces.empty? && child_namespaces.any? && parent_resource == child_namespaces.first
330
330
 
331
331
  # resources :projects do
332
332
  # scope module: 'projects' do
@@ -343,19 +343,40 @@ class Scaffolding::RoutesFileManipulator
343
343
  scope_within = insert([line, "end"], parent_within)
344
344
  end
345
345
 
346
- find_or_create_resource([child_resource], options: "only: collection_actions", within: scope_within)
347
-
348
- # namespace :projects do
349
- # resources :deliverables, except: collection_actions
350
- # end
351
-
352
- # We want to see if there are any namespaces one level above the parent itself,
353
- # because namespaces with the same name as the resource can exist on the same level.
354
- parent_block_start = Scaffolding::BlockManipulator.find_block_parent(parent_within, lines)
355
- namespace_line_within = find_or_create_namespaces(child_namespaces, parent_block_start)
356
- find_or_create_resource([child_resource], options: "except: collection_actions", within: namespace_line_within)
357
- unless find_namespaces(child_namespaces, within)[child_namespaces.last]
358
- raise "tried to insert `namespace :#{child_namespaces.last}` but it seems we failed"
346
+ if child_namespaces.size > 1
347
+ # If a model has multiple namespaces, we have to account for that here.
348
+ # For example, this creates the :issues namespace here when `SendAction`
349
+ # and the `parent_resource` is `newsletters`.
350
+ #
351
+ # resources :newsletters do
352
+ # scope module: 'newsletters' do
353
+ # resources :issues, only: collection_actions
354
+ # namespace :issues do
355
+ # resources :send_actions, shallow: false
356
+ # end
357
+ # end
358
+ # end
359
+
360
+ # TODO: We should be able to just do `child_namespaces.shift`.
361
+ child_namespaces_without_parent = child_namespaces.dup
362
+ child_namespaces_without_parent.shift
363
+ deeply_nested_within = find_or_create_namespaces(child_namespaces_without_parent, scope_within)
364
+ find_or_create_resource([child_resource], options: "shallow: false", within: deeply_nested_within)
365
+ else
366
+ find_or_create_resource([child_resource], options: "only: collection_actions", within: scope_within)
367
+
368
+ # namespace :projects do
369
+ # resources :deliverables, except: collection_actions
370
+ # end
371
+
372
+ # We want to see if there are any namespaces one level above the parent itself,
373
+ # because namespaces with the same name as the resource can exist on the same level.
374
+ parent_block_start = Scaffolding::BlockManipulator.find_block_parent(parent_within, lines)
375
+ namespace_line_within = find_or_create_namespaces(child_namespaces, parent_block_start)
376
+ find_or_create_resource([child_resource], options: "except: collection_actions", within: namespace_line_within)
377
+ unless find_namespaces(child_namespaces, within)[child_namespaces.last]
378
+ raise "tried to insert `namespace :#{child_namespaces.last}` but it seems we failed"
379
+ end
359
380
  end
360
381
 
361
382
  # e.g. Projects::Deliverable and Objective Under It, Abstract::Concept and Concrete::Thing
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-super_scaffolding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.8
4
+ version: 1.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-01 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard