Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow director and unknown editor types #58

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,4 +1270,62 @@ Martin}}"#;
Ok(PermissiveType::Typed(vec![1..1]))
);
}

#[test]
fn test_editor_types() {
let contents = fs::read_to_string("tests/editortypes.bib").unwrap();
let bibliography = Bibliography::parse(&contents).unwrap();
let video = bibliography.get("acerolaThisDifferenceGaussians2022").unwrap();
assert_eq!(
video.editors(),
Ok(vec![(
vec![Person {
name: "Acerola".into(),
given_name: "".into(),
prefix: "".into(),
suffix: "".into()
}],
EditorType::Director
)])
);

let music = bibliography.get("mozart_KV183_1773").unwrap();
assert_eq!(
music.editors(),
Ok(vec![(
vec![Person {
name: "Mozart".into(),
given_name: "Wolfgang Amadeus".into(),
prefix: "".into(),
suffix: "".into()
}],
EditorType::Unknown("pianist".into()),
)])
);

let audio = bibliography.get("Smith2018").unwrap();
assert_eq!(
audio.editors(),
Ok(vec![
(
vec![Person {
name: "Smith".into(),
given_name: "Stacey Vanek".into(),
prefix: "".into(),
suffix: "".into()
}],
EditorType::Unknown("host".into()),
),
(
vec![Person {
name: "Plotkin".into(),
given_name: "Stanley".into(),
prefix: "".into(),
suffix: "".into()
}],
EditorType::Unknown("participant".into()),
)
])
);
}
}
6 changes: 5 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl Type for Pagination {
/// Which role the according editor had.
///
/// The value of the `editor` through `editorc` fields.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Display, EnumString, AsRefStr)]
#[derive(Debug, Clone, Eq, PartialEq, Display, EnumString, AsRefStr)]
#[strum(serialize_all = "snake_case")]
#[allow(missing_docs)]
pub enum EditorType {
Expand All @@ -331,6 +331,10 @@ pub enum EditorType {
Reviser,
Collaborator,
Organizer,
Director,

#[strum(default)]
Unknown(String),
}

impl Type for EditorType {
Expand Down
37 changes: 37 additions & 0 deletions tests/editortypes.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@video{acerolaThisDifferenceGaussians2022,
entrysubtype = {video},
title = {This Is the {{Difference}} of {{Gaussians}}},
editor = {{Acerola}},
editortype = {director},
date = {2022-12-24},
url = {https://www.youtube.com/watch?v=5EuYKEvugLU},
urldate = {2023-09-16},
abstract = {In the realm of image based edge detection, aesthetically pleasing edges are hard to come by. But, what if we could get stylized edge lines by just blurring our image twice?}
}

@misc{mozart_KV183_1773,
author = {Mozart, Wolfgang Amadeus},
title = {Sinfonie g-Moll},
year = {1773},
address = {Salzburg},
editor = {Mozart, Wolfgang Amadeus},
editortype = {pianist},
note = {New K{\"o}chelverzeichnis Nr. 183, old version Nr. 25;
Erster Satz: Allegro con brio, Zweiter Satz: Andante,
Dritter Satz: Menuetto, Vierter Satz: Allegro},
}

@audio{Smith2018,
author={Stacey Vanek Smith and Stanley Plotkin},
title={The Economics of Vaccines},
howpublished={NPR},
organization={Planet Money},
month=6,
year=2010,
editora={Stacey Vanek Smith},
editoratype={host},
editorb={Stanley Plotkin},
editorbtype={participant},
series={Planet Money},
url={https://www.npr.org/templates/transcript/transcript.php?storyId=616926505}
}