diff options
-rw-r--r-- | Cargo.lock | 8 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/lib.rs | 37 |
3 files changed, 14 insertions, 35 deletions
@@ -8,14 +8,14 @@ dependencies = [ [[package]] name = "dict" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "dutree" -version = "0.2.1" +version = "0.2.3" dependencies = [ - "dict 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dict 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "terminal_size 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -133,7 +133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" -"checksum dict 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7799ea4aadf97b4236e761799371f7ba10ea6327c69bd51690dd567bf0ae539" +"checksum dict 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "372bf4a79fc1e54f87e2888e1bfb2eebc1a72c3941b49ef56744fcf656281957" "checksum getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "65922871abd2f101a2eb0eaebadc66668e54a87ad9c3dd82520b5f86ede5eff9" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" @@ -1,6 +1,6 @@ [package] name = "dutree" -version = "0.2.3" +version = "0.2.4" authors = ["nacho <nacho@ownyourbits.com>"] description = "Command line tool to analyze disk usage" repository = "https://github.com/nachoparker/dutree" @@ -10,7 +10,7 @@ homepage = "https://ownyourbits.com/2018/03/25/analize-disk-usage-with-dutree/" exclude = ["test/*"] [dependencies] -dict = "0.1.1" +dict = "0.1.4" getopts = "0.2" terminal_size = "0.1.7" regex = "0.2" @@ -86,8 +86,6 @@ pub struct Config { exclude : Vec<String>, } -//struct DictEntry { key : String, val : String } - fn init_opts() -> Options { let mut options = Options::new(); @@ -567,14 +565,14 @@ mod tests { #[test] fn parse_ls_colors() { - let mut dict_ = Vec::new(); - dict_.push( DictEntry{ key: "di".to_string() , val: "dircode".to_string() } ); - dict_.push( DictEntry{ key: "li".to_string() , val: "linkcod".to_string() } ); - dict_.push( DictEntry{ key: "*.mp3".to_string(), val: "mp3code".to_string() } ); - dict_.push( DictEntry{ key: "*.tar".to_string(), val: "tarcode".to_string() } ); - assert_eq!( "dircode", color_from_path( Path::new(".") , &dict_ ) ); - assert_eq!( "mp3code", color_from_path( Path::new("test.mp3"), &dict_ ) ); - assert_eq!( "tarcode", color_from_path( Path::new("test.tar"), &dict_ ) ); + let mut dict = Dict::<String>::new(); + dict.add( "di".to_string(), "dircode".to_string() ); + dict.add( "li".to_string(), "linkcod".to_string() ); + dict.add( "*.mp3".to_string(), "mp3code".to_string() ); + dict.add( "*.tar".to_string(), "tarcode".to_string() ); + assert_eq!( "dircode", color_from_path( Path::new(".") , &dict ).unwrap() ); + assert_eq!( "mp3code", color_from_path( Path::new("test.mp3"), &dict ).unwrap() ); + assert_eq!( "tarcode", color_from_path( Path::new("test.tar"), &dict ).unwrap() ); } /* @@ -595,25 +593,6 @@ mod tests { } #[test] - fn entry_object() { - let dir = fs::read_dir(".").unwrap().nth(0).unwrap().unwrap(); - let entry = Entry::new(None, &dir, true, 0, false); - println!( "entry created {} {}B", entry.name, entry.bytes ); - assert_eq!( ".git", entry.name ); - } - - #[test] - fn vector_of_entries() { - let mut vec : Vec<Entry> = Vec::new(); - let entry = Entry { name: String::from("file1"), bytes: 1, dir: None }; - vec.push( entry ); - let entry = Entry { name: String::from("file2"), bytes: 2, dir: None }; - vec.push( entry ); - vec.sort_unstable_by(|a, b| b.bytes.cmp(&a.bytes)); - assert!( vec[0].bytes == 2 ); - } - - #[test] fn get_bytes_test() { println!( "calculated bytes {}", get_bytes( Path::new( "." ) ) ); |