Class: Kowl::PagesGenerator
- Inherits:
-
Generators::Base
- Object
- Rails::Generators::Base
- Generators::Base
- Kowl::PagesGenerator
- Defined in:
- lib/kowl/generators/pages_generator.rb
Instance Method Summary collapse
-
#copy_welcome_pages ⇒ Object
Copy over a basic welcome page view dependant on the CSS framework and template engine specified for the application.
-
#disable_auth ⇒ Object
Add a skip_before_action for the welcome page if authentication is being used with the application.
- #make_controller_immuatable ⇒ Object
-
#setup_welcome_page ⇒ Object
Generate a basic welcome page for the application.
Methods inherited from Generators::Base
default_source_root, source_paths
Methods included from Docker
#alpine_docker_dependencies, #app_js_volumes, #app_volumes, #db_volumes, #debian_database_dependencies, #debian_docker_dependencies, #docker_app_command, #docker_compose_database_string, #docker_databases, #docker_depends_on, #docker_port_watcher, #docker_redis_service, #docker_sidekiq_service, #docker_variables, #docker_volumes, #docker_webpacker_service, #dockerfile_database_args, #dockerfile_migration_snip, #js_volumes, #mysql_volumes, #postgresql_volumes, #redis_volumes
Methods included from Actions
#add_extension_routes, #add_package, #append_to_file, #database_route, #dev_config, #dup_file, #file_exists?, #mailer_gems, #mailer_route, #mk_dir, #move_file, #pry_gems, #rails_cmd, #remove_dir, #remove_file, #remove_gem, #replace_string_in_file, #robocop_test_engine, #sidekiq_route, #template_linter_gems
Instance Method Details
#copy_welcome_pages ⇒ Object
Copy over a basic welcome page view dependant on the CSS framework and template engine specified for the application
27 28 29 30 31 32 33 |
# File 'lib/kowl/generators/pages_generator.rb', line 27 def copy_welcome_pages if %w[bootstrap semantic].include? [:framework] copy_file "pages/welcome/#{[:framework]}.html.#{[:template_engine]}", "app/views/pages/welcome.html.#{[:template_engine]}", force: true else copy_file "pages/welcome/default.html.#{[:template_engine]}", "app/views/pages/welcome.html.#{[:template_engine]}", force: true end end |
#disable_auth ⇒ Object
Add a skip_before_action for the welcome page if authentication is being used with the application
36 37 38 39 40 41 42 43 44 |
# File 'lib/kowl/generators/pages_generator.rb', line 36 def disable_auth action_str = <<~STR # Allow pages to be displayed without requiring authentication skip_before_action :authenticate_user! STR inject_into_file 'app/controllers/pages_controller.rb', optimize_indentation(action_str, 2), after: "class PagesController < ApplicationController\n" unless [:noauth] end |
#make_controller_immuatable ⇒ Object
22 23 24 |
# File 'lib/kowl/generators/pages_generator.rb', line 22 def make_controller_immuatable inject_into_file 'app/controllers/pages_controller.rb', "# frozen_string_literal: true\n\n", before: "class PagesController < ApplicationController\n" end |
#setup_welcome_page ⇒ Object
Generate a basic welcome page for the application
15 16 17 18 19 20 |
# File 'lib/kowl/generators/pages_generator.rb', line 15 def setup_welcome_page generate('controller Pages welcome --skip') # I don't want to skip or remove all tests created for pages, I just want to remove the generated controller test remove_file('spec/requests/pages_request_spec.rb') end |