Class: Milestoner::Configuration::Transformers::Citations::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/milestoner/configuration/transformers/citations/label.rb

Overview

Conditionally updates project label based on citation details.

Instance Method Summary collapse

Constructor Details

#initialize(key = :project_label, path: Pathname.pwd.join("CITATION.cff"), citation: CFF::File) ⇒ Label

Returns a new instance of Label.



14
15
16
17
18
19
20
# File 'lib/milestoner/configuration/transformers/citations/label.rb', line 14

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

Instance Method Details

#call(attributes) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/milestoner/configuration/transformers/citations/label.rb', line 22

def call attributes
  attributes.fetch key do
    value = citation.open(path).title
    attributes.merge! key => value unless value.empty?
  end

  Success attributes
end