Class: Semantic::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Semantic::Generators::InstallGenerator
- Defined in:
- lib/generators/semantic/install_generator.rb
Instance Method Summary collapse
- #copy_flash_messages ⇒ Object
- #copy_scaffold_views ⇒ Object
- #copy_shared_pagination ⇒ Object
- #copy_simpleforms ⇒ Object
- #create_layout ⇒ Object
- #inject_helpers ⇒ Object
- #invoke_devise_generator ⇒ Object
Instance Method Details
#copy_flash_messages ⇒ Object
46 47 48 |
# File 'lib/generators/semantic/install_generator.rb', line 46 def copy_file 'shared/_messages.html.erb', 'app/views/shared/_messages.html.erb', force: true end |
#copy_scaffold_views ⇒ Object
35 36 37 38 39 40 |
# File 'lib/generators/semantic/install_generator.rb', line 35 def copy_scaffold_views %w[edit index show new].each do |file| template "scaffolds/#{[:template_engine]}/#{file}.html.#{[:template_engine]}", "lib/templates/#{[:template_engine]}/scaffold/#{file}.html.#{[:template_engine]}", force: true end copy_file "scaffolds/#{[:template_engine]}/_form.html.#{[:template_engine]}", "lib/templates/#{[:template_engine]}/scaffold/_form.html.#{[:template_engine]}", force: true end |
#copy_shared_pagination ⇒ Object
50 51 52 |
# File 'lib/generators/semantic/install_generator.rb', line 50 def copy_shared_pagination copy_file("shared/_pagination.html.#{[:template_engine]}", "app/views/shared/_pagination.html.#{[:template_engine]}", force: true) if [:pagination] end |
#copy_simpleforms ⇒ Object
54 55 56 57 58 59 |
# File 'lib/generators/semantic/install_generator.rb', line 54 def copy_simpleforms if [:simpleform] copy_file 'initializers/simple_form.rb', 'config/initializers/simple_form.rb', force: true copy_file "simple_form/_form.html.#{[:template_engine]}", "lib/templates/#{[:template_engine]}/scaffold/_form.html.#{[:template_engine]}", force: true end end |
#create_layout ⇒ Object
42 43 44 |
# File 'lib/generators/semantic/install_generator.rb', line 42 def create_layout template("layouts/application.html.#{[:template_engine]}.tt", "app/views/layouts/application.html.#{[:template_engine]}", force: true) if [:layout] end |
#inject_helpers ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/generators/semantic/install_generator.rb', line 61 def inject_helpers pagy_helper = ([:pagination] ? 'include Pagy::Frontend' : '') helper_str = <<~HELPER #{pagy_helper} # For generating SemanitcUI based flash[:notices] def flash_class(level) case level when 'success' 'positive' when 'error' 'negative' when 'alert' 'negative' when 'notice' 'info' else 'info' end end HELPER inject_into_file 'app/helpers/application_helper.rb', optimize_indentation(helper_str,2), after: "module ApplicationHelper\n", force: true end |
#invoke_devise_generator ⇒ Object
84 85 86 87 |
# File 'lib/generators/semantic/install_generator.rb', line 84 def invoke_devise_generator # Generate semantic based devise views if devise is being used invoke('semantic:devise') if [:devise] end |