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-15.0.0 lib/gemsmith/generators/base.rb
gemsmith-14.11.0 lib/gemsmith/generators/base.rb
gemsmith-14.10.1 lib/gemsmith/generators/base.rb
gemsmith-14.10.0 lib/gemsmith/generators/base.rb
gemsmith-14.9.0 lib/gemsmith/generators/base.rb
gemsmith-14.8.0 lib/gemsmith/generators/base.rb
gemsmith-14.7.0 lib/gemsmith/generators/base.rb
gemsmith-14.6.0 lib/gemsmith/generators/base.rb
gemsmith-14.5.0 lib/gemsmith/generators/base.rb
gemsmith-14.4.0 lib/gemsmith/generators/base.rb
gemsmith-14.3.0 lib/gemsmith/generators/base.rb
gemsmith-14.2.0 lib/gemsmith/generators/base.rb
gemsmith-14.1.3 lib/gemsmith/generators/base.rb
gemsmith-14.1.2 lib/gemsmith/generators/base.rb
gemsmith-14.1.1 lib/gemsmith/generators/base.rb
gemsmith-14.1.0 lib/gemsmith/generators/base.rb
gemsmith-14.0.2 lib/gemsmith/generators/base.rb
gemsmith-14.0.1 lib/gemsmith/generators/base.rb
gemsmith-14.0.0 lib/gemsmith/generators/base.rb
gemsmith-13.8.0 lib/gemsmith/generators/base.rb