Sha256: c84a4f02a0092dc16f3a32581bb7444fb460a8cc84c9eaee98b571db24dd35a4

Contents?: true

Size: 904 Bytes

Versions: 9

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

require "refinements/structs"
require "tocer"

module Rubysmith
  module Builders
    module Documentation
      # Builds project skeleton README documentation.
      class Readme
        using Refinements::Structs

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

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

        def call
          return configuration unless configuration.build_readme

          builder.call(configuration.merge(template_path: "%project_name%/README.#{kind}.erb"))
                 .render
                 .replace(/\n{2,}/, "\n\n")
                 .replace("\n    \n", "\n")

          configuration
        end

        private

        attr_reader :configuration, :builder

        def kind = configuration.documentation_format
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubysmith-5.5.0 lib/rubysmith/builders/documentation/readme.rb
rubysmith-5.4.0 lib/rubysmith/builders/documentation/readme.rb
rubysmith-5.3.0 lib/rubysmith/builders/documentation/readme.rb
rubysmith-5.2.0 lib/rubysmith/builders/documentation/readme.rb
rubysmith-5.1.0 lib/rubysmith/builders/documentation/readme.rb
rubysmith-5.0.1 lib/rubysmith/builders/documentation/readme.rb
rubysmith-4.9.0 lib/rubysmith/builders/documentation/readme.rb
rubysmith-4.8.0 lib/rubysmith/builders/documentation/readme.rb
rubysmith-4.7.0 lib/rubysmith/builders/documentation/readme.rb