Class: KonoUtilsBootstrapView4::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- KonoUtilsBootstrapView4::InstallGenerator
- Defined in:
- lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb
Instance Method Summary collapse
- #append_dependecy_to_assets ⇒ Object
- #append_gem_dependency ⇒ Object
- #copy_initializer ⇒ Object
- #install_cell_concept_namespacer_on_application_record ⇒ Object
- #install_kono_utils ⇒ Object
- #install_node_dependency ⇒ Object
Instance Method Details
#append_dependecy_to_assets ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb', line 28 def append_dependecy_to_assets js_requirements = [ 'kono_utils_bootstrap_view4/application' ] KonoUtilsBootstrapView4.configuration.moment_js_locales.each do |l| js_requirements << "moment/locale/#{l}.js" end rails6 = Gem::Version.new('6') if rails6 <= Gem::Version.new(Rails.version) say "in rails 6 dobbiamo avere webpacker che compila erb, creiamo un file erb che includa le nostre dipendenze", :yellow run "rails webpacker:install:erb" #cancelliamo il file di esempio remove_file 'app/javascript/packs/hello_erb.js.erb' template 'kono_utils_bootstrap_view4.js.erb.template', Rails.root.join('app', 'javascript', 'packs', 'application.js.erb') say "Ricorda di aggiungere nel layout <%= javascript_pack_tag 'application' %>", :yellow else inject_into_file 'app/assets/javascripts/application.js', "#{requirements.collect { |c| "\n//= require #{c}" }.join}\n", before: "//= require_tree ." end requirements = [ 'kono_utils_bootstrap_view4/application' ] inject_into_file 'app/assets/stylesheets/application.css', "#{requirements.collect { |c| "\n *= require #{c}" }.join}\n", before: " *= require_tree ." end |
#append_gem_dependency ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb', line 60 def append_gem_dependency dips = [ 'cells-erb', # inserita in installazione come specificato qua http://trailblazer.to/gems/cells/rails.html#engine-render-problems 'cells-rails', 'kaminari-cells' ] say "AGGIUNGO dipendenze per concepts, #{dips.join(" ")}", :green dips.each do |dip| gem dip end end |
#copy_initializer ⇒ Object
12 13 14 |
# File 'lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb', line 12 def copy_initializer template 'kono_utils_bootstrap_view4.template', Rails.root.join('config', 'initializers', 'kono_utils_bootstrap_view4.rb') end |
#install_cell_concept_namespacer_on_application_record ⇒ Object
21 22 23 24 25 26 |
# File 'lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb', line 21 def install_cell_concept_namespacer_on_application_record inject_into_file 'app/models/application_record.rb', "\n include KonoUtilsBootstrapView4::BaseClassConceptNs", after: "ActiveRecord::Base" rescue Exception => e say "Attenzione, includere a mano KonoUtilsBootstrapView4::BaseClassConceptNs nel modello da cui darivano i modelli del base editing - #{e.}", :red end |
#install_kono_utils ⇒ Object
8 9 10 |
# File 'lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb', line 8 def install_kono_utils run "rails g kono_utils:install" end |
#install_node_dependency ⇒ Object
16 17 18 19 |
# File 'lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb', line 16 def install_node_dependency yarn_packages = ['[email protected]', '[email protected]', 'popper.js', 'moment', 'tempusdominus-bootstrap-4', '@fortawesome/fontawesome-free', 'data-confirm-modal'] run "yarn add #{yarn_packages.join(' ')}" unless yarn_packages.empty? end |