Sha256: 5c741528f7910f8b16ea479cce1d0a68cc8be162f42bcf180ddc51299f835644

Contents?: true

Size: 969 Bytes

Versions: 13

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

require "open3"

module Gemsmith
  module Generators
    # Generates Git support.
    class Git < Base
      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
        Dir.chdir gem_root 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

13 entries across 13 versions & 1 rubygems

Version Path
gemsmith-15.0.0 lib/gemsmith/generators/git.rb
gemsmith-14.11.0 lib/gemsmith/generators/git.rb
gemsmith-14.10.1 lib/gemsmith/generators/git.rb
gemsmith-14.10.0 lib/gemsmith/generators/git.rb
gemsmith-14.9.0 lib/gemsmith/generators/git.rb
gemsmith-14.8.0 lib/gemsmith/generators/git.rb
gemsmith-14.7.0 lib/gemsmith/generators/git.rb
gemsmith-14.6.0 lib/gemsmith/generators/git.rb
gemsmith-14.5.0 lib/gemsmith/generators/git.rb
gemsmith-14.4.0 lib/gemsmith/generators/git.rb
gemsmith-14.3.0 lib/gemsmith/generators/git.rb
gemsmith-14.2.0 lib/gemsmith/generators/git.rb
gemsmith-14.1.3 lib/gemsmith/generators/git.rb