Skip to content

Commit

Permalink
refactor(index): yaml -> json
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdoret committed Aug 26, 2024
1 parent 132f688 commit c496272
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/index.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rio_api::parser::TriplesParser;
use rio_turtle::TurtleError;
use serde::{Deserialize, Serialize};
use serde_yml;
use serde_json;
use smallvec::{SmallVec, smallvec};
use std::{
collections::HashMap,
Expand Down Expand Up @@ -120,7 +120,7 @@ pub fn create_type_index(input: &Path, output: &Path) {
panic!("Parsing error occured: {e}");
});
}
let _ = serde_yml::to_writer(buf_out, &index);
let _ = serde_json::to_writer(buf_out, &index);
}

#[cfg(test)]
Expand All @@ -143,6 +143,6 @@ mod tests {
idx.get("urn:Alice").unwrap(),
vec!["urn:Person", "urn:Employee"]
);
println!("{}", serde_yml::to_string(&idx).unwrap());
println!("{}", serde_json::to_string(&idx).unwrap());
}
}
2 changes: 1 addition & 1 deletion src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn parse_rules(path: &Path) -> Rules {
// Parse yaml type index
pub fn parse_index(path: &Path) -> TypeIndex {
return match File::open(path) {
Ok(file) => serde_yml::from_reader(file).expect("Error parsing index file."),
Ok(file) => serde_json::from_reader(file).expect("Error parsing index file."),
Err(e) => panic!("Cannot open index file '{:?}': '{}'.", path, e),
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/pseudo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod tests {
let input_path = Path::new("tests/data/test.nt");
let rules_path = Path::new("tests/data/rules.yaml");
let output_path = dir.path().join("output.nt");
let type_map_path = Path::new("tests/data/type_index.yaml");
let type_map_path = Path::new("tests/data/type_index.json");
let key = None;
pseudonymize_graph(
&logger,
Expand Down
1 change: 1 addition & 0 deletions tests/data/type_index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"types":["<http://xmlns.com/foaf/0.1/Person>","<http://xmlns.com/foaf/OnlineAccount>","<http://xmlns.com/foaf/0.1/Organization>"],"map":{"15212815035200482759":[1],"130358124972442050":[0],"9932096721503705860":[1],"10729855068363610633":[2],"8283467020653172379":[0]}}
15 changes: 0 additions & 15 deletions tests/data/type_index.yaml

This file was deleted.

0 comments on commit c496272

Please sign in to comment.