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
permalink #copy_flash_messages ⇒ Object
[View source]
29 30 31 |
# File 'lib/generators/semantic/install_generator.rb', line 29 def copy_file 'shared/_messages.html.erb', 'app/views/shared/_messages.html.erb', force: true end |
permalink #copy_scaffold_views ⇒ Object
[View source]
18 19 20 21 22 23 |
# File 'lib/generators/semantic/install_generator.rb', line 18 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 |
permalink #copy_shared_pagination ⇒ Object
[View source]
33 34 35 |
# File 'lib/generators/semantic/install_generator.rb', line 33 def copy_shared_pagination copy_file("shared/_pagination.html.#{[:template_engine]}", "app/views/shared/_pagination.html.#{[:template_engine]}", force: true) if [:pagination] end |
permalink #copy_simpleforms ⇒ Object
[View source]
37 38 39 40 41 42 |
# File 'lib/generators/semantic/install_generator.rb', line 37 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 |
permalink #create_layout ⇒ Object
[View source]
25 26 27 |
# File 'lib/generators/semantic/install_generator.rb', line 25 def create_layout template("layouts/application.html.#{[:template_engine]}.tt", "app/views/layouts/application.html.#{[:template_engine]}", force: true) if [:layout] end |
permalink #inject_helpers ⇒ Object
[View source]
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/generators/semantic/install_generator.rb', line 44 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 |
permalink #invoke_devise_generator ⇒ Object
[View source]
67 68 69 70 |
# File 'lib/generators/semantic/install_generator.rb', line 67 def invoke_devise_generator # Generate semantic based devise views if devise is being used invoke('semantic:devise') if [:devise] end |