Sha256: 4b4fa05df0a1876009110faed087a36fa6a7b9c124e309139342add7d56765ed

Contents?: true

Size: 1.2 KB

Versions: 31

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require "refinements/structs"

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

      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

31 entries across 31 versions & 1 rubygems

Version Path
rubysmith-5.9.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.8.1 lib/rubysmith/builders/git_hub.rb
rubysmith-5.8.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.7.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.6.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.5.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.4.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.3.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.2.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.1.0 lib/rubysmith/builders/git_hub.rb
rubysmith-5.0.1 lib/rubysmith/builders/git_hub.rb
rubysmith-4.9.0 lib/rubysmith/builders/git_hub.rb
rubysmith-4.8.0 lib/rubysmith/builders/git_hub.rb
rubysmith-4.7.0 lib/rubysmith/builders/git_hub.rb
rubysmith-4.6.1 lib/rubysmith/builders/git_hub.rb
rubysmith-4.6.0 lib/rubysmith/builders/git_hub.rb
rubysmith-4.5.0 lib/rubysmith/builders/git_hub.rb
rubysmith-4.4.0 lib/rubysmith/builders/git_hub.rb
rubysmith-4.3.0 lib/rubysmith/builders/git_hub.rb
rubysmith-4.2.0 lib/rubysmith/builders/git_hub.rb