From 56bb83e8644055d83b23e46b08a1a4ed9b783f43 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:59:03 +0000 Subject: [PATCH 1/4] Initial plan From d1fa07ae8f65af17a3ef211ec722f693b918f5cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 14:07:21 +0000 Subject: [PATCH 2/4] Fix APA style output for hyphenated first names Co-authored-by: hainesr <143558+hainesr@users.noreply.github.com> --- lib/cff/formatters/formatter.rb | 6 +++++- test/files/formatted/hyphenated-names.apa | 1 + test/files/formatter/hyphenated-names.cff | 9 +++++++++ test/formatters/formatter_test.rb | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/files/formatted/hyphenated-names.apa create mode 100644 test/files/formatter/hyphenated-names.cff diff --git a/lib/cff/formatters/formatter.rb b/lib/cff/formatters/formatter.rb index 02731d4..509c3fd 100644 --- a/lib/cff/formatters/formatter.rb +++ b/lib/cff/formatters/formatter.rb @@ -40,8 +40,12 @@ def self.select_and_check_model(model, preferred_citation) model.authors.empty? || model.title.empty? ? nil : model end + def self.initial_from_name_part(part) + part.split('-').filter_map { |sub| sub[0]&.capitalize }.join('.-') + end + def self.initials(name) - name.split.map { |part| part[0].capitalize }.join('. ') + name.split.map { |part| initial_from_name_part(part) }.join('. ') end def self.note_from_model(model) diff --git a/test/files/formatted/hyphenated-names.apa b/test/files/formatted/hyphenated-names.apa new file mode 100644 index 0000000..3b0aa94 --- /dev/null +++ b/test/files/formatted/hyphenated-names.apa @@ -0,0 +1 @@ +Kling, M.-U., & Picard, J.-L. (2021). Hyphenated names test [Computer software] diff --git a/test/files/formatter/hyphenated-names.cff b/test/files/formatter/hyphenated-names.cff new file mode 100644 index 0000000..c143489 --- /dev/null +++ b/test/files/formatter/hyphenated-names.cff @@ -0,0 +1,9 @@ +cff-version: 1.2.0 +message: If you use this software, please cite it as below. +authors: + - family-names: Kling + given-names: Marc-Uwe + - family-names: Picard + given-names: Jean-Luc +title: Hyphenated names test +date-released: 2021-09-21 diff --git a/test/formatters/formatter_test.rb b/test/formatters/formatter_test.rb index 63c6ba0..44aed9b 100644 --- a/test/formatters/formatter_test.rb +++ b/test/formatters/formatter_test.rb @@ -20,6 +20,21 @@ require 'cff/index' class CFFFormatterTest < Minitest::Test + def test_initial_from_name_part + assert_equal 'A', CFF::Formatters::Formatter.initial_from_name_part('Arfon') + assert_equal 'M', CFF::Formatters::Formatter.initial_from_name_part('M.') + assert_equal 'M.-U', CFF::Formatters::Formatter.initial_from_name_part('Marc-Uwe') + assert_equal 'J.-L', CFF::Formatters::Formatter.initial_from_name_part('Jean-Luc') + assert_equal 'A.-B.-C', CFF::Formatters::Formatter.initial_from_name_part('A-B-C') + end + + def test_initials + assert_equal 'A. M', CFF::Formatters::Formatter.initials('Arfon M.') + assert_equal 'M.-U', CFF::Formatters::Formatter.initials('Marc-Uwe') + assert_equal 'J.-L. P', CFF::Formatters::Formatter.initials('Jean-Luc Picard') + assert_equal 'A. B. C', CFF::Formatters::Formatter.initials('Arfon B. C.') + end + def test_month_and_year_from_date [nil, '', ' ', 'nil'].each do |date| assert_equal(['', ''], CFF::Formatters::Formatter.month_and_year_from_date(date)) From f5ab0236861f918ee6c36b22aeaa7766ce94e03b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 14:57:25 +0000 Subject: [PATCH 3/4] Fix CI failures and address review feedback for hyphenated names Co-authored-by: hainesr <143558+hainesr@users.noreply.github.com> --- lib/cff/formatters/formatter.rb | 2 ++ test/files/formatted/hyphenated-names.apa | 2 +- test/files/formatted/hyphenated-names.bibtex | 6 ++++++ test/files/formatter/hyphenated-names.cff | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/files/formatted/hyphenated-names.bibtex diff --git a/lib/cff/formatters/formatter.rb b/lib/cff/formatters/formatter.rb index 509c3fd..b557d06 100644 --- a/lib/cff/formatters/formatter.rb +++ b/lib/cff/formatters/formatter.rb @@ -41,6 +41,8 @@ def self.select_and_check_model(model, preferred_citation) end def self.initial_from_name_part(part) + return part[0].capitalize unless part.include?('-') + part.split('-').filter_map { |sub| sub[0]&.capitalize }.join('.-') end diff --git a/test/files/formatted/hyphenated-names.apa b/test/files/formatted/hyphenated-names.apa index 3b0aa94..4a589ed 100644 --- a/test/files/formatted/hyphenated-names.apa +++ b/test/files/formatted/hyphenated-names.apa @@ -1 +1 @@ -Kling, M.-U., & Picard, J.-L. (2021). Hyphenated names test [Computer software] +Kling, M.-U., Picard, J.-L., & Smith, J. (2021). Hyphenated names test [Computer software] diff --git a/test/files/formatted/hyphenated-names.bibtex b/test/files/formatted/hyphenated-names.bibtex new file mode 100644 index 0000000..12a767a --- /dev/null +++ b/test/files/formatted/hyphenated-names.bibtex @@ -0,0 +1,6 @@ +@software{Kling_Hyphenated_names_test_2021, +author = {Kling, Marc-Uwe and Picard, Jean-Luc and Smith, John}, +month = sep, +title = {{Hyphenated names test}}, +year = {2021} +} diff --git a/test/files/formatter/hyphenated-names.cff b/test/files/formatter/hyphenated-names.cff index c143489..5be3d82 100644 --- a/test/files/formatter/hyphenated-names.cff +++ b/test/files/formatter/hyphenated-names.cff @@ -5,5 +5,7 @@ authors: given-names: Marc-Uwe - family-names: Picard given-names: Jean-Luc + - family-names: Smith + given-names: John title: Hyphenated names test date-released: 2021-09-21 From 504ccaae8078602cce69eb1fecf4508f6aa61cb2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:59:03 +0000 Subject: [PATCH 4/4] Initial plan