Skip to content

Commit

Permalink
refactor: extract parse by type
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 29, 2023
1 parent 7bc6374 commit 86ecc9e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions counit-server/src/domain/domain_transpiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,21 @@ impl DomainTranspiler {
let entry = entry.unwrap();
if entry.file_type().is_file() {
let path_str = entry.path().to_str();
if path_str.is_none() {
let ext = entry.path().extension();

if path_str.is_none() || ext.is_none() {
continue;
}

let path_str = path_str.unwrap();
if path_str.ends_with(".csv") {
let _ = self.load_csv(path_str);
} else if path_str.ends_with(".json") {
self.load_json(path_str);
let ext = ext.unwrap().to_str().unwrap();
match ext {
"csv" => {
let _ = self.load_csv(path_str.unwrap());
}
"json" => {
self.load_json(path_str.unwrap());
}
_ => {}
}
}
}
Expand Down

0 comments on commit 86ecc9e

Please sign in to comment.