Sha256: 4a153b882126bf3eaa6f0b2db0a5e4e90bd37fb82d46c65ccaefced9f89893bf

Contents?: true

Size: 946 Bytes

Versions: 23

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true

module Gemsmith
  module Generators
    # Abstract class from which all generators inherit from.
    class Base
      LIB_ROOT = File.join("%gem_name%", "lib").freeze
      LIB_ROOT_GEM = File.join(LIB_ROOT, "%gem_path%").freeze

      def self.run cli, configuration: {}
        new(cli, configuration: configuration).run
      end

      def initialize cli, configuration: {}
        @cli = cli
        @configuration = configuration
      end

      def run
        fail NotImplementedError, "The method, #run, is not implemented yet."
      end

      protected

      attr_reader :cli, :configuration

      def gem_name
        configuration.dig :gem, :name
      end

      def gem_path
        configuration.dig :gem, :path
      end

      def gem_root
        File.join cli.destination_root, gem_name
      end

      def template path
        cli.template path, configuration
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
gemsmith-13.7.2 lib/gemsmith/generators/base.rb
gemsmith-13.7.1 lib/gemsmith/generators/base.rb
gemsmith-13.7.0 lib/gemsmith/generators/base.rb