Sha256: e3326bb82d2941c4ab290101953ebabc1337dbb69ab5b1372ac4d093653152b0

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require "refinements/struct"

module Rubysmith
  module Builders
    # Builds project skeleton GitHub templates.
    class GitHub
      using Refinements::Struct

      def self.call(...) = new(...).call

      def initialize configuration, builder: Builder
        @configuration = configuration
        @builder = builder
      end

      def call
        render_funding

        return configuration unless configuration.build_git_hub

        builder.call(with_issue_template).render
        builder.call(with_pull_request_template).render
        configuration
      end

      private

      attr_reader :configuration, :builder

      def render_funding
        return unless configuration.build_funding

        configuration.merge(template_path: "%project_name%/.github/FUNDING.yml.erb")
                     .then { |updated_configuration| builder.call(updated_configuration).render }
      end

      def with_issue_template
        configuration.merge template_path: "%project_name%/.github/ISSUE_TEMPLATE.md.erb"
      end

      def with_pull_request_template
        configuration.merge template_path: "%project_name%/.github/PULL_REQUEST_TEMPLATE.md.erb"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubysmith-6.6.0 lib/rubysmith/builders/git_hub.rb
rubysmith-6.5.0 lib/rubysmith/builders/git_hub.rb
rubysmith-6.4.0 lib/rubysmith/builders/git_hub.rb
rubysmith-6.3.0 lib/rubysmith/builders/git_hub.rb
rubysmith-6.2.1 lib/rubysmith/builders/git_hub.rb
rubysmith-6.2.0 lib/rubysmith/builders/git_hub.rb
rubysmith-6.1.0 lib/rubysmith/builders/git_hub.rb
rubysmith-6.0.0 lib/rubysmith/builders/git_hub.rb