lib/milestoner/configuration/transformers/citations/uri.rb in milestoner-18.3.0 vs lib/milestoner/configuration/transformers/citations/uri.rb in milestoner-18.4.0

- old
+ new

@@ -1,22 +1,19 @@ # 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 URI based on citation URL. class URI include Dry::Monads[:result] - using Refinements::Hash - def initialize key = :project_uri, path: Pathname.pwd.join("CITATION.cff"), citation: CFF::File @key = key @path = path @@ -37,10 +34,10 @@ attr_reader :key, :path, :citation def process attributes attributes.fetch(key) { citation.open(path).url } .then { |value| value.match?(/%<.+>s/) ? format(value, attributes) : value } - .then { |value| attributes.merge!(key => value).compress! } + .then { |value| attributes.merge! key => value unless value.empty? } end end end end end