Sha256: c4c051c4579afa1b417f11671b037ecc50ae5b7d3a66dc712ccb0603afbb4448

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require "open3"
require "refinements/pathnames"

module Gemsmith
  module Generators
    # Generates Git support.
    class Git < Base
      using Refinements::Pathnames

      def initialize cli, configuration: {}, shell: Open3
        super cli, configuration: configuration
        @shell = shell
      end

      def run
        create_ignore_file
        create_repository
      end

      private

      attr_reader :shell

      def create_ignore_file
        template "%gem_name%/.gitignore.tt"
      end

      def create_repository
        create_commit "Added gem skeleton",
                      "Generated with [#{Identity::LABEL}](#{Identity::URL})\n" \
                      "#{Identity::VERSION}."
      end

      def create_commit subject, body
        gem_root.change_dir do
          shell.capture3 "git init"
          shell.capture3 "git add ."
          shell.capture3 %(git commit --all --no-verify --message "#{subject}" --message "#{body}")
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gemsmith-15.5.0 lib/gemsmith/generators/git.rb
gemsmith-15.4.0 lib/gemsmith/generators/git.rb
gemsmith-15.3.0 lib/gemsmith/generators/git.rb
gemsmith-15.2.0 lib/gemsmith/generators/git.rb
gemsmith-15.1.1 lib/gemsmith/generators/git.rb
gemsmith-15.1.0 lib/gemsmith/generators/git.rb