Skip to content

Commit

Permalink
Merge pull request #294 from citation-file-format/285-email-in-codemeta
Browse files Browse the repository at this point in the history
Add email to author data for 1.2.0 and CodeMeta output
  • Loading branch information
jspaaks authored Jul 11, 2023
2 parents 06b41c2 + f6e3f24 commit 163b9cf
Show file tree
Hide file tree
Showing 29 changed files with 1,200 additions and 69 deletions.
3 changes: 2 additions & 1 deletion cffconvert/behavior_1_0_x/schemaorg_author.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def as_dict(self):
'_',
self._has_name(),
self._has_affiliation(),
self._has_orcid()
self._has_orcid(),
self._has_email()
])
return self._behaviors[key]()
3 changes: 2 additions & 1 deletion cffconvert/behavior_1_1_x/schemaorg_author.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def as_dict(self):
self._has_alias(),
self._has_name(),
self._has_affiliation(),
self._has_orcid()
self._has_orcid(),
self._has_email()
])
return self._behaviors[key]()
3 changes: 2 additions & 1 deletion cffconvert/behavior_1_2_x/schemaorg_author.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def as_dict(self):
self._has_alias(),
self._has_name(),
self._has_affiliation(),
self._has_orcid()
self._has_orcid(),
self._has_email()
])
return self._behaviors[key]()
6 changes: 6 additions & 0 deletions cffconvert/behavior_shared/abstract_author_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ def _has_orcid(self):
if value is not None and value != '':
return 'O'
return '_'

def _has_email(self):
value = self._author.get('email', None)
if value is not None and value != '':
return 'E'
return '_'
857 changes: 793 additions & 64 deletions cffconvert/behavior_shared/schemaorg_author_shared.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/1.0.3/01/CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors:
affiliation: "Netherlands eScience Center"
family-names: Spaaks
given-names: Jurriaan H.
email: my@email.notexist
-
affiliation: "Netherlands eScience Center"
family-names: Klaver
Expand Down
1 change: 1 addition & 0 deletions test/1.0.3/01/codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@type": "Organization",
"legalName": "Netherlands eScience Center"
},
"email": "my@email.notexist",
"familyName": "Spaaks",
"givenName": "Jurriaan H."
},
Expand Down
1 change: 1 addition & 0 deletions test/1.0.3/01/schemaorg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@type": "Organization",
"legalName": "Netherlands eScience Center"
},
"email": "my@email.notexist",
"familyName": "Spaaks",
"givenName": "Jurriaan H."
},
Expand Down
3 changes: 2 additions & 1 deletion test/1.0.3/01/test_1_0_3__01_codemeta_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def test_author(self, codemeta_object):
"legalName": "Netherlands eScience Center"
},
"familyName": "Spaaks",
"givenName": "Jurriaan H."
"givenName": "Jurriaan H.",
"email": "my@email.notexist"
}, {
"@type": "Person",
"affiliation": {
Expand Down
3 changes: 2 additions & 1 deletion test/1.0.3/01/test_1_0_3__01_schemaorg_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def test_author(self, schemaorg_object):
"legalName": "Netherlands eScience Center"
},
"familyName": "Spaaks",
"givenName": "Jurriaan H."
"givenName": "Jurriaan H.",
"email": "my@email.notexist"
}, {
"@type": "Person",
"affiliation": {
Expand Down
1 change: 1 addition & 0 deletions test/1.1.0/01/CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors:
affiliation: "Netherlands eScience Center"
family-names: Spaaks
given-names: Jurriaan H.
email: my@email.notexist
-
affiliation: "Netherlands eScience Center"
family-names: Klaver
Expand Down
1 change: 1 addition & 0 deletions test/1.1.0/01/codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@type": "Organization",
"legalName": "Netherlands eScience Center"
},
"email": "my@email.notexist",
"familyName": "Spaaks",
"givenName": "Jurriaan H."
},
Expand Down
1 change: 1 addition & 0 deletions test/1.1.0/01/schemaorg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@type": "Organization",
"legalName": "Netherlands eScience Center"
},
"email": "my@email.notexist",
"familyName": "Spaaks",
"givenName": "Jurriaan H."
},
Expand Down
1 change: 1 addition & 0 deletions test/1.1.0/01/test_1_1_0__01_codemeta_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_author(self, codemeta_object):
"@type": "Organization",
"legalName": "Netherlands eScience Center"
},
"email": "my@email.notexist",
"familyName": "Spaaks",
"givenName": "Jurriaan H."
}, {
Expand Down
1 change: 1 addition & 0 deletions test/1.1.0/01/test_1_1_0__01_schemaorg_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_author(self, schemaorg_object):
"@type": "Organization",
"legalName": "Netherlands eScience Center"
},
"email": "my@email.notexist",
"familyName": "Spaaks",
"givenName": "Jurriaan H."
}, {
Expand Down
10 changes: 10 additions & 0 deletions test/1.2.0/authors-creators/one/GFA_AOE/.zenodo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"creators": [
{
"affiliation": "Netherlands eScience Center",
"name": "von der Spaaks Jr., Jurriaan H.",
"orcid": "0000-0002-7064-4069"
}
],
"title": "the title"
}
12 changes: 12 additions & 0 deletions test/1.2.0/authors-creators/one/GFA_AOE/CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
authors:
- given-names: Jurriaan H.
name-particle: von der
family-names: Spaaks
name-suffix: Jr.
alias: jspaaks
orcid: https://orcid.org/0000-0002-7064-4069
affiliation: Netherlands eScience Center
email: my@email.notexist
cff-version: "1.2.0"
message: "test of author inputs"
title: the title
1 change: 1 addition & 0 deletions test/1.2.0/authors-creators/one/GFA_AOE/apalike.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
von der Spaaks Jr. J.H. the title
4 changes: 4 additions & 0 deletions test/1.2.0/authors-creators/one/GFA_AOE/bibtex.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@misc{YourReferenceHere,
author = {von der Spaaks Jr., Jurriaan H.},
title = {the title}
}
3 changes: 3 additions & 0 deletions test/1.2.0/authors-creators/one/GFA_AOE/endnote.enw
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%0 Generic
%A von der Spaaks Jr., Jurriaan H.
%T the title
4 changes: 4 additions & 0 deletions test/1.2.0/authors-creators/one/GFA_AOE/ris.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TY - GEN
AU - von der Spaaks Jr., Jurriaan H.
TI - the title
ER
19 changes: 19 additions & 0 deletions test/1.2.0/authors-creators/one/GFA_AOE/schemaorg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"@context": "https://schema.org",
"@type": "SoftwareSourceCode",
"author": [
{
"@id": "https://orcid.org/0000-0002-7064-4069",
"@type": "Person",
"affiliation": {
"@type": "Organization",
"legalName": "Netherlands eScience Center"
},
"alternateName": "jspaaks",
"email": "my@email.notexist",
"familyName": "von der Spaaks Jr.",
"givenName": "Jurriaan H."
}
],
"name": "the title"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import pytest
from test.contracts.apalike_object import Contract
from cffconvert.behavior_1_2_x.apalike_object import ApalikeObject
from cffconvert import Citation


@pytest.fixture(scope="module")
def apalike_object():
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
with open(fixture, "rt", encoding="utf-8") as f:
cffstr = f.read()
citation = Citation(cffstr)
return ApalikeObject(citation.cffobj, initialize_empty=True)


class TestApalikeObject(Contract):

def test_author(self, apalike_object):
assert apalike_object.add_author().author == 'von der Spaaks Jr. J.H.'

def test_check_cffobj(self, apalike_object):
apalike_object.check_cffobj()
# doesn't need an assert

def test_doi(self, apalike_object):
assert apalike_object.add_doi().doi is None

def test_as_string(self, apalike_object):
actual_apalike = apalike_object.add_all().as_string()
fixture = os.path.join(os.path.dirname(__file__), "apalike.txt")
with open(fixture, "rt", encoding="utf-8") as f:
expected_apalike = f.read()
assert actual_apalike == expected_apalike

def test_title(self, apalike_object):
assert apalike_object.add_title().title == 'the title'

def test_url(self, apalike_object):
assert apalike_object.add_url().url is None

def test_version(self, apalike_object):
assert apalike_object.add_version().version is None

def test_year(self, apalike_object):
assert apalike_object.add_year().year is None
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import pytest
from test.contracts.bibtex_object import Contract
from cffconvert.behavior_1_2_x.bibtex_object import BibtexObject
from cffconvert import Citation


@pytest.fixture(scope="module")
def bibtex_object():
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
with open(fixture, "rt", encoding="utf-8") as f:
cffstr = f.read()
citation = Citation(cffstr)
return BibtexObject(citation.cffobj, initialize_empty=True)


class TestBibtexObject(Contract):

def test_author(self, bibtex_object):
assert bibtex_object.add_author().author == 'author = {von der Spaaks Jr., Jurriaan H.}'

def test_check_cffobj(self, bibtex_object):
bibtex_object.check_cffobj()
# doesn't need an assert

def test_doi(self, bibtex_object):
assert bibtex_object.add_doi().doi is None

def test_month(self, bibtex_object):
assert bibtex_object.add_month().month is None

def test_as_string(self, bibtex_object):
actual_bibtex = bibtex_object.add_all().as_string()
fixture = os.path.join(os.path.dirname(__file__), "bibtex.bib")
with open(fixture, "rt", encoding="utf-8") as f:
expected_bibtex = f.read()
assert actual_bibtex == expected_bibtex

def test_title(self, bibtex_object):
assert bibtex_object.add_title().title == 'title = {the title}'

def test_url(self, bibtex_object):
assert bibtex_object.add_url().url is None

def test_year(self, bibtex_object):
assert bibtex_object.add_year().year is None
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import pytest
from cffconvert.citation import Citation


@pytest.fixture(scope="module")
def citation():
p = os.path.join(os.path.dirname(__file__), "CITATION.cff")
with open(p, "rt", encoding="utf-8") as fid:
cffstr = fid.read()
return Citation(cffstr)


def test_cffversion(citation):
assert citation.cffversion == "1.2.0"


def test_validate(citation):
citation.validate()
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import pytest
from test.contracts.endnote_object import Contract
from cffconvert.behavior_1_2_x.endnote_object import EndnoteObject
from cffconvert import Citation


@pytest.fixture(scope="module")
def endnote_object():
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
with open(fixture, "rt", encoding="utf-8") as f:
cffstr = f.read()
citation = Citation(cffstr)
return EndnoteObject(citation.cffobj, initialize_empty=True)


class TestEndnoteObject(Contract):

def test_check_cffobj(self, endnote_object):
endnote_object.check_cffobj()
# doesn't need an assert

def test_author(self, endnote_object):
assert endnote_object.add_author().author == '%A von der Spaaks Jr., Jurriaan H.\n'

def test_doi(self, endnote_object):
assert endnote_object.add_doi().doi is None

def test_keyword(self, endnote_object):
assert endnote_object.add_keyword().keyword is None

def test_name(self, endnote_object):
assert endnote_object.add_name().name == '%T the title\n'

def test_as_string(self, endnote_object):
actual_endnote = endnote_object.add_all().as_string()
fixture = os.path.join(os.path.dirname(__file__), "endnote.enw")
with open(fixture, "rt", encoding="utf-8") as f:
expected_endnote = f.read()
assert actual_endnote == expected_endnote

def test_url(self, endnote_object):
assert endnote_object.add_url().url is None

def test_year(self, endnote_object):
assert endnote_object.add_year().year is None
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import pytest
from test.contracts.ris_object import Contract
from cffconvert.behavior_1_2_x.ris_object import RisObject
from cffconvert import Citation


@pytest.fixture(scope="module")
def ris_object():
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
with open(fixture, "rt", encoding="utf-8") as f:
cffstr = f.read()
citation = Citation(cffstr)
return RisObject(citation.cffobj, initialize_empty=True)


class TestRisObject(Contract):

def test_abstract(self, ris_object):
assert ris_object.add_abstract().abstract is None

def test_author(self, ris_object):
assert ris_object.add_author().author == 'AU - von der Spaaks Jr., Jurriaan H.\n'

def test_check_cffobj(self, ris_object):
ris_object.check_cffobj()
# doesn't need an assert

def test_date(self, ris_object):
assert ris_object.add_date().date is None

def test_doi(self, ris_object):
assert ris_object.add_doi().doi is None

def test_keywords(self, ris_object):
assert ris_object.add_keywords().keywords is None

def test_as_string(self, ris_object):
actual_ris = ris_object.add_all().as_string()
fixture = os.path.join(os.path.dirname(__file__), "ris.txt")
with open(fixture, "rt", encoding="utf-8") as f:
expected_ris = f.read()
assert actual_ris == expected_ris

def test_title(self, ris_object):
assert ris_object.add_title().title == 'TI - the title\n'

def test_url(self, ris_object):
assert ris_object.add_url().url is None

def test_year(self, ris_object):
assert ris_object.add_year().year is None
Loading

0 comments on commit 163b9cf

Please sign in to comment.