Sha256: 5b7040800ba3f21a4824e746cacfb7f540e13c11235e3682ac1e2091263eb800

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Gemsmith
  module Builders
    module Git
      # Builds project skeleton initial Git commit message.
      class Commit
        def self.call(...) = new(...).call

        def initialize configuration, builder: Rubysmith::Builder, container: Container
          @configuration = configuration
          @builder = builder
          @container = container
        end

        def call
          return configuration unless configuration.build_git

          builder.call(configuration)
                 .run("git add .", chdir: project_name)
                 .run(
                   %(git commit --all --message "Added project skeleton" --message "#{body}"),
                   chdir: project_name
                 )

          configuration
        end

        private

        attr_reader :configuration, :builder, :container

        def body
          <<~CONTENT
            Generated with [#{specification.label}](#{specification.homepage_url})
            #{specification.version}.
          CONTENT
        end

        def project_name = configuration.project_name

        def specification = container[__method__]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gemsmith-17.0.1 lib/gemsmith/builders/git/commit.rb
gemsmith-17.0.0 lib/gemsmith/builders/git/commit.rb
gemsmith-16.2.0 lib/gemsmith/builders/git/commit.rb
gemsmith-16.1.0 lib/gemsmith/builders/git/commit.rb
gemsmith-16.0.0 lib/gemsmith/builders/git/commit.rb