From 171d9a4331a587b570e73636edf2f82e8e6e85bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Pa=C5=82ucha?= Date: Mon, 17 Jul 2023 17:03:37 +0100 Subject: [PATCH 1/3] Run code formater --- app/helpers/apa.rb | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/app/helpers/apa.rb b/app/helpers/apa.rb index 56befbba..5eb282ff 100644 --- a/app/helpers/apa.rb +++ b/app/helpers/apa.rb @@ -22,9 +22,7 @@ def self.format_name(name) # author_all can be passed as an Array, or a string containing all authors, e.g. ["Author1","Author2","Author3",] def self.get_apa_short_author_all_in_one(author_all, publication_year) authors = author_all - if authors.is_a? String - authors = author_all.strip.split('"').delete_if { |a| (a == '[') || a == ']' || (a == ',') } - end + authors = author_all.strip.split('"').delete_if { |a| (a == '[') || a == ']' || (a == ',') } if authors.is_a? String authors_s = '' return authors[0] + ' (' + publication_year + ')' if authors.length == 1 @@ -41,13 +39,13 @@ def self.get_apa_short_html(authors, publication_year) return '' if authors.nil? || publication_year.nil? if authors.length == 1 - return get_surname(authors[0]) + ' (' + publication_year + ')' + get_surname(authors[0]) + ' (' + publication_year + ')' elsif authors.length == 2 - return get_surname(authors[0]) + ' & ' + get_surname(authors[1]) + ' (' + publication_year + ')' + get_surname(authors[0]) + ' & ' + get_surname(authors[1]) + ' (' + publication_year + ')' elsif authors.length > 2 - return get_surname(authors[0]) + ' et al. (' + publication_year + ')' + get_surname(authors[0]) + ' et al. (' + publication_year + ')' else - return '' + '' end end @@ -188,25 +186,19 @@ def self.get_journal_string_markup(journal) end def self.get_vol_issue_string_html(vol, issue) - unless vol.nil? || issue.nil? - return html_italic(vol) + '(' + issue + ')' + ', ' - end + return html_italic(vol) + '(' + issue + ')' + ', ' unless vol.nil? || issue.nil? '' end def self.get_vol_issue_string(vol, issue) - unless vol.nil? || issue.nil? - return vol + '(' + issue + ')' + ', ' - end + return vol + '(' + issue + ')' + ', ' unless vol.nil? || issue.nil? '' end def self.get_pages_string(page_from, page_to) - if !page_from.nil? && (page_from != '') && !page_to.nil? && (page_to != '') - return page_from + '-' + page_to + '.' - end + return page_from + '-' + page_to + '.' if !page_from.nil? && (page_from != '') && !page_to.nil? && (page_to != '') '' end From 8aef431828eea1a77f8abad8c414f3b8a8782cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Pa=C5=82ucha?= Date: Mon, 17 Jul 2023 17:04:23 +0100 Subject: [PATCH 2/3] Bugfix for nil value Resolve (LAN-64)[https://dti-uoy.atlassian.net/browse/LAN-64] --- app/helpers/apa.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/helpers/apa.rb b/app/helpers/apa.rb index 5eb282ff..260af420 100644 --- a/app/helpers/apa.rb +++ b/app/helpers/apa.rb @@ -101,10 +101,12 @@ def self.get_reference_with_other_journal_name_html(authors, publication_year, t def self.get_other_journal_string_markup(other_journal_name, other_journal_url) if !other_journal_name.nil? && (other_journal_name != '') - return '[' + other_journal_name + '](' + other_journal_url +'), ' + if !other_journal_url.nil? && (other_journal_url != '') + '[' + other_journal_name + '](' + other_journal_url + '), ' + else + '[' + other_journal_name + '], ' + end end - - '' end def self.get_reference_with_other_journal_name(authors, publication_year, title, other_journal_name, other_journal_url, authority_value = true, volume, issue, page_from, page_to, doi) From 385d6eaf686a6fd06eb19b2dcdad9514b5b61b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Pa=C5=82ucha?= Date: Tue, 18 Jul 2023 15:53:49 +0100 Subject: [PATCH 3/3] Check for empty field Resolve nil + string error --- app/helpers/apa.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/apa.rb b/app/helpers/apa.rb index 260af420..45152d2c 100644 --- a/app/helpers/apa.rb +++ b/app/helpers/apa.rb @@ -110,7 +110,7 @@ def self.get_other_journal_string_markup(other_journal_name, other_journal_url) end def self.get_reference_with_other_journal_name(authors, publication_year, title, other_journal_name, other_journal_url, authority_value = true, volume, issue, page_from, page_to, doi) - j_string = other_journal_name + '. ' + j_string = other_journal_name + '. ' if !other_journal_name.nil? j_string = get_other_journal_string_markup(other_journal_name, other_journal_url) if authority_value == true get_author_string(authors) + get_publication_year_string(publication_year) +