Class: AdvancedSelect::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- AdvancedSelect::Generators::InstallGenerator
- Defined in:
- lib/generators/advanced_select/install/install_generator.rb
Constant Summary collapse
- VALID_SETUPS =
%w[importmap jsbundling].freeze
Instance Method Summary collapse
- #import_stylesheet ⇒ Object
- #install_stimulus_controller ⇒ Object
- #install_stylesheet ⇒ Object
- #register_stimulus_controller ⇒ Object
- #show_next_steps ⇒ Object
- #validate_options ⇒ Object
Instance Method Details
#import_stylesheet ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/generators/advanced_select/install/install_generator.rb', line 42 def import_stylesheet case setup when "importmap" import_application_stylesheet when "jsbundling" append_postcss_import end end |
#install_stimulus_controller ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/generators/advanced_select/install/install_generator.rb', line 18 def install_stimulus_controller case setup when "importmap" pin_importmap_controller when "jsbundling" copy_file "advanced_select_controller.js", "app/javascript/controllers/advanced_select_controller.js" end end |
#install_stylesheet ⇒ Object
27 28 29 30 31 |
# File 'lib/generators/advanced_select/install/install_generator.rb', line 27 def install_stylesheet if setup == "jsbundling" copy_file "advanced_select.css", "app/assets/stylesheets/advanced_select.css" end end |
#register_stimulus_controller ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/generators/advanced_select/install/install_generator.rb', line 33 def register_stimulus_controller case setup when "importmap" register_importmap_controller when "jsbundling" register_manifest_controller end end |
#show_next_steps ⇒ Object
51 52 53 54 55 |
# File 'lib/generators/advanced_select/install/install_generator.rb', line 51 def show_next_steps say "AdvancedSelect installed.", :green say "Setup: #{setup}" say "Host apps still own routes, controllers, queries, and Turbo Stream option endpoints." end |
#validate_options ⇒ Object
12 13 14 15 16 |
# File 'lib/generators/advanced_select/install/install_generator.rb', line 12 def return if VALID_SETUPS.include?(setup) raise Thor::Error, "Invalid --setup=#{setup.inspect}. Expected one of: #{VALID_SETUPS.join(', ')}." end |