Sha256: 86d1190fd9ef5e629408c2665cea38517ed8ef3b2a688d22e1e4a6628e24498e

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

module Ecm
  module UserArea
    module Generators
      class InstallGenerator < Rails::Generators::Base
        desc 'Generates the initializer'

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

        attr_reader :base_controller_class_name

        def initialize(*args)
          super
          @base_controller_class_name = ENV.fetch('BASE_CONTROLLER_CLASS_NAME') { '::FrontendController' }
        end

        def generate_initializer
          template 'initializer.rb', 'config/initializers/ecm_user_area.rb'
        end

        def generate_routes
          route File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
        end

        def add_helpers_to_application_controller
          inject_into_file 'app/controllers/application_controller.rb', before: "\nend" do
            File.read(File.join(File.expand_path('../templates', __FILE__), 'application_controller.source'))
          end
        end

        # def add_default_user
        #   if yes? "Add default user (user@expample.com/password)?"
        #     CreateDefaultUserService.call
        #   end
        # end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ecm_user_area2-4.0.2 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-4.0.1 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-3.1.2 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-3.1.1 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-3.1.0 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-3.0.3 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-3.0.2 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-3.0.1 lib/generators/ecm/user_area/install/install_generator.rb
ecm_user_area2-3.0.0 lib/generators/ecm/user_area/install/install_generator.rb