Sha256: f463388183ff74b4b03deeebc74c3c4fd0f805cb322cf4fefc8e4f0ad4ec8230

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module Rubysmith
  module Builders
    # Builds project skeleton documentation.
    class Documentation
      def self.call realm, builder: Builder
        new(realm, builder: builder).call
      end

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

      def call
        return unless realm.build_documentation

        private_methods.grep(/render_/).each(&method(:__send__))
      end

      private

      attr_reader :realm, :builder

      def render_changes
        builder.call(realm.with(template_path: "%project_name%/CHANGES.#{kind}.erb"))
               .render
      end

      def render_conduct
        builder.call(realm.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb"))
               .render
      end

      def render_contributions
        builder.call(realm.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb"))
               .render
      end

      def render_license
        builder.call(realm.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb"))
               .render
               .rename "LICENSE.#{kind}"
      end

      def render_readme
        builder.call(realm.with(template_path: "%project_name%/README.#{kind}.erb"))
               .render
               .replace("\n\n\n", "\n\n")
      end

      def kind
        realm.documentation_format || "md"
      end

      def license
        realm.documentation_license || "mit"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubysmith-0.4.0 lib/rubysmith/builders/documentation.rb