Sha256: dd20a681f67202c2495a4b3828f4dcbb06931c587b89bd097debb508cd029288

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

require 'rails/generators'

module CommonwealthVlrEngine
  class InstallGenerator < Rails::Generators::Base

    source_root File.expand_path('../templates', __FILE__)

    argument :search_builder_name, type: :string , default: "search_builder"
    argument :document_name, type: :string , default: "solr_document"
    argument :controller_name, type: :string , default: "catalog"

    desc "InstallGenerator Commonwealth VLR Engine"

    def verify_blacklight_installed
      if !IO.read('app/controllers/application_controller.rb').include?('include Blacklight::Controller')
         raise "It doesn't look like you have Blacklight installed..."
      end
    end

    def insert_to_assets
      generate 'commonwealth_vlr_engine:localassets'
    end

    def copy_yml_files
      generate 'commonwealth_vlr_engine:yml'
    end

    def insert_to_controllers
      generate 'commonwealth_vlr_engine:controller', controller_name
    end

    def insert_to_models
      generate 'commonwealth_vlr_engine:model', search_builder_name, document_name
    end

    def add_vlr_initializers
      template 'config/initializers/a_load_commonwealth_vlr_configs.rb'
      template 'config/initializers/devise.rb'
      template 'config/initializers/secret_token.rb'
    end

    def insert_to_routes
      generate 'commonwealth_vlr_engine:routes'
    end

    def insert_to_environments
      generate 'commonwealth_vlr_engine:environment'
    end

    def bundle_install
      Bundler.with_clean_env do
        run 'bundle install'
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
commonwealth-vlr-engine-0.0.7 lib/generators/commonwealth_vlr_engine/install_generator.rb
commonwealth-vlr-engine-0.0.4 lib/generators/commonwealth_vlr_engine/install_generator.rb
commonwealth-vlr-engine-0.0.3 lib/generators/commonwealth_vlr_engine/install_generator.rb
commonwealth-vlr-engine-0.0.2 lib/generators/commonwealth_vlr_engine/install_generator.rb
commonwealth-vlr-engine-0.0.1 lib/generators/commonwealth_vlr_engine/install_generator.rb