Sha256: 712251b98ec28630886d239e3fdc3d40651e240d6e2fa3b309a4db434cdcaef3

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

# encoding: UTF-8
require 'rails/generators/migration'
require 'rails/generators/active_record'

module Georgia
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../templates', __FILE__)

      desc "Installs Georgia CMS:\n
        * Mounts routes\n
        * Copies initializer\n
        * Loads Migration\n
        * Runs Migration\n
        * Creates initial instances"

      def mount_engine
        # Must be in reverse order to keep priorities
        route "get '*request_path', to: 'pages#show', as: :page"
        route "root to: 'pages#show', request_path: 'home'"
        route "resources :messages, only: [:create]"
        route "mount Ckeditor::Engine => '/ckeditor'"
        route "mount Georgia::Engine => '/admin'"
      end

      def self.next_migration_number(number)
        ActiveRecord::Generators::Base.next_migration_number(number)
      end

      def run_migrations
        rake "railties:install:migrations"
        rake "db:migrate"
      end

      def create_admin_user
        say("You're almost done. You need an admin user to get started.", :yellow)
        rake "georgia:seed"
      end

      def copy_templates
        copy_file "config/initializers/georgia.rb"
        copy_file "app/controllers/pages_controller.rb"
      end

      def create_indices
        if defined? Tire
          say("Creating elasticsearch indices", :yellow)
          rake "environment tire:import CLASS=Georgia::Page FORCE=true"
          rake "environment tire:import CLASS=Ckeditor::Asset FORCE=true"
        end
      end

      def show_readme
        readme "README"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
georgia-0.7.7 lib/generators/georgia/install/install_generator.rb
georgia-0.7.6 lib/generators/georgia/install/install_generator.rb