Sha256: 286bc082a5e55fe7cd1bbabef37f675cb010e9f12eb52f033659d43a09abf3a8

Contents?: true

Size: 903 Bytes

Versions: 5

Compression:

Stored size: 903 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 label based on citation details.
        class Label
          include Dry::Monads[:result]

          using Refinements::Hash

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

          def call attributes
            attributes.fetch(key) { attributes.merge!(key => citation.open(path).title).compress! }
            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/label.rb
milestoner-18.2.0 lib/milestoner/configuration/transformers/citations/label.rb
milestoner-18.1.0 lib/milestoner/configuration/transformers/citations/label.rb
milestoner-18.0.1 lib/milestoner/configuration/transformers/citations/label.rb
milestoner-18.0.0 lib/milestoner/configuration/transformers/citations/label.rb