From c4962728519b06f1fb533a644a1f1ee9741c0076 Mon Sep 17 00:00:00 2001 From: cmdoret Date: Mon, 26 Aug 2024 13:30:28 +0200 Subject: [PATCH] refactor(index): yaml -> json --- src/index.rs | 6 +++--- src/io.rs | 2 +- src/pseudo.rs | 2 +- tests/data/type_index.json | 1 + tests/data/type_index.yaml | 15 --------------- 5 files changed, 6 insertions(+), 20 deletions(-) create mode 100644 tests/data/type_index.json delete mode 100644 tests/data/type_index.yaml diff --git a/src/index.rs b/src/index.rs index 2aaa70c..1112f38 100644 --- a/src/index.rs +++ b/src/index.rs @@ -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, @@ -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)] @@ -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()); } } diff --git a/src/io.rs b/src/io.rs index 54be676..24722e9 100644 --- a/src/io.rs +++ b/src/io.rs @@ -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), }; } diff --git a/src/pseudo.rs b/src/pseudo.rs index f0e2a95..c1c55a3 100644 --- a/src/pseudo.rs +++ b/src/pseudo.rs @@ -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, diff --git a/tests/data/type_index.json b/tests/data/type_index.json new file mode 100644 index 0000000..abc6847 --- /dev/null +++ b/tests/data/type_index.json @@ -0,0 +1 @@ +{"types":["","",""],"map":{"15212815035200482759":[1],"130358124972442050":[0],"9932096721503705860":[1],"10729855068363610633":[2],"8283467020653172379":[0]}} \ No newline at end of file diff --git a/tests/data/type_index.yaml b/tests/data/type_index.yaml deleted file mode 100644 index 0b6b442..0000000 --- a/tests/data/type_index.yaml +++ /dev/null @@ -1,15 +0,0 @@ -types: -- -- -- -map: - 15212815035200482759: - - 1 - 9932096721503705860: - - 1 - 130358124972442050: - - 0 - 8283467020653172379: - - 0 - 10729855068363610633: - - 2