Sha256: 9df8791c7939946cfa13e2fd75859e823f672dee4a1a25ebe553a5b5cc2265d6

Contents?: true

Size: 942 Bytes

Versions: 7

Compression:

Stored size: 942 Bytes

Contents

# frozen_string_literal: true

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

7 entries across 7 versions & 1 rubygems

Version Path
milestoner-17.6.0 lib/milestoner/builders/web.rb
milestoner-17.5.0 lib/milestoner/builders/web.rb
milestoner-17.4.0 lib/milestoner/builders/web.rb
milestoner-17.3.0 lib/milestoner/builders/web.rb
milestoner-17.2.0 lib/milestoner/builders/web.rb
milestoner-17.1.0 lib/milestoner/builders/web.rb
milestoner-17.0.0 lib/milestoner/builders/web.rb