Sha256: 885f48053c88cda4cf0a2974a3a7dea90728dd61cf4fe295e02d9c518e97ee54

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'fileutils'
require 'rails/generators'
require_relative '../actions'
require_relative '../docker'

# https://api.rubyonrails.org/v5.2/classes/Rails/Generators/Base.html
module Kowl
  module Generators
    class Base < Rails::Generators::Base
      include Kowl::Actions
      include Kowl::Docker
      hide!

      # Resolve to using the default Rails gem templates as a fallback in case source_path doesn't exist for generator
      # NOTE: Do no enable this, as it tends to overwrite the default rails gem past for pulling templates from (ie: database stuff)
      def self.default_source_root
        File.expand_path(File.join('..', 'templates'), __dir__)
      end

      # Used for setting RAILS default source_path
      # As well as adding the gems source_path to the generators
      # src: https://github.com/solidusio/solidus/blob/master/core/lib/generators/spree/dummy/dummy_generator.rb#L15
      def self.source_paths
        super
        paths = superclass.source_paths
        paths << File.expand_path(File.join('..', 'templates'), __dir__)
        paths.flatten.uniq
      end

      private

      # Return a cleaned up version of the name of the application being generated
      def app_name
        @app_name ||= Rails.app_class.module_parent_name.demodulize.underscore.dasherize
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kowl-0.0.7 lib/kowl/generators/base.rb