class Milestoner::Configuration::Transformers::Citations::URI
Conditionally updates project URI
based on citation URL.
Attributes
Public Class Methods
Source
# File lib/milestoner/configuration/transformers/citations/uri.rb, line 15 def initialize key = :project_uri, path: Pathname.pwd.join("CITATION.cff"), citation: CFF::File @key = key @path = path @citation = citation end
Public Instance Methods
Source
# File lib/milestoner/configuration/transformers/citations/uri.rb, line 23 def call attributes process attributes Success attributes rescue KeyError => error Failure step: :transform, payload: "Unable to transform #{key.inspect}, missing specifier: " \ "\"#{error.message[/<.+>/]}\"." end
Private Instance Methods
Source
# File lib/milestoner/configuration/transformers/citations/uri.rb, line 36 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 unless value.empty? } end