Skip to content

Commit 2a310ad

Browse files
authored
refactor(cli): --config -> --rules (#48)
1 parent f879635 commit 2a310ad

6 files changed

Lines changed: 19 additions & 19 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ Indexing only requires an RDF file as input:
108108
tripsu index input.nt > index.nt
109109
```
110110

111-
Pseudonymization requires an RDF file, index and config as input:
111+
Pseudonymization requires an RDF file, index and rules configuration as input:
112112

113113
```shell
114-
tripsu pseudo --index index.nt --config rules.yaml input.nt > output.nt
114+
tripsu pseudo --index index.nt --rules rules.yaml input.nt > output.nt
115115
```
116116

117117
By default, pseudonymization uses a random key. To make the process

docs/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on a large graph and we would like to pseudonymize some of the triples. This is
88
how the flow should look like:
99

1010
```shell
11-
curl <sparql-query> | tripsu pseudo -x index.nt -c config.yaml > pseudo.nt
11+
curl <sparql-query> | tripsu pseudo -x index.nt -r rules.yaml > pseudo.nt
1212
```
1313

1414
For this flow to stream data instead of loading everything into memory, note

src/io.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ pub fn parse_ntriples(reader: impl BufRead) -> NTriplesParser<impl BufRead> {
4343
}
4444

4545
// Parse yaml configuration file.
46-
pub fn parse_config(path: &Path) -> Rules {
46+
pub fn parse_rules(path: &Path) -> Rules {
4747
return match File::open(path) {
48-
Ok(file) => serde_yml::from_reader(file).expect("Error parsing config file."),
48+
Ok(file) => serde_yml::from_reader(file).expect("Error parsing rules file."),
4949
Err(e) => panic!("Cannot open file '{:?}': '{}'.", path, e),
5050
};
5151
}
@@ -62,7 +62,7 @@ pub fn read_bytes(path: &PathBuf) -> Vec<u8> {
6262

6363
#[cfg(test)]
6464
mod tests {
65-
use super::{parse_config, parse_ntriples};
65+
use super::{parse_ntriples, parse_rules};
6666
use rio_api::parser::TriplesParser;
6767
use std::{
6868
io::{BufRead, BufReader},
@@ -86,8 +86,8 @@ mod tests {
8686
}
8787
// Test the parsing of a config file.
8888
#[test]
89-
fn config_parsing() {
90-
let config_path = Path::new("tests/data/config.yaml");
91-
parse_config(&config_path);
89+
fn rules_parsing() {
90+
let config_path = Path::new("tests/data/rules.yaml");
91+
parse_rules(&config_path);
9292
}
9393
}

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ struct PseudoArgs {
5151
#[arg(default_value = "-")]
5252
input: PathBuf,
5353

54-
/// The config file descriptor to use for defining RDF elements to pseudonymize.
54+
/// File defining which RDF elements to pseudonymize.
5555
/// Format: yaml
5656
#[arg(short, long)]
57-
config: PathBuf,
57+
rules: PathBuf,
5858

5959
/// Output file descriptor for pseudonymized triples.
6060
/// Defaults to `stdout`.
@@ -94,7 +94,7 @@ fn main() {
9494
pseudonymize_graph(
9595
&log,
9696
&args.input,
97-
&args.config,
97+
&args.rules,
9898
&args.output,
9999
&args.index,
100100
&args.secret,

src/pseudo.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ fn load_type_map(input: impl BufRead) -> HashMap<String, String> {
5656
pub fn pseudonymize_graph(
5757
_: &Logger,
5858
input: &Path,
59-
config: &Path,
59+
rules_path: &Path,
6060
output: &Path,
61-
index: &Path,
61+
index_path: &Path,
6262
secret_path: &Option<PathBuf>,
6363
) {
6464
let buf_input = io::get_reader(input);
65-
let buf_index = io::get_reader(index);
65+
let buf_index = io::get_reader(index_path);
6666
let mut buf_output = io::get_writer(output);
6767

68-
let rules_config = io::parse_config(config);
68+
let rules = io::parse_rules(rules_path);
6969
let node_to_type: HashMap<String, String> = load_type_map(buf_index);
7070

7171
let secret = secret_path.as_ref().map(io::read_bytes);
@@ -79,7 +79,7 @@ pub fn pseudonymize_graph(
7979
.parse_step(&mut |t: TripleView| {
8080
process_triple(
8181
t.into(),
82-
&rules_config,
82+
&rules,
8383
&node_to_type,
8484
&mut buf_output,
8585
&pseudonymizer,
@@ -107,14 +107,14 @@ mod tests {
107107

108108
let dir = tempdir().unwrap();
109109
let input_path = Path::new("tests/data/test.nt");
110-
let config_path = Path::new("tests/data/config.yaml");
110+
let rules_path = Path::new("tests/data/rules.yaml");
111111
let output_path = dir.path().join("output.nt");
112112
let type_map_path = Path::new("tests/data/type_map.nt");
113113
let key = None;
114114
pseudonymize_graph(
115115
&logger,
116116
&input_path,
117-
&config_path,
117+
&rules_path,
118118
&output_path,
119119
&type_map_path,
120120
&key,

0 commit comments

Comments
 (0)