Sha256: bbdebeb859d12b91b9435f044a2cb1072b234995af6e8bdf5a26e70f06af23f2
Contents?: true
Size: 996 Bytes
Versions: 3
Compression:
Stored size: 996 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_value(key) { citation.open(path).title } .then { |value| value unless String(value).empty? } .then { |value| Success attributes.merge!(key => value) } end private attr_reader :key, :path, :citation end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems