Sha256: 8df71414c7e8d8cc0b56ee45610258eb78d88fb920aad1d8acefb248b64f7a51

Contents?: true

Size: 1006 Bytes

Versions: 6

Compression:

Stored size: 1006 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "refinements/pathname"

module Milestoner
  module Builders
    # Builds syndicated feed output.
    class Feed
      include Milestoner::Import[:settings, :logger]

      using Refinements::Pathname

      def initialize(tagger: Commits::Tagger.new, syndicator: Syndication::Builder.new, **)
        @tagger = tagger
        @syndicator = syndicator
        super(**)
      end

      def call
        tagger.call
              .bind { |tags| syndicator.call tags }
              .fmap { |body| write body }
              .alt_map { |message| failure message }
      end

      private

      attr_reader :tagger, :syndicator

      def write body
        root = settings.build_root
        path = root.join(settings.build_basename).make_ancestors.sub_ext(".xml").write body

        logger.info { "Built: #{path}." }
        root
      end

      def failure message
        logger.error { message }
        message
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
milestoner-18.10.0 lib/milestoner/builders/feed.rb
milestoner-18.9.0 lib/milestoner/builders/feed.rb
milestoner-18.8.0 lib/milestoner/builders/feed.rb
milestoner-18.7.0 lib/milestoner/builders/feed.rb
milestoner-18.6.0 lib/milestoner/builders/feed.rb
milestoner-18.5.0 lib/milestoner/builders/feed.rb