Class: HotGlue::TypeaheadInstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- HotGlue::TypeaheadInstallGenerator
- Defined in:
- lib/generators/hot_glue/typeahead_install_generator.rb
Instance Method Summary collapse
- #filepath_prefix ⇒ Object
-
#initialize(*args) ⇒ TypeaheadInstallGenerator
constructor
:nodoc:.
Constructor Details
#initialize(*args) ⇒ TypeaheadInstallGenerator
:nodoc:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/generators/hot_glue/typeahead_install_generator.rb', line 12 def initialize(*args) #:nodoc: super copy_file "typeahead_views/typeahead.scss", "#{'spec/dummy/' if $INTERNAL_SPECS}app/assets/stylesheets/typeahead.scss" try = ["application.scss", "application.bootstrap.scss"] try.each do |filename| main_scss_file = "#{'spec/dummy/' if $INTERNAL_SPECS}app/assets/stylesheets/#{filename}" if File.exist?(main_scss_file) insert_into_file main_scss_file do "@import 'typeahead';\n" end puts "Inserted @import 'typeahead'; into #{main_scss_file}" break else # puts "Could not find #{main_scss_file}. Please add the following line to your main scss file: @import 'typeahead';" end end copy_file "typeahead_views/typeahead_controller.js", "#{'spec/dummy/' if $INTERNAL_SPECS}app/javascript/controllers/typeahead_controller.js" copy_file "typeahead_views/typeahead_results_controller.js", "#{'spec/dummy/' if $INTERNAL_SPECS}app/javascript/controllers/typeahead_results_controller.js" system("bin/rails stimulus:manifest:update") end |
Instance Method Details
#filepath_prefix ⇒ Object
6 7 8 9 |
# File 'lib/generators/hot_glue/typeahead_install_generator.rb', line 6 def filepath_prefix # todo: inject the context 'spec/dummy/' if $INTERNAL_SPECS end |