diff options
Diffstat (limited to 'src/barbfile.rs')
-rw-r--r-- | src/barbfile.rs | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/barbfile.rs b/src/barbfile.rs index 54ee031..e5ef916 100644 --- a/src/barbfile.rs +++ b/src/barbfile.rs @@ -1,13 +1,12 @@ use jsonpath_rust::JsonPathQuery; use regex::Regex; use serde_json::Value; +use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}; +use std::fs; +use std::path::Path; use std::str::FromStr; use std::string::ToString; use std::{error::Error, fmt}; -use std::cmp::{Eq, PartialEq, PartialOrd, Ord, Ordering}; -use std::fs; -use std::path::Path; - #[cfg(feature = "jq")] use jq_rs; @@ -210,7 +209,13 @@ struct BarbPreamble { } impl BarbPreamble { - fn new(method: Method, url: String, headers: Vec<Header>, filters: Vec<BarbFilter>, dependency: Option<String>) -> Self { + fn new( + method: Method, + url: String, + headers: Vec<Header>, + filters: Vec<BarbFilter>, + dependency: Option<String>, + ) -> Self { BarbPreamble { method, url, @@ -257,7 +262,9 @@ impl BarbFile { let dep_path = Path::new(dep); if !dep_path.is_absolute() { - let my_path = Path::new(&self.file_name).parent().or(Some(Path::new("")))?; + let my_path = Path::new(&self.file_name) + .parent() + .or(Some(Path::new("")))?; return Some(String::from(my_path.join(dep_path).to_str()?)); } @@ -307,8 +314,9 @@ impl BarbFile { let mut bfile = Self::from_str( fs::read_to_string(file_name.as_str()) .map_err(|_| BarbParseError {})? - .as_str() - ).map_err(|_| BarbParseError {})?; + .as_str(), + ) + .map_err(|_| BarbParseError {})?; bfile.file_name = file_name; Ok(bfile) } @@ -479,12 +487,19 @@ mod tests { #[test] fn test_parse_dependency() { let bfile = BarbFile::from_str("#GET^http://test.com\n#>blah.barb").unwrap(); - assert_eq!(bfile.dependency().as_ref().unwrap(), &String::from("blah.barb")); + assert_eq!( + bfile.dependency().as_ref().unwrap(), + &String::from("blah.barb") + ); } #[test] fn test_parse_mult_dependency_keeps_last() { - let bfile = BarbFile::from_str("#GET^http://test.com\n#>blah.barb\n#>foo.barb\n#>bar.barb").unwrap(); - assert_eq!(bfile.dependency().as_ref().unwrap(), &String::from("bar.barb")); + let bfile = BarbFile::from_str("#GET^http://test.com\n#>blah.barb\n#>foo.barb\n#>bar.barb") + .unwrap(); + assert_eq!( + bfile.dependency().as_ref().unwrap(), + &String::from("bar.barb") + ); } } |