From 280d53d4a856cd0419370d4cf39ed5d2164b916e Mon Sep 17 00:00:00 2001 From: "Thomas J. Leeper" Date: Mon, 14 May 2018 17:48:36 +0100 Subject: [PATCH] allow author no affiliation --- lib/whedon.rb | 8 ++++++-- lib/whedon/author.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/whedon.rb b/lib/whedon.rb index f622e53..d955e43 100644 --- a/lib/whedon.rb +++ b/lib/whedon.rb @@ -85,8 +85,12 @@ def parse_authors(yaml) # Loop through the authors block and build up the affiliation authors_yaml.each do |author| - affiliation_index = author['affiliation'] - returned << Author.new(author['name'], author['orcid'], affiliation_index, affiliations) + if author.has_key? 'affiliation' + returned << Author.new(author['name'], author['orcid'], affiliation_index, affiliations) + else + affiliation_index = author['affiliation'] + returned << Author.new(author['name'], author['orcid'], nil, affiliations) + end end returned diff --git a/lib/whedon/author.rb b/lib/whedon/author.rb index 79e6a0c..484b660 100644 --- a/lib/whedon/author.rb +++ b/lib/whedon/author.rb @@ -18,7 +18,7 @@ def build_affiliation_string(index, affiliations_yaml) # to parse each one and build the affiliation string. author_affiliations = [] - return nil if index.nil? # Some authors don't have an affiliation + return '' if index.nil? # Some authors don't have an affiliation affiliations = if index.to_s.include?(',') index.split(',').map { |a| a.strip }