Sha256: c87b76eb03f37b7f6b7c512108a6a7e1c99a6bf9663f4a9276be63a8676fefae

Contents?: true

Size: 953 Bytes

Versions: 5

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

require "cff"
require "dry/monads"
require "pathname"
require "refinements/hash"

module Milestoner
  module Configuration
    module Transformers
      module Citations
        # Conditionally updates project description based on citation details.
        class Description
          include Dry::Monads[:result]

          using Refinements::Hash

          def initialize key = :project_description,
                         path: Pathname.pwd.join("CITATION.cff"),
                         citation: CFF::File
            @key = key
            @path = path
            @citation = citation
          end

          def call attributes
            attributes.fetch key do
              attributes.merge!(key => citation.open(path).abstract).compress!
            end

            Success attributes
          end

          private

          attr_reader :key, :path, :citation
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
milestoner-18.3.0 lib/milestoner/configuration/transformers/citations/description.rb
milestoner-18.2.0 lib/milestoner/configuration/transformers/citations/description.rb
milestoner-18.1.0 lib/milestoner/configuration/transformers/citations/description.rb
milestoner-18.0.1 lib/milestoner/configuration/transformers/citations/description.rb
milestoner-18.0.0 lib/milestoner/configuration/transformers/citations/description.rb