Sha256: 847a47e1325047396bf6c630ea11826a78e4ac294618e63a94108e4a89e5774b

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true

require "refinements/pathname"

module Milestoner
  module Builders
    # Builds web page output (i.e. HTML and CSS).
    class Web
      include Milestoner::Import[:input]

      using Refinements::Pathname

      def initialize(view: Views::Milestones::Show.new, enricher: Commits::Enricher.new, **)
        @view = view
        @enricher = enricher
        super(**)
      end

      def call
        input.build_root.tap do |path|
          stylesheet_path.copy path.make_path.join("page.css")
          write path
        end
      end

      private

      attr_reader :view, :enricher

      def stylesheet_path
        input.build_template_paths
             .map { |path| path.join "public/page.css.erb" }
             .find(&:exist?)
      end

      def write path
        enricher.call.fmap do |commits|
          path.join("index.html").write view.call commits:, layout: input.build_layout
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milestoner-17.11.0 lib/milestoner/builders/web.rb
milestoner-17.10.0 lib/milestoner/builders/web.rb
milestoner-17.9.0 lib/milestoner/builders/web.rb