Sha256: f33412e166f9aec09393e7c52fe3db8645b16d85ef036045e8a0622a0ffd948c

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 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
      end

      def kind
        realm.documentation_format || "md"
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubysmith-0.3.0 lib/rubysmith/builders/documentation.rb
rubysmith-0.2.0 lib/rubysmith/builders/documentation.rb
rubysmith-0.1.1 lib/rubysmith/builders/documentation.rb
rubysmith-0.1.0 lib/rubysmith/builders/documentation.rb