Skip to content

Commit

Permalink
Support EcoEvoRxiv preprints
Browse files Browse the repository at this point in the history
Refs #290
  • Loading branch information
thewilkybarkid committed May 2, 2024
1 parent a390309 commit 38ed884
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/CrossrefPreprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface CrossrefPreprint {
readonly authors: ReadonlyArray<string>
readonly doi: Doi.Doi
readonly posted: Temporal.PlainDate
readonly server: 'biorxiv' | 'edarxiv' | 'medrxiv' | 'osf-preprints' | 'psyarxiv' | 'scielo'
readonly server: 'biorxiv' | 'ecoevorxiv' | 'edarxiv' | 'medrxiv' | 'osf-preprints' | 'psyarxiv' | 'scielo'
readonly title: string
}

Expand Down Expand Up @@ -46,6 +46,7 @@ export const getPreprintFromCrossref = (
Match.when(['1590'], () => 'scielo' as const),
Match.when(['31219', { 'group-title': 'Open Science Framework' }], () => 'osf-preprints' as const),
Match.when(['31234', { 'group-title': 'PsyArXiv' }], () => 'psyarxiv' as const),
Match.when(['32942'], () => 'ecoevorxiv' as const),
Match.when(['35542', { 'group-title': 'EdArXiv' }], () => 'edarxiv' as const),
Match.either,
Either.mapLeft(() => new GetPreprintFromCrossrefError({ message: 'Not from a supported server' })),
Expand Down
5 changes: 4 additions & 1 deletion src/Preprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const getPreprint: (
doi: Doi.Doi,
) => Effect.Effect<Preprint, GetPreprintError, Crossref.CrossrefApi | Datacite.DataciteApi> = flow(
Match.value,
Match.when(Doi.hasRegistrant('1101', '1590', '31219', '31234', '35542'), CrossrefPreprint.getPreprintFromCrossref),
Match.when(
Doi.hasRegistrant('1101', '1590', '31219', '31234', '32942', '35542'),
CrossrefPreprint.getPreprintFromCrossref,
),
Match.when(Doi.hasRegistrant('48550'), DatacitePreprint.getPreprintFromDatacite),
Match.orElse(() => Effect.fail('Not from a supported server')),
Effect.mapError(toGetPreprintError),
Expand Down
1 change: 1 addition & 0 deletions src/ReviewRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ ${Array.match(preprint.authors, {
Preprint server: """${Match.value(preprint.server).pipe(
Match.when('arxiv', () => 'arXiv'),
Match.when('biorxiv', () => 'bioRxiv'),
Match.when('ecoevorxiv', () => 'EcoEvoRxiv'),
Match.when('edarxiv', () => 'EdArXiv'),
Match.when('medrxiv', () => 'medRxiv'),
Match.when('osf-preprints', () => 'OSF Preprints'),
Expand Down
16 changes: 11 additions & 5 deletions test/CrossrefPreprint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ describe('getPreprintFromCrossref', () => {
fc.constant('PsyArXiv'),
fc.constant('psyarxiv'),
),
fc.tuple(
fc.doi({ registrant: fc.constant('32942') }),
fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }),
fc.option(fc.string(), { nil: undefined }),
fc.constant('ecoevorxiv'),
),
fc.tuple(
fc.doi({ registrant: fc.constant('35542') }),
fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }),
Expand Down Expand Up @@ -101,7 +107,7 @@ describe('getPreprintFromCrossref', () => {
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.constant('1590') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
title: fc.constant([]),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
Expand Down Expand Up @@ -154,7 +160,7 @@ describe('getPreprintFromCrossref', () => {
}),
fc.crossrefWork({
abstract: fc.constant(undefined),
DOI: fc.doi({ registrant: fc.constant('1590') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
Expand Down Expand Up @@ -211,7 +217,7 @@ describe('getPreprintFromCrossref', () => {
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constant('1590') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
published: fc.oneof(fc.plainYear(), fc.plainYearMonth()),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
Expand Down Expand Up @@ -272,7 +278,7 @@ describe('getPreprintFromCrossref', () => {
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constant('1590') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
published: fc.constant(undefined),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
Expand Down Expand Up @@ -347,7 +353,7 @@ describe('getPreprintFromCrossref', () => {
fc.doi(),
fc.oneof(
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.doiRegistrant().filter(registrant => !['1590'].includes(registrant)) }),
DOI: fc.doi({ registrant: fc.doiRegistrant().filter(registrant => !['1590', '32942'].includes(registrant)) }),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
Expand Down

0 comments on commit 38ed884

Please sign in to comment.