Sha256: 0ae0ec4e73c06a34c7b182e130e5b0f2f582b4d87f98248b56b5a149d2f83a34
Contents?: true
Size: 926 Bytes
Versions: 1
Compression:
Stored size: 926 Bytes
Contents
# frozen_string_literal: true require "cff" require "dry/monads" require "pathname" module Milestoner module Configuration module Transformers module Citations # Conditionally updates project label based on citation details. class Label include Dry::Monads[:result] def initialize key = :project_label, path: Pathname.pwd.join("CITATION.cff"), citation: CFF::File @key = key @path = path @citation = citation end def call(content) = Success process(content) private attr_reader :key, :path, :citation def process content content.fetch(key) { citation.open(path).title } .then { |value| String(value).empty? ? content : content.merge!(key => value) } end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
milestoner-17.0.0 | lib/milestoner/configuration/transformers/citations/label.rb |