Class: TamSelect::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- TamSelect::Generators::InstallGenerator
- Defined in:
- lib/generators/tam_select/install_generator.rb
Instance Method Summary collapse
- #configure_importmap ⇒ Object
- #copy_controller_concern ⇒ Object
- #copy_helper ⇒ Object
- #copy_javascript ⇒ Object
- #copy_remote_controller ⇒ Object
- #copy_simple_form_input ⇒ Object
- #show_tailwind_instruction ⇒ Object
Instance Method Details
#configure_importmap ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/tam_select/install_generator.rb', line 15 def configure_importmap importmap = "config/importmap.rb" unless File.exist?(destination_path(importmap)) configure_esbuild return end pin = 'pin "tam_select", to: "tam_select/tam_select.js"' contents = File.read(destination_path(importmap)) existing_pin = /^\s*pin\s+["']tam_select["'].*$/ if contents.match?(existing_pin) gsub_file importmap, existing_pin, pin unless contents.match?(/^#{Regexp.escape(pin)}$/) else append_to_file importmap, "\n#{pin}\n" end end |
#copy_controller_concern ⇒ Object
41 42 43 44 |
# File 'lib/generators/tam_select/install_generator.rb', line 41 def copy_controller_concern copy_file "lib/generators/tam_select/templates/tam_select_paginatable.rb", "app/controllers/concerns/tam_select_paginatable.rb" copy_file "lib/generators/tam_select/templates/tam_select_remote.rb", "app/controllers/concerns/tam_select_remote.rb" end |
#copy_helper ⇒ Object
50 51 52 |
# File 'lib/generators/tam_select/install_generator.rb', line 50 def copy_helper copy_file "lib/generators/tam_select/templates/tam_select_helper.rb", "app/helpers/tam_select_helper.rb" end |
#copy_javascript ⇒ Object
10 11 12 13 |
# File 'lib/generators/tam_select/install_generator.rb', line 10 def copy_javascript copy_file "src/tam-select.js", "app/javascript/tam_select/tam_select.js" copy_file "lib/generators/tam_select/templates/tam_select_controller.js", "app/javascript/controllers/tam_select_controller.js" end |
#copy_remote_controller ⇒ Object
46 47 48 |
# File 'lib/generators/tam_select/install_generator.rb', line 46 def copy_remote_controller copy_file "lib/generators/tam_select/templates/tam_select_remote_controller.rb", "app/controllers/tam_select_remote_controller.rb" end |
#copy_simple_form_input ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/generators/tam_select/install_generator.rb', line 33 def copy_simple_form_input if simple_form_available? copy_file "lib/generators/tam_select/templates/tam_select_input.rb", "app/inputs/tam_select_input.rb" else say "Simple Form is not installed; skipped app/inputs/tam_select_input.rb. Standard Rails form helpers remain available.", :yellow end end |
#show_tailwind_instruction ⇒ Object
54 55 56 57 58 59 |
# File 'lib/generators/tam_select/install_generator.rb', line 54 def show_tailwind_instruction say "\ntam_select installed.", :green say "Tailwind CSS 4 scans app/javascript automatically in most Rails setups." say "If your setup uses explicit sources, add:" say '@source "../../javascript/tam_select/**/*.js";' end |