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 +4 -4
- data/lib/bullet_train/super_scaffolding/scaffolders/join_model_scaffolder.rb +1 -1
- data/lib/bullet_train/super_scaffolding/version.rb +1 -1
- data/lib/scaffolding/attribute.rb +2 -2
- data/lib/scaffolding/routes_file_manipulator.rb +13 -5
- data/lib/scaffolding/script.rb +2 -2
- data/lib/tasks/bullet_train/super_scaffolding_tasks.rake +0 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7d33a69bc377b790693e058b4d06a16026a2ecf5f1bbba4ce901062fbedf6ea
|
4
|
+
data.tar.gz: 75848676aa75f7e19fb8d52d6310ea7570ea7aa60ae488efab004fb72dfa1870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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(" ")}"
|
@@ -90,11 +90,11 @@ class Scaffolding::Attribute
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def name_without_id
|
93
|
-
name.
|
93
|
+
name.delete_suffix("_id")
|
94
94
|
end
|
95
95
|
|
96
96
|
def name_without_ids
|
97
|
-
name.
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/scaffolding/script.rb
CHANGED
@@ -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.
|
133
|
+
name.delete_suffix("_id")
|
134
134
|
elsif name.match?(/_ids$/)
|
135
|
-
name.
|
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.
|
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-
|
11
|
+
date: 2024-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|