Sha256: 32c7694256456b0ac74c51491c6a2ed64e3367f053d4c1f41b8a63a7ba4a8c8f

Contents?: true

Size: 946 Bytes

Versions: 12

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 initialize cli, configuration: {}
        @cli = cli
        @configuration = configuration
      end

      def self.run cli, configuration: {}
        new(cli, configuration: configuration).run
      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

12 entries across 12 versions & 1 rubygems

Version Path
gemsmith-13.6.0 lib/gemsmith/generators/base.rb
gemsmith-13.5.0 lib/gemsmith/generators/base.rb
gemsmith-13.4.0 lib/gemsmith/generators/base.rb
gemsmith-13.3.0 lib/gemsmith/generators/base.rb
gemsmith-13.2.0 lib/gemsmith/generators/base.rb
gemsmith-13.1.0 lib/gemsmith/generators/base.rb
gemsmith-13.0.0 lib/gemsmith/generators/base.rb
gemsmith-12.4.0 lib/gemsmith/generators/base.rb
gemsmith-12.3.0 lib/gemsmith/generators/base.rb
gemsmith-12.2.0 lib/gemsmith/generators/base.rb
gemsmith-12.1.0 lib/gemsmith/generators/base.rb
gemsmith-12.0.0 lib/gemsmith/generators/base.rb