• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / bibdata / 2d1e9eb3-fa5a-4980-87e2-ef3c95fd7c17

21 Aug 2025 01:07AM UTC coverage: 91.51% (-0.2%) from 91.671%
2d1e9eb3-fa5a-4980-87e2-ef3c95fd7c17

Pull #2880

circleci

sandbergja
Re-implement pub_created_display in rust
Pull Request #2880: Re-implement pub_created_display in rust

131 of 157 new or added lines in 5 files covered. (83.44%)

7351 of 8033 relevant lines covered (91.51%)

367.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/bibdata_rs/src/marc.rs
1
use magnus::exception;
2
use marctk::Record;
3

4
mod string_normalize;
5

6
pub mod control_field;
7
pub mod fixed_field;
8
pub mod genre;
9
pub mod identifier;
10
pub mod language;
11
pub mod note;
12
pub mod publication;
13
pub mod record_facet_mapping;
14
pub mod scsb;
15
pub mod variable_length_field;
16

17
pub use string_normalize::trim_punctuation;
18

19
pub fn alma_code_start_22(code: String) -> bool {
×
20
    code.starts_with("22") && code.ends_with("06421")
×
21
}
×
22
pub fn genres(record_string: String) -> Result<Vec<String>, magnus::Error> {
×
23
    let record = get_record(&record_string)?;
×
24
    Ok(genre::genres(&record))
×
25
}
×
26

27
pub fn original_languages_of_translation(
×
28
    record_string: String,
×
29
) -> Result<Vec<String>, magnus::Error> {
×
30
    let record = get_record(&record_string)?;
×
31
    Ok(language::original_languages_of_translation(&record)
×
32
        .iter()
×
33
        .map(|language| language.english_name.to_owned())
×
34
        .collect())
×
35
}
×
36

37
pub fn access_notes(record_string: String) -> Result<Option<Vec<String>>, magnus::Error> {
×
38
    let record = get_record(&record_string)?;
×
39
    Ok(note::access_notes(&record))
×
40
}
×
41

42
pub fn recap_partner_notes(record_string: String) -> Result<Vec<String>, magnus::Error> {
×
43
    let record = get_record(&record_string)?;
×
44
    Ok(scsb::recap_partner::recap_partner_notes(&record))
×
45
}
×
46

47
pub fn is_scsb(record_string: String) -> Result<bool, magnus::Error> {
×
48
    let record = get_record(&record_string)?;
×
49
    Ok(scsb::is_scsb(&record))
×
50
}
×
51

52
pub fn current_location_code(field_string: String) -> Result<Option<String>, magnus::Error> {
×
53
    let record = get_record(&field_string)?;
×
54
    let field_876 = record.get_fields("876").into_iter().next();
×
55
    Ok(field_876.and_then(
×
56
        |field| match (field.first_subfield("y"), field.first_subfield("z")) {
×
57
            (Some(y), Some(z)) => Some(format!("{}${}", y.content(), z.content())),
×
58
            _ => None,
×
59
        },
×
60
    ))
61
}
×
62
pub fn format_facets(record_string: String) -> Result<Vec<String>, magnus::Error> {
×
63
    let record = get_record(&record_string)?;
×
64
    Ok(record_facet_mapping::format_facets(&record)
×
65
        .iter()
×
66
        .map(|facet| format!("{facet}"))
×
67
        .collect())
×
68
}
×
69
pub fn private_items(record_string: String, holding_id: String) -> Result<bool, magnus::Error> {
×
70
    let record = get_record(&record_string)?;
×
71
    let fields_876 = record.get_fields("876");
×
72
    let mut items = fields_876.iter().filter(|field| {
×
73
        field.first_subfield("0").map(|subfield| subfield.content()) == Some(&holding_id)
×
74
    });
×
75
    Ok(items.any(|item| {
×
76
        item.first_subfield("x")
×
77
            .map_or(true, |subfield| subfield.content() == "Private")
×
78
    }))
×
79
}
×
80

81
pub fn normalize_oclc_number(string: String) -> String {
×
82
    identifier::normalize_oclc_number(&string)
×
83
}
×
84

85
pub fn is_oclc_number(string: String) -> bool {
×
86
    identifier::is_oclc_number(&string)
×
87
}
×
88

89
pub fn identifiers_of_all_versions(record_string: String) -> Result<Vec<String>, magnus::Error> {
×
90
    let record = get_record(&record_string)?;
×
91
    Ok(identifier::identifiers_of_all_versions(&record))
×
92
}
×
93

NEW
94
pub fn publication_statements(record_string: String) -> Result<Vec<String>, magnus::Error> {
×
NEW
95
    let record = get_record(&record_string)?;
×
NEW
96
    Ok(publication::publication_statements(&record).collect())
×
NEW
97
}
×
98

99
pub fn strip_non_numeric(string: String) -> String {
×
100
    string_normalize::strip_non_numeric(&string)
×
101
}
×
102

103
fn get_record(breaker: &str) -> Result<Record, magnus::Error> {
×
104
    Record::from_breaker(breaker).map_err(|err| {
×
105
        magnus::Error::new(
×
106
            exception::runtime_error(),
×
107
            format!("Found error {} while parsing breaker {}", err, breaker),
×
108
        )
109
    })
×
110
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc