bullet_train-super_scaffolding 1.0.24 → 1.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bt-link +0 -0
- data/app/models/scaffolding/completely_concrete/tangible_thing.rb +2 -0
- data/app/models/scaffolding/completely_concrete/tangible_things/assignment.rb +2 -0
- data/app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb +5 -2
- data/app/views/account/scaffolding/completely_concrete/tangible_things/show.html.erb +1 -0
- data/lib/bullet_train/super_scaffolding/scaffolders/oauth_provider_scaffolder.rb +1 -1
- data/lib/bullet_train/super_scaffolding/version.rb +1 -1
- data/lib/bullet_train/terminal_commands.rb +30 -0
- data/lib/scaffolding/script.rb +2 -0
- data/lib/scaffolding/transformer.rb +67 -14
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9aa5ac0c67b58b810e04c0d3d168029f9f9ef7da7faa3a8e7caa983e9902827
|
4
|
+
data.tar.gz: fc327f125d39b8fa070aa8fa2f0a44e970f76b40582862d5fa9a65f001bc933c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc55ee986f3a46ca5e5ca7b9246cb6de751a08f643a036f75eb2b05ca03da3b077e52c3befe5e75d68b54bdba29598414c10e45be4307e5bfdc72da5e4d94fa
|
7
|
+
data.tar.gz: b73895f7df4bacab8e606077847bfb3b64287e8e79ddfe72a2dd6d244dbe61f6370dcf06d5cdc07d43685b753e1fe7c0f088b9cadad3108289b20edad2f58eef
|
data/.bt-link
ADDED
File without changes
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Scaffolding::CompletelyConcrete::TangibleThing < ApplicationRecord
|
2
2
|
# 🚅 add concerns above.
|
3
3
|
|
4
|
+
# 🚅 add attribute accessors above.
|
5
|
+
|
4
6
|
belongs_to :absolutely_abstract_creative_concept, class_name: "Scaffolding::AbsolutelyAbstract::CreativeConcept"
|
5
7
|
# 🚅 add belongs_to associations above.
|
6
8
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Scaffolding::CompletelyConcrete::TangibleThings::Assignment < ApplicationRecord
|
2
2
|
# 🚅 add concerns above.
|
3
3
|
|
4
|
+
# 🚅 add attribute accessors above.
|
5
|
+
|
4
6
|
belongs_to :tangible_thing, class_name: "Scaffolding::CompletelyConcrete::TangibleThing"
|
5
7
|
belongs_to :membership, class_name: "Membership"
|
6
8
|
# 🚅 add belongs_to associations above.
|
@@ -4,7 +4,10 @@
|
|
4
4
|
<% hide_actions ||= false %>
|
5
5
|
<% hide_back ||= false %>
|
6
6
|
|
7
|
-
|
7
|
+
<% tangible_things = tangible_things.order(:id) unless has_order?(tangible_things) %>
|
8
|
+
<% pagy, tangible_things = pagy(tangible_things, page_param: :tangible_things_page) %>
|
9
|
+
|
10
|
+
<%= render 'account/shared/box', pagy: pagy do |p| %>
|
8
11
|
<% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
|
9
12
|
<% p.content_for :description do %>
|
10
13
|
<%= t(".contexts.#{context.class.name.underscore}.description#{"_empty" unless tangible_things.any?}") %>
|
@@ -69,4 +72,4 @@
|
|
69
72
|
<% end %>
|
70
73
|
<% end %>
|
71
74
|
<% end %>
|
72
|
-
<% end %>
|
75
|
+
<% end %>
|
@@ -15,6 +15,7 @@
|
|
15
15
|
<%= render 'shared/attributes/boolean', attribute: :boolean_button_value %>
|
16
16
|
<%= render 'shared/attributes/option', attribute: :button_value %>
|
17
17
|
<%= render 'shared/attributes/options', attribute: :multiple_button_values %>
|
18
|
+
<%= render 'shared/attributes/code', attribute: :color_picker_value %>
|
18
19
|
<%= render 'shared/attributes/text', attribute: :cloudinary_image_value %>
|
19
20
|
<%= render 'shared/attributes/date', attribute: :date_field_value %>
|
20
21
|
<%= render 'shared/attributes/date_and_time', attribute: :date_and_time_field_value %>
|
@@ -61,7 +61,7 @@ module BulletTrain
|
|
61
61
|
puts "When you find one you like, hover your mouse over it and then come back here and"
|
62
62
|
puts "and enter the name of the icon you want to use."
|
63
63
|
response = STDIN.gets.chomp
|
64
|
-
|
64
|
+
TerminalCommands.open_file_or_link("http://light.pinsupreme.com/icon_fonts_themefy.html")
|
65
65
|
puts ""
|
66
66
|
puts "Did you find an icon you wanted to use? Enter the name here or hit enter to just"
|
67
67
|
puts "use the dollar symbol:"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module TerminalCommands
|
2
|
+
def self.open_file_or_link(file_or_link, options = {})
|
3
|
+
command = if macosx?
|
4
|
+
"open"
|
5
|
+
elsif linux?
|
6
|
+
"xdg-open"
|
7
|
+
end
|
8
|
+
`#{command} #{file_or_link}`
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.os
|
12
|
+
Gem::Platform.local.os
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.macosx?
|
16
|
+
os == macosx
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.linux?
|
20
|
+
os == linux
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.macosx
|
24
|
+
"darwin"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.linux
|
28
|
+
"linux"
|
29
|
+
end
|
30
|
+
end
|
data/lib/scaffolding/script.rb
CHANGED
@@ -23,6 +23,7 @@ class Scaffolding::Transformer
|
|
23
23
|
ENDPOINTS_HOOK = "# 🚅 super scaffolding will mount new endpoints above this line."
|
24
24
|
ERB_NEW_FIELDS_HOOK = "<%#{RUBY_NEW_FIELDS_HOOK} %>"
|
25
25
|
CONCERNS_HOOK = "# 🚅 add concerns above."
|
26
|
+
ATTR_ACCESSORS_HOOK = "# 🚅 add attribute accessors above."
|
26
27
|
BELONGS_TO_HOOK = "# 🚅 add belongs_to associations above."
|
27
28
|
HAS_MANY_HOOK = "# 🚅 add has_many associations above."
|
28
29
|
OAUTH_PROVIDERS_HOOK = "# 🚅 add oauth providers above."
|
@@ -414,6 +415,8 @@ class Scaffolding::Transformer
|
|
414
415
|
before_scaffolding_hooks = <<~RUBY
|
415
416
|
#{CONCERNS_HOOK}
|
416
417
|
|
418
|
+
#{ATTR_ACCESSORS_HOOK}
|
419
|
+
|
417
420
|
RUBY
|
418
421
|
|
419
422
|
after_scaffolding_hooks = <<-RUBY
|
@@ -565,7 +568,7 @@ class Scaffolding::Transformer
|
|
565
568
|
def add_attributes_to_various_views(attributes, scaffolding_options = {})
|
566
569
|
sql_type_to_field_type_mapping = {
|
567
570
|
# 'binary' => '',
|
568
|
-
"boolean" => "
|
571
|
+
"boolean" => "options",
|
569
572
|
"date" => "date_field",
|
570
573
|
"datetime" => "date_and_time_field",
|
571
574
|
"decimal" => "text_field",
|
@@ -631,15 +634,13 @@ class Scaffolding::Transformer
|
|
631
634
|
attribute_partial ||= attribute_options[:attribute] || case type
|
632
635
|
when "trix_editor", "ckeditor"
|
633
636
|
"html"
|
634
|
-
when "buttons", "super_select", "options"
|
635
|
-
if
|
636
|
-
"boolean"
|
637
|
-
elsif is_ids
|
637
|
+
when "buttons", "super_select", "options", "boolean"
|
638
|
+
if is_ids
|
638
639
|
"has_many"
|
639
640
|
elsif is_id
|
640
641
|
"belongs_to"
|
641
642
|
else
|
642
|
-
"option"
|
643
|
+
"option#{"s" if is_multiple}"
|
643
644
|
end
|
644
645
|
when "cloudinary_image"
|
645
646
|
attribute_options[:height] = 200
|
@@ -747,7 +748,7 @@ class Scaffolding::Transformer
|
|
747
748
|
# FORM FIELD
|
748
749
|
#
|
749
750
|
|
750
|
-
unless cli_options["skip-form"]
|
751
|
+
unless cli_options["skip-form"] || attribute_options[:readonly]
|
751
752
|
|
752
753
|
# add `has_rich_text` for trix editor fields.
|
753
754
|
if type == "trix_editor"
|
@@ -768,8 +769,14 @@ class Scaffolding::Transformer
|
|
768
769
|
# add_additional_step :yellow, transform_string("We've added a reference to a `placeholder` to the form for the select or super_select field, but unfortunately earlier versions of the scaffolded locales Yaml don't include a reference to `fields: *fields` under `form`. Please add it, otherwise your form won't be able to locate the appropriate placeholder label.")
|
769
770
|
end
|
770
771
|
|
772
|
+
# TODO: This feels incorrect.
|
773
|
+
# Should we adjust the partials to only use `{multiple: true}` or `html_options: {multiple_true}`?
|
771
774
|
if is_multiple
|
772
|
-
|
775
|
+
if type == "super_select"
|
776
|
+
field_options[:multiple] = "true"
|
777
|
+
else
|
778
|
+
field_attributes[:multiple] = "true"
|
779
|
+
end
|
773
780
|
end
|
774
781
|
|
775
782
|
valid_values = if is_id
|
@@ -912,6 +919,18 @@ class Scaffolding::Transformer
|
|
912
919
|
|
913
920
|
<% end %>
|
914
921
|
|
922
|
+
<% if type == "color_picker" %>
|
923
|
+
options:
|
924
|
+
- '#9C73D2'
|
925
|
+
- '#48CDFE'
|
926
|
+
- '#53F3ED'
|
927
|
+
- '#47E37F'
|
928
|
+
- '#F2593D'
|
929
|
+
- '#F68421'
|
930
|
+
- '#F9DE00'
|
931
|
+
- '#929292'
|
932
|
+
<% end %>
|
933
|
+
|
915
934
|
<% if is_association %>
|
916
935
|
<%= attribute_name %>: *<%= attribute_name %>
|
917
936
|
<% end %>
|
@@ -930,16 +949,19 @@ class Scaffolding::Transformer
|
|
930
949
|
# STRONG PARAMETERS
|
931
950
|
#
|
932
951
|
|
933
|
-
unless cli_options["skip-form"]
|
952
|
+
unless cli_options["skip-form"] || attribute_options[:readonly]
|
934
953
|
|
935
954
|
# add attributes to strong params.
|
936
955
|
[
|
937
956
|
"./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb"
|
938
957
|
].each do |file|
|
939
|
-
if is_ids
|
958
|
+
if is_ids || is_multiple
|
940
959
|
scaffold_add_line_to_file(file, "#{name}: [],", RUBY_NEW_ARRAYS_HOOK, prepend: true)
|
941
960
|
else
|
942
961
|
scaffold_add_line_to_file(file, ":#{name},", RUBY_NEW_FIELDS_HOOK, prepend: true)
|
962
|
+
if type == "file_field"
|
963
|
+
scaffold_add_line_to_file(file, ":#{name}_removal,", RUBY_NEW_FIELDS_HOOK, prepend: true)
|
964
|
+
end
|
943
965
|
end
|
944
966
|
end
|
945
967
|
|
@@ -1021,8 +1043,10 @@ class Scaffolding::Transformer
|
|
1021
1043
|
# scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb", "assert_equal tangible_thing_attributes['#{name.gsub('_', '-')}'], tangible_thing.#{name}", RUBY_NEW_FIELDS_HOOK, prepend: true)
|
1022
1044
|
|
1023
1045
|
if attribute_assignment
|
1024
|
-
|
1025
|
-
|
1046
|
+
unless attribute_options[:readonly]
|
1047
|
+
scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb", "#{name}: #{attribute_assignment},", RUBY_ADDITIONAL_NEW_FIELDS_HOOK, prepend: true)
|
1048
|
+
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)
|
1049
|
+
end
|
1026
1050
|
end
|
1027
1051
|
end
|
1028
1052
|
|
@@ -1134,9 +1158,38 @@ class Scaffolding::Transformer
|
|
1134
1158
|
|
1135
1159
|
case type
|
1136
1160
|
when "file_field"
|
1161
|
+
remove_file_methods =
|
1162
|
+
<<~RUBY
|
1163
|
+
def #{name}_removal?
|
1164
|
+
#{name}_removal.present?
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
def remove_#{name}
|
1168
|
+
#{name}.purge
|
1169
|
+
end
|
1170
|
+
RUBY
|
1171
|
+
|
1172
|
+
# Generating a model with an `attachment` data type (i.e. - `rails g ModelName file:attachment`)
|
1173
|
+
# adds `has_one_attached` to our model, just not directly above the HAS_ONE_HOOK.
|
1174
|
+
# We move the string here so it's right above the HAS_ONE_HOOK.
|
1175
|
+
model_file_path = transform_string("./app/models/scaffolding/completely_concrete/tangible_thing.rb")
|
1176
|
+
model_contents = File.readlines(model_file_path)
|
1177
|
+
model_without_attached_hook = model_contents.reject.each { |line| line.include?("has_one_attached :#{name}") }
|
1178
|
+
File.open(model_file_path, "w") do |f|
|
1179
|
+
model_without_attached_hook.each { |line| f.write(line) }
|
1180
|
+
end
|
1181
|
+
|
1137
1182
|
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "has_one_attached :#{name}", HAS_ONE_HOOK, prepend: true)
|
1183
|
+
|
1184
|
+
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "attr_accessor :#{name}_removal", ATTR_ACCESSORS_HOOK, prepend: true)
|
1185
|
+
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", remove_file_methods, METHODS_HOOK, prepend: true)
|
1186
|
+
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "after_validation :remove_#{name}, if: :#{name}_removal?", CALLBACKS_HOOK, prepend: true)
|
1138
1187
|
when "trix_editor"
|
1139
1188
|
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "has_rich_text :#{name}", HAS_ONE_HOOK, prepend: true)
|
1189
|
+
when "buttons"
|
1190
|
+
if boolean_buttons
|
1191
|
+
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "validates :#{name}, inclusion: [true, false]", VALIDATIONS_HOOK, prepend: true)
|
1192
|
+
end
|
1140
1193
|
end
|
1141
1194
|
|
1142
1195
|
end
|
@@ -1346,9 +1399,9 @@ class Scaffolding::Transformer
|
|
1346
1399
|
puts "OK, great! Let's do this! By default these menu items appear with a puzzle piece, but after you hit enter I'll open two different pages where you can view other icon options. When you find one you like, hover your mouse over it and then come back here and and enter the name of the icon you want to use. (Or hit enter to skip this step.)"
|
1347
1400
|
$stdin.gets.chomp
|
1348
1401
|
if `which open`.present?
|
1349
|
-
|
1402
|
+
TerminalCommands.open_file_or_link("https://themify.me/themify-icons")
|
1350
1403
|
if font_awesome?
|
1351
|
-
|
1404
|
+
TerminalCommands.open_file_or_link("https://fontawesome.com/icons?d=gallery&s=light")
|
1352
1405
|
end
|
1353
1406
|
else
|
1354
1407
|
puts "Sorry! We can't open these URLs automatically on your platform, but you can visit them manually:"
|
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.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".bt-link"
|
76
77
|
- MIT-LICENSE
|
77
78
|
- README.md
|
78
79
|
- Rakefile
|
@@ -157,6 +158,7 @@ files:
|
|
157
158
|
- lib/bullet_train/super_scaffolding/scaffolders/join_model_scaffolder.rb
|
158
159
|
- lib/bullet_train/super_scaffolding/scaffolders/oauth_provider_scaffolder.rb
|
159
160
|
- lib/bullet_train/super_scaffolding/version.rb
|
161
|
+
- lib/bullet_train/terminal_commands.rb
|
160
162
|
- lib/scaffolding.rb
|
161
163
|
- lib/scaffolding/block_manipulator.rb
|
162
164
|
- lib/scaffolding/class_names_transformer.rb
|
@@ -186,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
188
|
- !ruby/object:Gem::Version
|
187
189
|
version: '0'
|
188
190
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.3.7
|
190
192
|
signing_key:
|
191
193
|
specification_version: 4
|
192
194
|
summary: Bullet Train Super Scaffolding
|