bullet_train-super_scaffolding 1.0.38 → 1.0.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb +1 -0
- data/lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb +1 -1
- data/lib/bullet_train/super_scaffolding/scaffolders/crud_scaffolder.rb +4 -4
- data/lib/bullet_train/super_scaffolding/version.rb +1 -1
- data/lib/scaffolding/block_manipulator.rb +37 -45
- data/lib/scaffolding/file_manipulator.rb +18 -11
- data/lib/scaffolding/routes_file_manipulator.rb +15 -16
- data/lib/scaffolding/script.rb +4 -4
- data/lib/scaffolding/transformer.rb +25 -8
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5b3c39c20e852d11ae216cb1bb8e8686e935345954b5bb89fa4662e931aa9f0
|
4
|
+
data.tar.gz: c5c7884aacf4fad0073b2802913b2521c985d4059648e5036cef76dec826ba86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c67a6fc6aa0325cded01535276152126a8339ce2ea321b6e3e31eecb0a969dccbe6b69077b239941239720ce7cc616dd28272c17d6aa6dd1048984d5464aeba
|
7
|
+
data.tar.gz: 5591f573ad8cea3aed70e079bf6293f8764de12dbbf333f17e4c0f67ec295812ab986fe6fd04e1e9a64066125be944508bea381c2a2d145e1a9a52be6017efc8
|
@@ -72,6 +72,7 @@
|
|
72
72
|
<% end %>
|
73
73
|
<% end %>
|
74
74
|
|
75
|
+
<%# 🚅 super scaffolding will insert new targets one parent action model buttons above this line. %>
|
75
76
|
<%# 🚅 super scaffolding will insert new bulk action model buttons above this line. %>
|
76
77
|
<%= render "shared/bulk_action_select" %>
|
77
78
|
|
@@ -36,14 +36,14 @@ module BulletTrain
|
|
36
36
|
parent = parents.first
|
37
37
|
|
38
38
|
unless parents.include?("Team")
|
39
|
-
raise "Parents for #{child} should trace back to the Team model, but Team wasn't provided. Please confirm that all of the parents tracing back to the Team model are present and try again.\n"
|
40
|
-
"E.g.:\n"
|
41
|
-
"rails g model Section page:references title:text body:text\n"
|
39
|
+
raise "Parents for #{child} should trace back to the Team model, but Team wasn't provided. Please confirm that all of the parents tracing back to the Team model are present and try again.\n" \
|
40
|
+
"E.g.:\n" \
|
41
|
+
"rails g model Section page:references title:text body:text\n" \
|
42
42
|
"bin/super-scaffold crud Section Page,Site,Team title:text body:text\n"
|
43
43
|
end
|
44
44
|
|
45
45
|
# get all the attributes.
|
46
|
-
attributes = argv[2
|
46
|
+
attributes = argv[2..]
|
47
47
|
|
48
48
|
check_required_options_for_attributes("crud", attributes, child, parent)
|
49
49
|
|
@@ -1,27 +1,22 @@
|
|
1
|
-
|
2
|
-
attr_accessor :lines
|
3
|
-
|
4
|
-
def initialize(filepath)
|
5
|
-
@filepath = filepath
|
6
|
-
@lines = File.readlines(filepath)
|
7
|
-
end
|
1
|
+
require "scaffolding/file_manipulator"
|
8
2
|
|
3
|
+
module Scaffolding::BlockManipulator
|
9
4
|
#
|
10
5
|
# Wrap a block of ruby code with another block on the outside.
|
11
6
|
#
|
12
7
|
# @param [String] `starting` A string to search for at the start of the block. Eg "<%= updates_for context, collection do"
|
13
8
|
# @param [Array] `with` An array with two String elements. The text that should wrap the block. Eg ["<%= action_model_select_controller do %>", "<% end %>"]
|
14
9
|
#
|
15
|
-
def wrap_block(starting:, with:)
|
10
|
+
def self.wrap_block(starting:, with:, lines:)
|
16
11
|
with[0] += "\n" unless with[0].match?(/\n$/)
|
17
12
|
with[1] += "\n" unless with[1].match?(/\n$/)
|
18
|
-
starting_line = find_block_start(starting)
|
19
|
-
end_line = find_block_end(starting_from: starting_line, lines:
|
13
|
+
starting_line = find_block_start(starting_from: starting, lines: lines)
|
14
|
+
end_line = find_block_end(starting_from: starting_line, lines: lines)
|
20
15
|
|
21
16
|
final = []
|
22
17
|
block_indent = ""
|
23
18
|
spacer = " "
|
24
|
-
|
19
|
+
lines.each_with_index do |line, index|
|
25
20
|
line += "\n" unless line.match?(/\n$/)
|
26
21
|
if index < starting_line
|
27
22
|
final << line
|
@@ -39,80 +34,77 @@ class Scaffolding::BlockManipulator
|
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
unless
|
44
|
-
|
37
|
+
lines = final
|
38
|
+
unless lines.last.match?(/\n$/)
|
39
|
+
lines[-1] += "\n"
|
45
40
|
end
|
41
|
+
lines
|
46
42
|
end
|
47
43
|
|
48
|
-
def insert(content, within: nil, after: nil, before: nil, after_block: nil, append: false)
|
44
|
+
def self.insert(content, lines:, within: nil, after: nil, before: nil, after_block: nil, append: false)
|
49
45
|
# Search for before like we do after, we'll just inject before it.
|
50
46
|
after ||= before
|
51
47
|
|
52
48
|
# If within is given, find the start and end lines of the block
|
53
49
|
content += "\n" unless content.match?(/\n$/)
|
54
50
|
start_line = 0
|
55
|
-
end_line =
|
51
|
+
end_line = lines.count - 1
|
56
52
|
if within.present?
|
57
|
-
start_line = find_block_start(within)
|
58
|
-
end_line = find_block_end(starting_from: start_line, lines:
|
53
|
+
start_line = find_block_start(starting_from: within, lines: lines)
|
54
|
+
end_line = find_block_end(starting_from: start_line, lines: lines)
|
59
55
|
# start_line += 1 # ensure we actually insert the content _within_ the given block
|
60
56
|
# end_line += 1 if end_line == start_line
|
61
57
|
end
|
62
58
|
if after_block.present?
|
63
|
-
block_start = find_block_start(after_block)
|
64
|
-
block_end = find_block_end(starting_from: block_start, lines:
|
59
|
+
block_start = find_block_start(starting_from: after_block, lines: lines)
|
60
|
+
block_end = find_block_end(starting_from: block_start, lines: lines)
|
65
61
|
start_line = block_end
|
66
|
-
end_line =
|
62
|
+
end_line = lines.count - 1
|
67
63
|
end
|
68
64
|
index = start_line
|
69
65
|
match = false
|
70
66
|
while index < end_line && !match
|
71
|
-
line =
|
67
|
+
line = lines[index]
|
72
68
|
if after.nil? || line.match?(after)
|
73
69
|
unless append
|
74
70
|
match = true
|
75
71
|
# We adjust the injection point if we really wanted to insert before.
|
76
|
-
insert_line(content, index - (before ? 1 : 0))
|
72
|
+
lines = insert_line(content, index - (before ? 1 : 0), lines)
|
77
73
|
end
|
78
74
|
end
|
79
75
|
index += 1
|
80
76
|
end
|
81
77
|
|
82
|
-
return if match
|
78
|
+
return lines if match
|
83
79
|
|
84
80
|
# Match should always be false here.
|
85
81
|
if append && !match
|
86
|
-
insert_line(content, index - 1)
|
82
|
+
lines = insert_line(content, index - 1, lines)
|
87
83
|
end
|
84
|
+
lines
|
88
85
|
end
|
89
86
|
|
90
|
-
def insert_line(content, insert_at_index)
|
87
|
+
def self.insert_line(content, insert_at_index, lines)
|
91
88
|
content += "\n" unless content.match?(/\n$/)
|
92
89
|
final = []
|
93
|
-
|
90
|
+
lines.each_with_index do |line, index|
|
94
91
|
indent = line.match(/^\s*/).to_s
|
95
92
|
final << line
|
96
93
|
if index == insert_at_index
|
97
94
|
final << indent + content
|
98
95
|
end
|
99
96
|
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
def insert_block(block_content, after_block:)
|
104
|
-
block_start = find_block_start(after_block)
|
105
|
-
block_end = find_block_end(starting_from: block_start, lines: @lines)
|
106
|
-
insert_line(block_content[0], block_end)
|
107
|
-
insert_line(block_content[1], block_end + 1)
|
97
|
+
final
|
108
98
|
end
|
109
99
|
|
110
|
-
|
111
|
-
|
112
|
-
|
100
|
+
def self.insert_block(block_content, after_block:, lines:)
|
101
|
+
block_start = find_block_start(starting_from: after_block, lines: lines)
|
102
|
+
block_end = find_block_end(starting_from: block_start, lines: lines)
|
103
|
+
lines = insert_line(block_content[0], block_end, lines)
|
104
|
+
insert_line(block_content[1], block_end + 1, lines)
|
113
105
|
end
|
114
106
|
|
115
|
-
def find_block_parent(starting_line_number, lines)
|
107
|
+
def self.find_block_parent(starting_line_number, lines)
|
116
108
|
return nil unless indentation_of(starting_line_number, lines)
|
117
109
|
cursor = starting_line_number
|
118
110
|
while cursor >= 0
|
@@ -124,11 +116,11 @@ class Scaffolding::BlockManipulator
|
|
124
116
|
nil
|
125
117
|
end
|
126
118
|
|
127
|
-
def find_block_start(
|
128
|
-
matcher = Regexp.escape(
|
119
|
+
def self.find_block_start(starting_from:, lines:)
|
120
|
+
matcher = Regexp.escape(starting_from)
|
129
121
|
starting_line = 0
|
130
122
|
|
131
|
-
|
123
|
+
lines.each_with_index do |line, index|
|
132
124
|
if line.match?(matcher)
|
133
125
|
starting_line = index
|
134
126
|
break
|
@@ -137,7 +129,7 @@ class Scaffolding::BlockManipulator
|
|
137
129
|
starting_line
|
138
130
|
end
|
139
131
|
|
140
|
-
def find_block_end(starting_from:, lines:)
|
132
|
+
def self.find_block_end(starting_from:, lines:)
|
141
133
|
# This loop was previously in the RoutesFileManipulator.
|
142
134
|
lines.each_with_index do |line, line_number|
|
143
135
|
next unless line_number > starting_from
|
@@ -148,7 +140,7 @@ class Scaffolding::BlockManipulator
|
|
148
140
|
|
149
141
|
depth = 0
|
150
142
|
current_line = starting_from
|
151
|
-
|
143
|
+
lines[starting_from..lines.count].each_with_index do |line, index|
|
152
144
|
current_line = starting_from + index
|
153
145
|
depth += 1 if line.match?(/\s*<%.+ do .*%>/)
|
154
146
|
depth += 1 if line.match?(/\s*<% if .*%>/)
|
@@ -162,7 +154,7 @@ class Scaffolding::BlockManipulator
|
|
162
154
|
# TODO: We shouldn't need this second argument, but since
|
163
155
|
# we have `lines` here and in the RoutesFileManipulator,
|
164
156
|
# the lines diverge from one another when we edit them individually.
|
165
|
-
def indentation_of(line_number, lines)
|
157
|
+
def self.indentation_of(line_number, lines)
|
166
158
|
lines[line_number].match(/^( +)/)[1]
|
167
159
|
rescue
|
168
160
|
nil
|
@@ -3,22 +3,25 @@ require "scaffolding/block_manipulator"
|
|
3
3
|
# TODO: If we move this and the BlockManipulator into their own gems,
|
4
4
|
# we can probably call these methods with something shorter without `Scaffolding::`.
|
5
5
|
module Scaffolding::FileManipulator
|
6
|
-
|
7
|
-
|
8
|
-
lines_within(lines, within, block_manipulator).each_with_index do |line, line_number|
|
6
|
+
def self.find(lines, needle, within = nil)
|
7
|
+
lines_within(lines, within).each_with_index do |line, line_number|
|
9
8
|
return (within + (within ? 1 : 0) + line_number) if line.match?(needle)
|
10
9
|
end
|
11
10
|
nil
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
def self.lines_within(lines, within, block_manipulator)
|
13
|
+
def self.lines_within(lines, within)
|
16
14
|
return lines unless within
|
17
|
-
lines[(within + 1)..(
|
15
|
+
lines[(within + 1)..(Scaffolding::BlockManipulator.find_block_end(starting_from: within, lines: lines) + 1)]
|
18
16
|
end
|
19
17
|
|
20
|
-
def self.replace_line_in_file(file, content, in_place_of)
|
21
|
-
|
18
|
+
def self.replace_line_in_file(file, content, in_place_of, options = {})
|
19
|
+
begin
|
20
|
+
target_file_content = File.read(file)
|
21
|
+
rescue Errno::ENOENT => _
|
22
|
+
puts "Couldn't find '#{file}'".red unless options[:suppress_could_not_find]
|
23
|
+
return false
|
24
|
+
end
|
22
25
|
|
23
26
|
if target_file_content.include?(content)
|
24
27
|
puts "No need to update '#{file}'. It already has '#{content}'."
|
@@ -62,10 +65,14 @@ module Scaffolding::FileManipulator
|
|
62
65
|
File.write(file, new_lines.join)
|
63
66
|
end
|
64
67
|
|
65
|
-
def self.write(file_name, lines)
|
68
|
+
def self.write(file_name, lines, strip: true)
|
66
69
|
puts "Updating '#{file_name}'."
|
67
|
-
|
68
|
-
|
70
|
+
if strip
|
71
|
+
File.open(file_name, "w+") do |file|
|
72
|
+
file.puts(lines.join.strip + "\n")
|
73
|
+
end
|
74
|
+
else
|
75
|
+
File.write(file_name, lines.join)
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "scaffolding/block_manipulator"
|
2
2
|
|
3
3
|
class Scaffolding::RoutesFileManipulator
|
4
|
-
attr_accessor :child, :parent, :lines, :transformer_options
|
4
|
+
attr_accessor :child, :parent, :lines, :transformer_options
|
5
5
|
|
6
6
|
def initialize(filename, child, parent, transformer_options = {})
|
7
7
|
self.child = child
|
@@ -9,7 +9,6 @@ class Scaffolding::RoutesFileManipulator
|
|
9
9
|
@filename = filename
|
10
10
|
self.lines = File.readlines(@filename)
|
11
11
|
self.transformer_options = transformer_options
|
12
|
-
self.block_manipulator = Scaffolding::BlockManipulator.new(@filename)
|
13
12
|
end
|
14
13
|
|
15
14
|
def child_parts
|
@@ -68,7 +67,7 @@ class Scaffolding::RoutesFileManipulator
|
|
68
67
|
def find_namespaces(namespaces, within = nil)
|
69
68
|
namespaces = namespaces.dup
|
70
69
|
results = {}
|
71
|
-
block_end =
|
70
|
+
block_end = Scaffolding::BlockManipulator.find_block_end(starting_from: within, lines: lines) if within
|
72
71
|
lines.each_with_index do |line, line_number|
|
73
72
|
if within
|
74
73
|
next unless line_number > within
|
@@ -86,7 +85,7 @@ class Scaffolding::RoutesFileManipulator
|
|
86
85
|
def insert_before(new_lines, line_number, options = {})
|
87
86
|
options[:indent] ||= false
|
88
87
|
before = lines[0..(line_number - 1)]
|
89
|
-
new_lines = new_lines.map { |line| (
|
88
|
+
new_lines = new_lines.map { |line| (Scaffolding::BlockManipulator.indentation_of(line_number, lines) + (options[:indent] ? " " : "") + line).gsub(/\s+$/, "") + "\n" }
|
90
89
|
after = lines[line_number..]
|
91
90
|
self.lines = before + (options[:prepend_newline] ? ["\n"] : []) + new_lines + after
|
92
91
|
end
|
@@ -95,7 +94,7 @@ class Scaffolding::RoutesFileManipulator
|
|
95
94
|
def insert_after(new_lines, line_number, options = {})
|
96
95
|
options[:indent] ||= false
|
97
96
|
before = lines[0..line_number]
|
98
|
-
new_lines = new_lines.map { |line| (
|
97
|
+
new_lines = new_lines.map { |line| (Scaffolding::BlockManipulator.indentation_of(line_number, lines) + (options[:indent] ? " " : "") + line).gsub(/\s+$/, "") + "\n" }
|
99
98
|
after = lines[(line_number + 1)..]
|
100
99
|
self.lines = before + new_lines + (options[:append_newline] ? ["\n"] : []) + after
|
101
100
|
end
|
@@ -104,7 +103,7 @@ class Scaffolding::RoutesFileManipulator
|
|
104
103
|
namespace_lines = find_namespaces(namespaces, within)
|
105
104
|
if namespace_lines[namespaces.last]
|
106
105
|
block_start = namespace_lines[namespaces.last]
|
107
|
-
insertion_point =
|
106
|
+
insertion_point = Scaffolding::BlockManipulator.find_block_end(starting_from: block_start, lines: lines)
|
108
107
|
insert_before(new_lines, insertion_point, indent: true, prepend_newline: (insertion_point > block_start + 1))
|
109
108
|
else
|
110
109
|
raise "we weren't able to insert the following lines into the namespace block for #{namespaces.join(" -> ")}:\n\n#{new_lines.join("\n")}"
|
@@ -172,7 +171,7 @@ class Scaffolding::RoutesFileManipulator
|
|
172
171
|
within = namespace_lines[namespaces.last]
|
173
172
|
end
|
174
173
|
|
175
|
-
Scaffolding::FileManipulator.lines_within(lines, within
|
174
|
+
Scaffolding::FileManipulator.lines_within(lines, within).each_with_index do |line, line_number|
|
176
175
|
# + 2 because line_number starts from 0, and within starts one line after
|
177
176
|
actual_line_number = (within + line_number + 2)
|
178
177
|
|
@@ -226,7 +225,7 @@ class Scaffolding::RoutesFileManipulator
|
|
226
225
|
# However, will not find namespace blocks inside namespace blocks.
|
227
226
|
def top_level_namespace_block_lines(within)
|
228
227
|
local_namespace_blocks = []
|
229
|
-
Scaffolding::FileManipulator.lines_within(lines, within
|
228
|
+
Scaffolding::FileManipulator.lines_within(lines, within).each do |line|
|
230
229
|
# i.e. - Retrieve "foo" from "namespace :foo do"
|
231
230
|
match_data = line.match(/(\s*namespace\s:)(.*)(\sdo$)/)
|
232
231
|
|
@@ -236,7 +235,7 @@ class Scaffolding::RoutesFileManipulator
|
|
236
235
|
namespace_name = match_data[2]
|
237
236
|
local_namespace = find_namespaces([namespace_name], within)
|
238
237
|
starting_line_number = local_namespace[namespace_name]
|
239
|
-
local_namespace_block = ((starting_line_number + 1)..(
|
238
|
+
local_namespace_block = ((starting_line_number + 1)..(Scaffolding::BlockManipulator.find_block_end(starting_from: starting_line_number, lines: lines) + 1))
|
240
239
|
|
241
240
|
if local_namespace_blocks.empty?
|
242
241
|
local_namespace_blocks << local_namespace_block
|
@@ -263,11 +262,11 @@ class Scaffolding::RoutesFileManipulator
|
|
263
262
|
def namespace_blocks_directly_under_parent(within)
|
264
263
|
blocks = []
|
265
264
|
if lines[within].match?(/do$/)
|
266
|
-
parent_indentation_size =
|
267
|
-
within_block_end =
|
265
|
+
parent_indentation_size = Scaffolding::BlockManipulator.indentation_of(within, lines).length
|
266
|
+
within_block_end = Scaffolding::BlockManipulator.find_block_end(starting_from: within, lines: lines)
|
268
267
|
within.upto(within_block_end) do |line_number|
|
269
268
|
if lines[line_number].match?(/^#{" " * (parent_indentation_size + 2)}namespace/)
|
270
|
-
namespace_block_lines = line_number..
|
269
|
+
namespace_block_lines = line_number..Scaffolding::BlockManipulator.find_block_end(starting_from: line_number, lines: lines)
|
271
270
|
blocks << namespace_block_lines
|
272
271
|
end
|
273
272
|
end
|
@@ -301,7 +300,7 @@ class Scaffolding::RoutesFileManipulator
|
|
301
300
|
|
302
301
|
# TODO: Remove this and use the BlockManipulator
|
303
302
|
def insert(lines_to_add, within)
|
304
|
-
insertion_line =
|
303
|
+
insertion_line = Scaffolding::BlockManipulator.find_block_end(starting_from: within, lines: lines)
|
305
304
|
result_line = insertion_line
|
306
305
|
unless insertion_line == within + 1
|
307
306
|
# only put the extra space if we're adding this line after a block
|
@@ -333,7 +332,7 @@ class Scaffolding::RoutesFileManipulator
|
|
333
332
|
# add the new resource within that namespace.
|
334
333
|
line = "scope module: '#{parent_resource}' do"
|
335
334
|
# TODO you haven't tested this yet.
|
336
|
-
unless (scope_within = Scaffolding::FileManipulator.find(lines, /#{line}/, parent_within
|
335
|
+
unless (scope_within = Scaffolding::FileManipulator.find(lines, /#{line}/, parent_within))
|
337
336
|
scope_within = insert([line, "end"], parent_within)
|
338
337
|
end
|
339
338
|
|
@@ -345,7 +344,7 @@ class Scaffolding::RoutesFileManipulator
|
|
345
344
|
|
346
345
|
# We want to see if there are any namespaces one level above the parent itself,
|
347
346
|
# because namespaces with the same name as the resource can exist on the same level.
|
348
|
-
parent_block_start =
|
347
|
+
parent_block_start = Scaffolding::BlockManipulator.find_block_parent(parent_within, lines)
|
349
348
|
namespace_line_within = find_or_create_namespaces(child_namespaces, parent_block_start)
|
350
349
|
find_or_create_resource([child_resource], options: "except: collection_actions", within: namespace_line_within)
|
351
350
|
unless find_namespaces(child_namespaces, within)[child_namespaces.last]
|
@@ -364,7 +363,7 @@ class Scaffolding::RoutesFileManipulator
|
|
364
363
|
# resources :projects_deliverables, path: 'projects/deliverables' do
|
365
364
|
# resources :objectives
|
366
365
|
# end
|
367
|
-
block_parent_within =
|
366
|
+
block_parent_within = Scaffolding::BlockManipulator.find_block_parent(top_parent_namespace, lines)
|
368
367
|
parent_namespaces_and_resource = (parent_namespaces + [parent_resource]).join("_")
|
369
368
|
parent_within = find_or_create_resource_block([parent_namespaces_and_resource], options: "path: '#{parent_namespaces_and_resource.tr("_", "/")}'", within: block_parent_within)
|
370
369
|
find_or_create_resource(child_namespaces + [child_resource], within: parent_within)
|
data/lib/scaffolding/script.rb
CHANGED
@@ -15,7 +15,7 @@ argv = []
|
|
15
15
|
@options = {}
|
16
16
|
ARGV.each do |arg|
|
17
17
|
if arg[0..1] == "--"
|
18
|
-
arg = arg[2
|
18
|
+
arg = arg[2..]
|
19
19
|
if arg.split("=").count > 1
|
20
20
|
@options[arg.split("=")[0]] = arg.split("=")[1]
|
21
21
|
else
|
@@ -38,9 +38,9 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
|
|
38
38
|
type = parts.join(":")
|
39
39
|
|
40
40
|
unless Scaffolding.valid_attribute_type?(type)
|
41
|
-
raise "You have entered an invalid attribute type: #{type}. General data types are used when creating new models, but Bullet Train "
|
42
|
-
|
43
|
-
|
41
|
+
raise "You have entered an invalid attribute type: #{type}. General data types are used when creating new models, but Bullet Train " \
|
42
|
+
"uses field partials when Super Scaffolding, i.e. - `name:text_field` as opposed to `name:string`. " \
|
43
|
+
"Please refer to the Field Partial documentation to view which attribute types are available."
|
44
44
|
end
|
45
45
|
|
46
46
|
# extract any options they passed in with the field.
|
@@ -18,10 +18,12 @@ class Scaffolding::Transformer
|
|
18
18
|
def approved_by_reference(approved_by_index_name)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def permit_parents
|
22
|
+
["Team"]
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
+
def last_joinable_parent
|
26
|
+
"Team"
|
25
27
|
end
|
26
28
|
|
27
29
|
def update_action_models_abstract_class(targets_n)
|
@@ -351,7 +353,7 @@ class Scaffolding::Transformer
|
|
351
353
|
file = transform_string(file)
|
352
354
|
# we specifically don't transform the content, we assume a builder function created this content.
|
353
355
|
in_place_of = transform_string(in_place_of)
|
354
|
-
Scaffolding::FileManipulator.replace_line_in_file(file, content, in_place_of)
|
356
|
+
Scaffolding::FileManipulator.replace_line_in_file(file, content, in_place_of, suppress_could_not_find: suppress_could_not_find)
|
355
357
|
end
|
356
358
|
|
357
359
|
# if class_name isn't specified, we use `child`.
|
@@ -1045,14 +1047,14 @@ class Scaffolding::Transformer
|
|
1045
1047
|
|
1046
1048
|
assertion = case type
|
1047
1049
|
when "date_field"
|
1048
|
-
"
|
1050
|
+
"assert_equal_or_nil Date.parse(tangible_thing_data['#{name}']), tangible_thing.#{name}"
|
1049
1051
|
when "date_and_time_field"
|
1050
|
-
"
|
1052
|
+
"assert_equal_or_nil DateTime.parse(tangible_thing_data['#{name}']), tangible_thing.#{name}"
|
1051
1053
|
when "file_field"
|
1052
1054
|
# TODO: If we want to use Cloudinary to handle our files, we should make sure we're getting a URL.
|
1053
1055
|
"assert tangible_thing_data['#{name}'].match?('foo.txt') unless response.status == 201"
|
1054
1056
|
else
|
1055
|
-
"
|
1057
|
+
"assert_equal_or_nil tangible_thing_data['#{name}'], tangible_thing.#{name}"
|
1056
1058
|
end
|
1057
1059
|
scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb", assertion, RUBY_NEW_FIELDS_HOOK, prepend: true)
|
1058
1060
|
end
|
@@ -1083,6 +1085,20 @@ class Scaffolding::Transformer
|
|
1083
1085
|
scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb", "assert_equal @tangible_thing.#{name}, #{attribute_assignment}", RUBY_EVEN_MORE_NEW_FIELDS_HOOK, prepend: true)
|
1084
1086
|
end
|
1085
1087
|
end
|
1088
|
+
|
1089
|
+
# We need to update our new Tangible Thing's
|
1090
|
+
# jbuilder files if it's scoped under "account".
|
1091
|
+
# TODO: Should we run this if `namespace.present?` instead?
|
1092
|
+
if namespace == "account"
|
1093
|
+
target_string = "#{transform_string("scaffolding/completely_concrete/tangible_things")}/#{transform_string("tangible_thing")}"
|
1094
|
+
replacement_string = "#{namespace}/#{target_string}"
|
1095
|
+
[
|
1096
|
+
"app/views/account/completely_concrete/tangible_things/index.json.jbuilder",
|
1097
|
+
"app/views/account/completely_concrete/tangible_things/show.json.jbuilder"
|
1098
|
+
].each do |path|
|
1099
|
+
scaffold_replace_line_in_file(path, replacement_string, target_string)
|
1100
|
+
end
|
1101
|
+
end
|
1086
1102
|
end
|
1087
1103
|
|
1088
1104
|
#
|
@@ -1420,8 +1436,9 @@ class Scaffolding::Transformer
|
|
1420
1436
|
|
1421
1437
|
begin
|
1422
1438
|
routes_manipulator.apply([routes_namespace])
|
1423
|
-
rescue
|
1424
|
-
|
1439
|
+
rescue => e
|
1440
|
+
puts "We weren't able to automatically add your `#{routes_namespace}` routes for you. In theory this should be very rare, so if you could reach out on Slack, you could probably provide context that will help us fix whatever the problem was. In the meantime, to add the routes manually, we've got a guide at https://blog.bullettrain.co/nested-namespaced-rails-routing-examples/ .".send(:yellow)
|
1441
|
+
raise e
|
1425
1442
|
end
|
1426
1443
|
|
1427
1444
|
Scaffolding::FileManipulator.write("config/routes.rb", routes_manipulator.lines)
|
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.0.
|
4
|
+
version: 1.0.41
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -178,7 +178,7 @@ licenses:
|
|
178
178
|
metadata:
|
179
179
|
homepage_uri: https://github.com/bullet-train-co/bullet_train-super_scaffolding
|
180
180
|
source_code_uri: https://github.com/bullet-train-co/bullet_train-super_scaffolding
|
181
|
-
post_install_message:
|
181
|
+
post_install_message:
|
182
182
|
rdoc_options: []
|
183
183
|
require_paths:
|
184
184
|
- lib
|
@@ -193,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
rubygems_version: 3.
|
197
|
-
signing_key:
|
196
|
+
rubygems_version: 3.3.7
|
197
|
+
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Bullet Train Super Scaffolding
|
200
200
|
test_files: []
|