bullet_train-super_scaffolding 1.6.7 → 1.6.9

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: 4daf211d2bdfa4cdfed707713e865468f546e99e33217454a3a344623e323b24
4
- data.tar.gz: 73a5b7db62adb169f77eab98ebf2480b23a38eaa26d365c98262b34501e8fff3
3
+ metadata.gz: bdb72d4e418e35117006cbc2bde82d94fa388771c2eec71444abcf51d793f985
4
+ data.tar.gz: 63d86d99b7520dfb506c2d78608fbf2bf4448ef40c89123006c5dd45c4240fcb
5
5
  SHA512:
6
- metadata.gz: b1f123b55cd71806b43e84da083b8db0c86e655e26d831937651c20c3be179b0d9190fc46a9f72fcc601441b9dd1984352fc06d5e15d88830971999acdcdf6c5
7
- data.tar.gz: 21f3158dbbc7af72e1d6610c93e5daeb96e1c1e9f26882dc2acb57231981e9fc8f534c35e592d502bef9306b8c618a21e8f19bc94df54e43f9a81577766c0829
6
+ metadata.gz: dc8a4ba76d763ad6167e20c742a357376e54a0de4a9f9e345891c29435dbac3ac506be1d7da29920d872c44a9accec0de9d76b9d50732e6f607d398b3ddb076c
7
+ data.tar.gz: cafb5f4eb58dc6e1f074302ef885fccb313459b56998f360621822212d48cf18c5eabd67db694baee157261d9921859a534ee372a097ee5e55da9d83ef3cf20a
@@ -29,6 +29,14 @@ module BulletTrain
29
29
 
30
30
  child = argv[0]
31
31
  parents = argv[1] ? argv[1].split(",") : []
32
+
33
+ # Raise an error if the developer skipped adding the parent and went straight to the attributes.
34
+ if FIELD_PARTIALS.keys.map(&:to_s).include?(parents.first.split(":").last)
35
+ puts "It looks like you forgot to add the model's parent to your scaffolding command.".red
36
+ puts "Add the parent name after the model and try again.".red
37
+ exit
38
+ end
39
+
32
40
  parents = parents.map(&:classify).uniq
33
41
  parent = parents.first
34
42
  child_parts = child.split("::")
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.6.7"
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.7
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-10-23 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