Skip to content

Commit

Permalink
allow director and unknown editor types
Browse files Browse the repository at this point in the history
  • Loading branch information
PgBiel committed Sep 26, 2024
1 parent 3dd8eed commit 66ec247
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
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}
}

0 comments on commit 66ec247

Please sign in to comment.