From e2c40b20a8e823abf143ddb17ddb9f13c0a2dd78 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Tue, 23 Mar 2021 11:54:34 +0100 Subject: [PATCH] Change detection for crosscite format Look for snake case field to determine if it's crosscite. This is because it's very similiar to datacite_json, the difference being it is camelCase vs snakeCase --- lib/bolognese/utils.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bolognese/utils.rb b/lib/bolognese/utils.rb index 5e87ee68..3f79670a 100644 --- a/lib/bolognese/utils.rb +++ b/lib/bolognese/utils.rb @@ -534,7 +534,7 @@ def find_from_format_by_ext(string, options={}) "codemeta" elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("schemaVersion").to_s.start_with?("http://datacite.org/schema/kernel") "datacite_json" - elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("types") + elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("types") && Maremma.from_json(string).to_h.dig("publication_year").present? "crosscite" elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("issued", "date-parts").present? "citeproc" @@ -552,7 +552,7 @@ def find_from_format_by_string(string) "codemeta" elsif Maremma.from_json(string).to_h.dig("schema-version").to_s.start_with?("http://datacite.org/schema/kernel") "datacite_json" - elsif Maremma.from_json(string).to_h.dig("types").present? + elsif Maremma.from_json(string).to_h.dig("types").present? && Maremma.from_json(string).to_h.dig("publication_year").present? "crosscite" elsif Maremma.from_json(string).to_h.dig("issued", "date-parts").present? "citeproc"