Class: Journeybook::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Journeybook::Generators::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/journeybook/install/install_generator.rb
Constant Summary collapse
- MIGRATION_TEMPLATES =
%w[ create_journeybook_sites.rb create_journeybook_pages.rb create_journeybook_redirects.rb add_context_fields_to_journeybook_sites.rb create_journeybook_media_assets.rb create_journeybook_navigation.rb add_open_in_new_window_to_journeybook_navigation_items.rb create_journeybook_ai_style_prompts.rb add_blog_fields_to_journeybook_pages.rb add_knowledge_base_fields_to_journeybook_pages.rb add_position_to_journeybook_pages.rb ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #add_public_routes ⇒ Object
- #copy_initializer ⇒ Object
- #copy_migrations ⇒ Object
- #copy_public_page_files ⇒ Object
- #create_component_directories ⇒ Object
- #ensure_routes_file ⇒ Object
- #mount_admin_routes ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
25 26 27 28 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 25 def self.next_migration_number(dirname) @migration_number ||= Time.current.utc.strftime("%Y%m%d%H%M%S").to_i (@migration_number += 1).to_s end |
Instance Method Details
#add_public_routes ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 53 def add_public_routes route 'root "pages#show"' route <<~RUBY constraints Journeybook::PublicPageConstraint.new do get "*path" => "pages#show", as: :journeybook_page end RUBY end |
#copy_initializer ⇒ Object
36 37 38 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 36 def copy_initializer template "journeybook.rb", "config/initializers/journeybook.rb" end |
#copy_migrations ⇒ Object
30 31 32 33 34 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 30 def copy_migrations MIGRATION_TEMPLATES.each do |migration| migration_template migration, "db/migrate/#{migration}" end end |
#copy_public_page_files ⇒ Object
40 41 42 43 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 40 def copy_public_page_files template "pages_controller.rb", "app/controllers/pages_controller.rb" copy_file "show.html.erb", "app/views/pages/show.html.erb" end |
#create_component_directories ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 62 def create_component_directories empty_directory "app/components" empty_directory "app/components/previews" empty_directory "test/components/previews" create_file "app/components/.keep" create_file "app/components/previews/.keep" create_file "test/components/previews/.keep" end |
#ensure_routes_file ⇒ Object
45 46 47 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 45 def ensure_routes_file create_file "config/routes.rb", "Rails.application.routes.draw do\nend\n" unless File.exist?(File.join(destination_root, "config/routes.rb")) end |
#mount_admin_routes ⇒ Object
49 50 51 |
# File 'lib/generators/journeybook/install/install_generator.rb', line 49 def mount_admin_routes route 'mount Journeybook::Engine => "/journeybook"' end |