Sha256: 3d7f4852fb63c880c797dda991338b6c99bf5be8666bc50525e95794af226f8c

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 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__ method }
      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

4 entries across 4 versions & 1 rubygems

Version Path
rubysmith-0.7.0 lib/rubysmith/builders/documentation.rb
rubysmith-0.6.1 lib/rubysmith/builders/documentation.rb
rubysmith-0.6.0 lib/rubysmith/builders/documentation.rb
rubysmith-0.5.0 lib/rubysmith/builders/documentation.rb