bullet_train-super_scaffolding 1.6.35 → 1.6.37

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: 044dbfb0828cf00ca12e975d7b49769c555636666e64a16ac4d0fc05db19c4d7
4
- data.tar.gz: e77bce7fdde5eb6fd3e5a3598bab8520bcf8c37b21a78de734aed69692d7f132
3
+ metadata.gz: a7d33a69bc377b790693e058b4d06a16026a2ecf5f1bbba4ce901062fbedf6ea
4
+ data.tar.gz: 75848676aa75f7e19fb8d52d6310ea7570ea7aa60ae488efab004fb72dfa1870
5
5
  SHA512:
6
- metadata.gz: 5aa17cc571a64107afc56007743dc5c14b5192dc021dee371684fcd21fcd50a3b302fef4e73261979769df0bb652a2fb0b9a9750adc21e219330483e7161b4d1
7
- data.tar.gz: 9b4e70dcb0af3243235372a36cd42acd9ea655246829fd927af7ecad450fbd195a64a1b453724d08464e65ec251c694fcf09371f0545e66f27c4bc308c5a873b
6
+ metadata.gz: cd629420914dfa91d04f4b7c244a6c37f615c1135c19233743a174ec51e01107806ba2b7eed3b085f5ac32003b11b55fb4d377e256314dcbfd40723362d36609
7
+ data.tar.gz: 96f3b2a3e70ddf0700d87da31f0098531845ef941260ce8866ec44dd3620e6fb6b3a677baad8e8c2575ff9bf9db73b4b00898cd529cf9ce40343ca3dde5858d3
@@ -38,7 +38,7 @@ module BulletTrain
38
38
 
39
39
  unless @options["skip-migration-generation"]
40
40
  attributes_without_options = attributes.map { |attribute| attribute.gsub(/{.*}$/, "") }
41
- attributes_without_id = attributes_without_options.map { |attribute| attribute.gsub(/_id$/, "") }
41
+ attributes_without_id = attributes_without_options.map { |attribute| attribute.delete_suffix("_id") }
42
42
  attributes_with_references = attributes_without_id.map { |attribute| attribute + ":references" }
43
43
 
44
44
  generation_command = "bin/rails generate model #{child} #{attributes_with_references.join(" ")}"
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.6.35"
3
+ VERSION = "1.6.37"
4
4
  end
5
5
  end
@@ -90,11 +90,11 @@ class Scaffolding::Attribute
90
90
  end
91
91
 
92
92
  def name_without_id
93
- name.gsub(/_id$/, "")
93
+ name.delete_suffix("_id")
94
94
  end
95
95
 
96
96
  def name_without_ids
97
- name.gsub(/_ids$/, "").pluralize
97
+ name.delete_suffix("_ids").pluralize
98
98
  end
99
99
 
100
100
  def name_without_id_suffix
@@ -316,6 +316,9 @@ class Scaffolding::RoutesFileManipulator
316
316
 
317
317
  within = find_or_create_namespaces(base_namespaces)
318
318
 
319
+ # Add any concerns passed as options.
320
+ add_concern(:sortable) if transformer_options["sortable"]
321
+
319
322
  # e.g. Project and Projects::Deliverable
320
323
  if parent_namespaces.empty? && child_namespaces.any? && parent_resource == child_namespaces.first
321
324
 
@@ -352,9 +355,13 @@ class Scaffolding::RoutesFileManipulator
352
355
  child_namespaces_without_parent = child_namespaces.dup
353
356
  child_namespaces_without_parent.shift
354
357
  deeply_nested_within = find_or_create_namespaces(child_namespaces_without_parent, scope_within)
355
- find_or_create_resource([child_resource], options: "shallow: false", within: deeply_nested_within)
358
+ routing_options = "shallow: false"
359
+ routing_options += ", #{formatted_concerns}" if formatted_concerns
360
+ find_or_create_resource([child_resource], options: routing_options, within: deeply_nested_within)
356
361
  else
357
- find_or_create_resource([child_resource], options: "only: collection_actions", within: scope_within)
362
+ routing_options = "only: collection_actions"
363
+ routing_options += ", #{formatted_concerns}" if formatted_concerns
364
+ find_or_create_resource([child_resource], options: routing_options, within: scope_within)
358
365
 
359
366
  # namespace :projects do
360
367
  # resources :deliverables, except: collection_actions
@@ -364,7 +371,9 @@ class Scaffolding::RoutesFileManipulator
364
371
  # because namespaces with the same name as the resource can exist on the same level.
365
372
  parent_block_start = Scaffolding::BlockManipulator.find_block_parent(parent_within, lines)
366
373
  namespace_line_within = find_or_create_namespaces(child_namespaces, parent_block_start)
367
- find_or_create_resource([child_resource], options: "except: collection_actions", within: namespace_line_within)
374
+ routing_options = "except: collection_actions"
375
+ routing_options += ", #{formatted_concerns}" if formatted_concerns
376
+ find_or_create_resource([child_resource], options: routing_options, within: namespace_line_within)
368
377
  unless find_namespaces(child_namespaces, within)[child_namespaces.last]
369
378
  raise "tried to insert `namespace :#{child_namespaces.last}` but it seems we failed"
370
379
  end
@@ -377,7 +386,7 @@ class Scaffolding::RoutesFileManipulator
377
386
  # resources :deliverables
378
387
  # end
379
388
  top_parent_namespace = find_namespaces(parent_namespaces, within)[parent_namespaces.first]
380
- find_or_create_resource(child_namespaces + [child_resource], within: top_parent_namespace)
389
+ find_or_create_resource(child_namespaces + [child_resource], options: formatted_concerns, within: top_parent_namespace)
381
390
 
382
391
  # resources :projects_deliverables, path: 'projects/deliverables' do
383
392
  # resources :objectives
@@ -394,7 +403,6 @@ class Scaffolding::RoutesFileManipulator
394
403
  within = find_or_convert_resource_block(parent_resource, options: "except: collection_actions", within: within)
395
404
  end
396
405
 
397
- add_concern(:sortable) if transformer_options["sortable"]
398
406
  find_or_create_resource(child_namespaces + [child_resource], options: formatted_concerns, within: within)
399
407
 
400
408
  end
@@ -130,9 +130,9 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
130
130
  attribute_options ||= {}
131
131
  unless attribute_options[:vanilla]
132
132
  name_without_id = if name.match?(/_id$/)
133
- name.gsub(/_id$/, "")
133
+ name.delete_suffix("_id")
134
134
  elsif name.match?(/_ids$/)
135
- name.gsub(/_ids$/, "")
135
+ name.delete_suffix("_ids")
136
136
  end
137
137
 
138
138
  attribute_options[:class_name] ||= name_without_id.classify
@@ -1,12 +1,2 @@
1
1
  namespace :bullet_train do
2
- desc "Next-level code generation"
3
- task :super_scaffolding, [:all_options] => :environment do |t, arguments|
4
- ARGV.pop while ARGV.any?
5
-
6
- arguments[:all_options]&.split&.each do |argument|
7
- ARGV.push(argument)
8
- end
9
-
10
- BulletTrain::SuperScaffolding::Runner.new.run
11
- end
12
2
  end
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.35
4
+ version: 1.6.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-01 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard