Sha256: 33aab61680e6318a5cb46b72e8cd43ac31030313fc4b7b6d0c5ed8c23f2f30e0

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

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

        def initialize configuration, builder: Builder
          @configuration = configuration
          @builder = builder
        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

        def body
          <<~CONTENT
            Generated with [#{Identity::LABEL}]("https://www.alchemists.io/projects/rubysmith")
            #{Identity::VERSION}.
          CONTENT
        end

        def project_name = configuration.project_name
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysmith-1.1.1 lib/rubysmith/builders/git/commit.rb
rubysmith-1.1.0 lib/rubysmith/builders/git/commit.rb
rubysmith-1.0.0 lib/rubysmith/builders/git/commit.rb