bullet_train-super_scaffolding 1.0.22 → 1.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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/absolutely_abstract/creative_concepts/_index.html.erb +1 -1
- data/app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb +4 -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 +12 -9
- data/lib/bullet_train/super_scaffolding/version.rb +1 -1
- data/lib/bullet_train/terminal_commands.rb +30 -0
- data/lib/scaffolding/oauth_providers.rb +22 -6
- data/lib/scaffolding/script.rb +5 -3
- data/lib/scaffolding/transformer.rb +67 -14
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b694d29319b4cac16e219a1a80988981b1be8135cf3ee9ea341b58a8e7975113
|
4
|
+
data.tar.gz: a88a1c710e2690ac903c6a49ca275a4c3b17c8cfbe91b1dc17ef8336e9500e86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c7396ca84e89d4c90df6e26819c43013154ed5f35921e5161fec85fcadfec2c799bfbb098ea533d74e50cd9f71bfed71b7f09c85d8cf8c903767575ae961b7
|
7
|
+
data.tar.gz: 5fe4d83c1c05069acb8b12f39541cf77436ce7a91e533657d8ac7d0a49604058e480c233c7e3bb250c7213ab6bd3670e408764197c69c7626ca836e6e2d7b106
|
@@ -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.
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<%= render 'account/shared/box' do |p| %>
|
7
7
|
<% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
|
8
8
|
<% p.content_for :description do %>
|
9
|
-
<%=
|
9
|
+
<%= t(".contexts.#{context.class.name.underscore}.#{creative_concepts.any? ? 'description' : 'description_empty'}") %>
|
10
10
|
<% end %>
|
11
11
|
|
12
12
|
<% if creative_concepts.any? %>
|
@@ -4,7 +4,9 @@
|
|
4
4
|
<% hide_actions ||= false %>
|
5
5
|
<% hide_back ||= false %>
|
6
6
|
|
7
|
-
|
7
|
+
<% pagy, tangible_things = pagy(tangible_things, page_param: :tangible_things_page) %>
|
8
|
+
|
9
|
+
<%= render 'account/shared/box', pagy: pagy do |p| %>
|
8
10
|
<% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
|
9
11
|
<% p.content_for :description do %>
|
10
12
|
<%= t(".contexts.#{context.class.name.underscore}.description#{"_empty" unless tangible_things.any?}") %>
|
@@ -69,4 +71,4 @@
|
|
69
71
|
<% end %>
|
70
72
|
<% end %>
|
71
73
|
<% end %>
|
72
|
-
<% end %>
|
74
|
+
<% 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:"
|
@@ -78,7 +78,9 @@ module BulletTrain
|
|
78
78
|
|
79
79
|
# User OAuth.
|
80
80
|
"./app/models/oauth/stripe_account.rb",
|
81
|
+
"./app/models/concerns/oauth/stripe_accounts/base.rb",
|
81
82
|
"./app/models/webhooks/incoming/oauth/stripe_account_webhook.rb",
|
83
|
+
"./app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb",
|
82
84
|
"./app/controllers/account/oauth/stripe_accounts_controller.rb",
|
83
85
|
"./app/controllers/webhooks/incoming/oauth/stripe_account_webhooks_controller.rb",
|
84
86
|
"./app/views/account/oauth/stripe_accounts",
|
@@ -89,6 +91,7 @@ module BulletTrain
|
|
89
91
|
|
90
92
|
# Team Integration.
|
91
93
|
"./app/models/integrations/stripe_installation.rb",
|
94
|
+
"./app/models/concerns/integrations/stripe_installations/base.rb",
|
92
95
|
# './app/serializers/api/v1/integrations/stripe_installation_serializer.rb',
|
93
96
|
"./app/controllers/account/integrations/stripe_installations_controller.rb",
|
94
97
|
"./app/views/account/integrations/stripe_installations",
|
@@ -101,7 +104,7 @@ module BulletTrain
|
|
101
104
|
"./app/controllers/webhooks/incoming/oauth/stripe_account_webhooks_controller.rb"
|
102
105
|
|
103
106
|
].each do |name|
|
104
|
-
if File.directory?(name)
|
107
|
+
if File.directory?(legacy_resolve_template_path(name))
|
105
108
|
oauth_scaffold_directory(name, options)
|
106
109
|
else
|
107
110
|
oauth_scaffold_file(name, options)
|
@@ -109,7 +112,7 @@ module BulletTrain
|
|
109
112
|
end
|
110
113
|
|
111
114
|
oauth_scaffold_add_line_to_file("./app/views/devise/shared/_oauth.html.erb", "<%= render 'devise/shared/oauth/stripe', verb: verb if stripe_enabled? %>", "<%# 🚅 super scaffolding will insert new oauth providers above this line. %>", options, prepend: true)
|
112
|
-
oauth_scaffold_add_line_to_file("./app/views/account/users/
|
115
|
+
oauth_scaffold_add_line_to_file("./app/views/account/users/_oauth.html.erb", "<%= render 'account/oauth/stripe_accounts/index', context: @user, stripe_accounts: @user.oauth_stripe_accounts if stripe_enabled? %>", "<% # 🚅 super scaffolding will insert new oauth providers above this line. %>", options, prepend: true)
|
113
116
|
oauth_scaffold_add_line_to_file("./config/initializers/devise.rb", "config.omniauth :stripe_connect, ENV['STRIPE_CLIENT_ID'], ENV['STRIPE_SECRET_KEY'], {\n ## specify options for your oauth provider here, e.g.:\n # scope: 'read_products,read_orders,write_content',\n }\n", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
|
114
117
|
oauth_scaffold_add_line_to_file("./app/controllers/account/oauth/omniauth_callbacks_controller.rb", "def stripe_connect\n callback(\"Stripe\", team_id_from_env)\n end\n", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
|
115
118
|
oauth_scaffold_add_line_to_file("./app/models/team.rb", "has_many :integrations_stripe_installations, class_name: 'Integrations::StripeInstallation', dependent: :destroy if stripe_enabled?", "# 🚅 add oauth providers above.", options, prepend: true)
|
@@ -122,12 +125,7 @@ module BulletTrain
|
|
122
125
|
oauth_scaffold_add_line_to_file("./Gemfile", "gem 'omniauth-stripe-connect'", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
|
123
126
|
oauth_scaffold_add_line_to_file("./lib/bullet_train.rb", "def stripe_enabled?\n ENV['STRIPE_CLIENT_ID'].present? && ENV['STRIPE_SECRET_KEY'].present?\nend\n", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
|
124
127
|
oauth_scaffold_add_line_to_file("./lib/bullet_train.rb", "stripe_enabled?,", "# 🚅 super scaffolding will insert new oauth provider checks above this line.", options, prepend: true)
|
125
|
-
oauth_scaffold_add_line_to_file("./app/models/ability.rb", "if stripe_enabled
|
126
|
-
can [:read, :create, :destroy], Oauth::StripeAccount, user_id: user.id
|
127
|
-
can :manage, Integrations::StripeInstallation, team_id: user.team_ids
|
128
|
-
can :destroy, Integrations::StripeInstallation, oauth_stripe_account: {user_id: user.id}
|
129
|
-
end
|
130
|
-
", "# 🚅 super scaffolding will insert any new oauth providers above.", options, prepend: true)
|
128
|
+
oauth_scaffold_add_line_to_file("./app/models/ability.rb", "if stripe_enabled?\n can [:read, :create, :destroy], Oauth::StripeAccount, user_id: user.id\n can :manage, Integrations::StripeInstallation, team_id: user.team_ids\n can :destroy, Integrations::StripeInstallation, oauth_stripe_account: {user_id: user.id}\n end\n", "# 🚅 super scaffolding will insert any new oauth providers above.", options, prepend: true)
|
131
129
|
|
132
130
|
# find the database migration that defines this relationship.
|
133
131
|
migration_file_name = `grep "create_table #{oauth_transform_string(":oauth_stripe_accounts", options)}" db/migrate/*`.split(":").first
|
@@ -147,6 +145,11 @@ module BulletTrain
|
|
147
145
|
puts ""
|
148
146
|
puts "You'll probably need to `bundle install`.".green
|
149
147
|
puts ""
|
148
|
+
puts "You'll need to configure API keys for this provider in `config/application.yml`, like so:"
|
149
|
+
puts ""
|
150
|
+
puts oauth_transform_string(" STRIPE_CLIENT_ID: ...", options)
|
151
|
+
puts oauth_transform_string(" STRIPE_SECRET_KEY: ...", options)
|
152
|
+
puts ""
|
150
153
|
puts "If the OAuth provider asks you for some whitelisted callback URLs, the URL structure for those is as so:"
|
151
154
|
puts ""
|
152
155
|
path = "users/auth/stripe_connect/callback"
|
@@ -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
|
@@ -1,3 +1,15 @@
|
|
1
|
+
def legacy_resolve_template_path(file)
|
2
|
+
# Figure out the actual location of the file.
|
3
|
+
# Originally all the potential source files were in the repository alongside the application.
|
4
|
+
# Now the files could be provided by an included Ruby gem, so we allow those Ruby gems to register their base
|
5
|
+
# path and then we check them in order to see which template we should use.
|
6
|
+
BulletTrain::SuperScaffolding.template_paths.map do |base_path|
|
7
|
+
base_path = Pathname.new(base_path)
|
8
|
+
resolved_path = base_path.join(file).to_s
|
9
|
+
File.exist?(resolved_path) ? resolved_path : nil
|
10
|
+
end.compact.first || raise("Couldn't find the Super Scaffolding template for `#{file}` in any of the following locations:\n\n#{BulletTrain::SuperScaffolding.template_paths.join("\n")}")
|
11
|
+
end
|
12
|
+
|
1
13
|
def legacy_replace_in_file(file, before, after)
|
2
14
|
puts "Replacing in '#{file}'."
|
3
15
|
target_file_content = File.read(file)
|
@@ -61,14 +73,18 @@ def decode_double_replacement_fix(string)
|
|
61
73
|
end
|
62
74
|
|
63
75
|
def oauth_scaffold_directory(directory, options)
|
76
|
+
transformed_directory_name = oauth_transform_string(directory, options)
|
64
77
|
begin
|
65
|
-
Dir.mkdir(
|
66
|
-
rescue
|
67
|
-
|
78
|
+
Dir.mkdir(transformed_directory_name)
|
79
|
+
rescue Errno::EEXIST => _
|
80
|
+
puts "The directory #{transformed_directory_name} already exists, skipping generation.".yellow
|
81
|
+
rescue Errno::ENOENT => _
|
82
|
+
puts "Proceeding to generate '#{transformed_directory_name}'."
|
68
83
|
end
|
69
|
-
|
84
|
+
|
85
|
+
Dir.foreach(legacy_resolve_template_path(directory)) do |file|
|
70
86
|
file = "#{directory}/#{file}"
|
71
|
-
unless File.directory?(file)
|
87
|
+
unless File.directory?(legacy_resolve_template_path(file))
|
72
88
|
oauth_scaffold_file(file, options)
|
73
89
|
end
|
74
90
|
end
|
@@ -80,7 +96,7 @@ def oauth_scaffold_file(file, options)
|
|
80
96
|
transformed_file_content = []
|
81
97
|
|
82
98
|
skipping = false
|
83
|
-
File.open(file).each_line do |line|
|
99
|
+
File.open(legacy_resolve_template_path(file)).each_line do |line|
|
84
100
|
if line.include?("# 🚅 skip when scaffolding.")
|
85
101
|
next
|
86
102
|
end
|
data/lib/scaffolding/script.rb
CHANGED
@@ -8,6 +8,8 @@ require "scaffolding/class_names_transformer"
|
|
8
8
|
require "scaffolding/oauth_providers"
|
9
9
|
require "scaffolding/routes_file_manipulator"
|
10
10
|
|
11
|
+
require_relative "../bullet_train/terminal_commands"
|
12
|
+
|
11
13
|
# filter out options.
|
12
14
|
argv = []
|
13
15
|
@options = {}
|
@@ -64,11 +66,11 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
|
|
64
66
|
puts ""
|
65
67
|
puts "Attributes that end with `_id` or `_ids` trigger awesome, powerful magic in Super Scaffolding. However, because no `#{attribute_options[:class_name]}` class was found defined in `#{file_name}`, you'll need to specify a `class_name` that exists to let us know what model class is on the other side of the association, like so:".red
|
66
68
|
puts ""
|
67
|
-
puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}
|
69
|
+
puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}{class_name=#{name.gsub(/_ids?$/, "").classify}}".red
|
68
70
|
puts ""
|
69
|
-
puts "If `#{name}` is just a regular field and isn't backed by an ActiveRecord association, you can skip all this with the `
|
71
|
+
puts "If `#{name}` is just a regular field and isn't backed by an ActiveRecord association, you can skip all this with the `{vanilla}` option, e.g.:".red
|
70
72
|
puts ""
|
71
|
-
puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}
|
73
|
+
puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}{vanilla}".red
|
72
74
|
puts ""
|
73
75
|
exit
|
74
76
|
end
|
@@ -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,15 +1,29 @@
|
|
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.25
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: standard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rails
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: 6.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bullet_train
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: indefinite_article
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +157,7 @@ files:
|
|
129
157
|
- lib/bullet_train/super_scaffolding/scaffolders/join_model_scaffolder.rb
|
130
158
|
- lib/bullet_train/super_scaffolding/scaffolders/oauth_provider_scaffolder.rb
|
131
159
|
- lib/bullet_train/super_scaffolding/version.rb
|
160
|
+
- lib/bullet_train/terminal_commands.rb
|
132
161
|
- lib/scaffolding.rb
|
133
162
|
- lib/scaffolding/block_manipulator.rb
|
134
163
|
- lib/scaffolding/class_names_transformer.rb
|
@@ -158,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
187
|
- !ruby/object:Gem::Version
|
159
188
|
version: '0'
|
160
189
|
requirements: []
|
161
|
-
rubygems_version: 3.
|
190
|
+
rubygems_version: 3.3.7
|
162
191
|
signing_key:
|
163
192
|
specification_version: 4
|
164
193
|
summary: Bullet Train Super Scaffolding
|