summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornacho <nacho.nunez@aoifes.com>2018-04-17 11:52:52 +0200
committernacho <nacho.nunez@aoifes.com>2018-04-17 11:54:02 +0200
commitb65c3c0b5132aae93d3807d9b1be13356511fa65 (patch)
treef71d70b1b218b6db4c61b067755240b520e5ee7d
parent5b5d4f5db9f622a84f5b221038af3b608f414588 (diff)
use latest version of dict (with hashing)
-rw-r--r--Cargo.lock8
-rw-r--r--Cargo.toml4
-rw-r--r--src/lib.rs37
3 files changed, 14 insertions, 35 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 0c9969e..fdf046e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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"
diff --git a/Cargo.toml b/Cargo.toml
index b48b7ae..69c2b01 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/src/lib.rs b/src/lib.rs
index 5263d01..6160938 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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( "." ) ) );