From 164ee9cb844ac8b027218085bdcd0c354876e8cd Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 8 Aug 2019 10:04:51 -0500 Subject: [PATCH 1/3] refactor: Split bin/lib into separate crates --- Cargo.lock | 152 ++++++++++++++++++++++------- Cargo.toml | 21 +--- README.md | 2 +- benches/data.rs | 2 +- typos/Cargo.toml | 39 ++++++++ {assets => typos/assets}/main.go | 0 {assets => typos/assets}/words.csv | 0 {assets => typos/assets}/words.go | 0 build.rs => typos/build.rs | 0 {src => typos/src}/checks.rs | 0 {src => typos/src}/dict.rs | 0 {src => typos/src}/dict_codegen.rs | 0 {src => typos/src}/lib.rs | 0 {src => typos/src}/report.rs | 0 {src => typos/src}/tokens.rs | 0 15 files changed, 162 insertions(+), 54 deletions(-) create mode 100644 typos/Cargo.toml rename {assets => typos/assets}/main.go (100%) rename {assets => typos/assets}/words.csv (100%) rename {assets => typos/assets}/words.go (100%) rename build.rs => typos/build.rs (100%) rename {src => typos/src}/checks.rs (100%) rename {src => typos/src}/dict.rs (100%) rename {src => typos/src}/dict_codegen.rs (100%) rename {src => typos/src}/lib.rs (100%) rename {src => typos/src}/report.rs (100%) rename {src => typos/src}/tokens.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index daefb4369..4e59da76a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,10 +22,10 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "globwalk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -33,14 +33,14 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -48,10 +48,10 @@ name = "backtrace" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -62,7 +62,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -85,6 +85,15 @@ name = "byteorder" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cc" version = "1.0.28" @@ -236,7 +245,7 @@ name = "float-cmp" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -258,6 +267,15 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "getrandom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "globset" version = "0.4.2" @@ -332,7 +350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.47" +version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -358,7 +376,7 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -368,8 +386,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num-traits" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "owning_ref" @@ -393,7 +414,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -435,9 +456,14 @@ dependencies = [ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "predicates" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -487,8 +513,8 @@ name = "rand" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -499,20 +525,49 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_core" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rand_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -521,6 +576,14 @@ dependencies = [ "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -536,7 +599,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -610,7 +673,7 @@ dependencies = [ [[package]] name = "remove_dir_all" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -754,14 +817,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.0.5" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -778,7 +841,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -816,15 +879,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "typos" version = "0.1.0" dependencies = [ - "assert_fs 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bstr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clap-verbosity-flag 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ignore 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -833,12 +891,27 @@ dependencies = [ "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "typos-cli" +version = "0.1.0" +dependencies = [ + "assert_fs 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap-verbosity-flag 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ignore 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "typos 0.1.0", +] + [[package]] name = "ucd-util" version = "0.1.3" @@ -946,12 +1019,13 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum assert_fs 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "843ba73b7d990b4ef11b34a58eefa777c1350c098031857ec369658c7cb0597c" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" +"checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bstr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc0572e02f76cb335f309b19e0a0d585b4f62788f7d26de2a13a836a637385f" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -972,6 +1046,7 @@ dependencies = [ "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" "checksum globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4743617a7464bbda3c8aec8558ff2f9429047e025771037df561d383337ff865" "checksum globwalk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89fa2e29859da05acd066bd45996f05c271b271d7ec4a781f909682328f65d25" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" @@ -980,12 +1055,12 @@ dependencies = [ "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" +"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e0a1a39eab95caf4f5556da9289b9e68f0aafac901b2ce80daaf020d3b733a8" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" @@ -993,16 +1068,21 @@ dependencies = [ "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" -"checksum predicates 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa984b7cd021a0bf5315bcce4c4ae61d2a535db2a8d288fc7578638690a7b7c3" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" +"checksum predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53e09015b0d3f5a0ec2d4428f7559bb7b3fff341b4e159fedd1d57fac8b939ff" "checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" "checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" "checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" "checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" +"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" +"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46fbd5550acf75b0c2730f5dd1873751daf9beb8f11b44027778fae50d7feca" "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" @@ -1013,7 +1093,7 @@ dependencies = [ "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-automata 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3ed09217220c272b29ef237a974ad58515bde75f194e3ffa7e6d0bf0f3b01f86" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" -"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" +"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" @@ -1032,7 +1112,7 @@ dependencies = [ "checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" +"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" diff --git a/Cargo.toml b/Cargo.toml index 4bb7a8ac3..10cd3a03b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,12 @@ +[workspace] +members = ["typos"] + [package] -name = "typos" +name = "typos-cli" version = "0.1.0" authors = ["Ed Page "] description = "Source Code Spelling Correction" repository = "https://github.com/epage/typos" -documentation = "https://docs.rs/typos" readme = "README.md" categories = ["development-tools", "text-processing"] keywords = ["development", "spelling"] @@ -20,29 +22,16 @@ appveyor = { repository = "epage/typos" } iterate_unstable = [] [dependencies] +typos = { version = "0.1", path = "typos" } failure = "0.1" structopt = "0.2" clap = "2" clap-verbosity-flag = "0.2.0" ignore = "0.4" -phf = { version = "0.7", features = ["unicase"] } -regex = "1.0" -lazy_static = "1.2.0" serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" toml = "0.4" -itertools = "0.8" -unicase = "1.1" -bstr = "0.2" log = "0.4" env_logger = "0.6" -unicode-segmentation = "1.3.0" -derive_more = "0.15.0" [dev-dependencies] assert_fs = "0.10" - -[build-dependencies] -phf_codegen = "0.7" -csv = "1.0" -unicase = "1.1" diff --git a/README.md b/README.md index 7e0ddde99..57f409692 100644 --- a/README.md +++ b/README.md @@ -23,5 +23,5 @@ Licensed under either of at your option. -[Crates.io]: https://crates.io/crates/typos +[Crates.io]: https://crates.io/crates/typos-cli [Documentation]: https://docs.rs/typos diff --git a/benches/data.rs b/benches/data.rs index 353e9f0af..4cc93f3fb 100644 --- a/benches/data.rs +++ b/benches/data.rs @@ -28,4 +28,4 @@ fn main() { } "; -pub const CORPUS: &str = include_str!("../assets/words.csv"); +pub const CORPUS: &str = include_str!("../typos/assets/words.csv"); diff --git a/typos/Cargo.toml b/typos/Cargo.toml new file mode 100644 index 000000000..1588f0aeb --- /dev/null +++ b/typos/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "typos" +version = "0.1.0" +authors = ["Ed Page "] +description = "Source Code Spelling Correction" +repository = "https://github.com/epage/typos" +documentation = "https://docs.rs/typos" +readme = "README.md" +categories = ["development-tools", "text-processing"] +keywords = ["development", "spelling"] +license = "MIT" +edition = "2018" + +[badges] +travis-ci = { repository = "epage/typos" } +appveyor = { repository = "epage/typos" } + +[features] +# Support quickly iterating +iterate_unstable = [] + +[dependencies] +failure = "0.1" +phf = { version = "0.7", features = ["unicase"] } +regex = "1.0" +lazy_static = "1.2.0" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +itertools = "0.8" +unicase = "1.1" +bstr = "0.2" +log = "0.4" +unicode-segmentation = "1.3.0" +derive_more = "0.15.0" + +[build-dependencies] +phf_codegen = "0.7" +csv = "1.0" +unicase = "1.1" diff --git a/assets/main.go b/typos/assets/main.go similarity index 100% rename from assets/main.go rename to typos/assets/main.go diff --git a/assets/words.csv b/typos/assets/words.csv similarity index 100% rename from assets/words.csv rename to typos/assets/words.csv diff --git a/assets/words.go b/typos/assets/words.go similarity index 100% rename from assets/words.go rename to typos/assets/words.go diff --git a/build.rs b/typos/build.rs similarity index 100% rename from build.rs rename to typos/build.rs diff --git a/src/checks.rs b/typos/src/checks.rs similarity index 100% rename from src/checks.rs rename to typos/src/checks.rs diff --git a/src/dict.rs b/typos/src/dict.rs similarity index 100% rename from src/dict.rs rename to typos/src/dict.rs diff --git a/src/dict_codegen.rs b/typos/src/dict_codegen.rs similarity index 100% rename from src/dict_codegen.rs rename to typos/src/dict_codegen.rs diff --git a/src/lib.rs b/typos/src/lib.rs similarity index 100% rename from src/lib.rs rename to typos/src/lib.rs diff --git a/src/report.rs b/typos/src/report.rs similarity index 100% rename from src/report.rs rename to typos/src/report.rs diff --git a/src/tokens.rs b/typos/src/tokens.rs similarity index 100% rename from src/tokens.rs rename to typos/src/tokens.rs From 1bdd1c928a491e4bca285e8f048f28f6dd20dcdd Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 8 Aug 2019 10:24:50 -0500 Subject: [PATCH 2/3] refactor: Split out typos-dict --- Cargo.lock | 36 +++++++-- Cargo.toml | 3 +- benches/corrections.rs | 6 +- benches/data.rs | 2 +- benches/file.rs | 12 +-- src/main.rs | 2 +- typos-dict/Cargo.toml | 31 ++++++++ {typos => typos-dict}/assets/main.go | 0 {typos => typos-dict}/assets/words.csv | 0 {typos => typos-dict}/assets/words.go | 0 {typos => typos-dict}/build.rs | 0 typos-dict/src/dict.rs | 97 +++++++++++++++++++++++ {typos => typos-dict}/src/dict_codegen.rs | 0 typos-dict/src/lib.rs | 4 + typos/Cargo.toml | 10 --- typos/src/dict.rs | 96 ---------------------- typos/src/lib.rs | 1 - 17 files changed, 173 insertions(+), 127 deletions(-) create mode 100644 typos-dict/Cargo.toml rename {typos => typos-dict}/assets/main.go (100%) rename {typos => typos-dict}/assets/words.csv (100%) rename {typos => typos-dict}/assets/words.go (100%) rename {typos => typos-dict}/build.rs (100%) create mode 100644 typos-dict/src/dict.rs rename {typos => typos-dict}/src/dict_codegen.rs (100%) create mode 100644 typos-dict/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 4e59da76a..5bd16e0d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,6 +78,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -158,16 +159,19 @@ dependencies = [ [[package]] name = "csv" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "csv-core" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -697,6 +701,11 @@ name = "ryu" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ryu" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "same-file" version = "1.0.4" @@ -880,14 +889,11 @@ name = "typos" version = "0.1.0" dependencies = [ "bstr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", @@ -910,6 +916,19 @@ dependencies = [ "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "typos 0.1.0", + "typos-dict 0.1.0", +] + +[[package]] +name = "typos-dict" +version = "0.1.0" +dependencies = [ + "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "typos 0.1.0", + "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1033,8 +1052,8 @@ dependencies = [ "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "137bc235f622ffaa0428e3854e24acb53291fc0b3ff6fb2cb75a8be6fb02f06b" "checksum crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "41ee4864f4797060e52044376f7d107429ce1fb43460021b126424b7180ee21a" -"checksum csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd1c44c58078cfbeaf11fbb3eac9ae5534c23004ed770cc4bfb48e658ae4f04" -"checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65" +"checksum csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37519ccdfd73a75821cac9319d4fce15a81b9fcf75f951df5b9988aa3a0af87d" +"checksum csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9b5cadb6b25c77aeff80ba701712494213f4a8418fcda2ee11b6560c3ad0bf4c" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" @@ -1097,6 +1116,7 @@ dependencies = [ "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" diff --git a/Cargo.toml b/Cargo.toml index 10cd3a03b..428e0fb57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["typos"] +members = ["typos", "typos-dict"] [package] name = "typos-cli" @@ -23,6 +23,7 @@ iterate_unstable = [] [dependencies] typos = { version = "0.1", path = "typos" } +typos-dict = { version = "0.1", path = "typos-dict" } failure = "0.1" structopt = "0.2" clap = "2" diff --git a/benches/corrections.rs b/benches/corrections.rs index 8e0d75145..40a452004 100644 --- a/benches/corrections.rs +++ b/benches/corrections.rs @@ -4,12 +4,12 @@ extern crate test; #[bench] fn load_corrections(b: &mut test::Bencher) { - b.iter(|| typos::BuiltIn::new()); + b.iter(|| typos_dict::BuiltIn::new()); } #[bench] fn correct_word_hit(b: &mut test::Bencher) { - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let input = typos::tokens::Word::new("successs", 0).unwrap(); assert_eq!( corrections.correct_word(input), @@ -20,7 +20,7 @@ fn correct_word_hit(b: &mut test::Bencher) { #[bench] fn correct_word_miss(b: &mut test::Bencher) { - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let input = typos::tokens::Word::new("success", 0).unwrap(); assert_eq!(corrections.correct_word(input), None); b.iter(|| corrections.correct_word(input)); diff --git a/benches/data.rs b/benches/data.rs index 4cc93f3fb..4252655c0 100644 --- a/benches/data.rs +++ b/benches/data.rs @@ -28,4 +28,4 @@ fn main() { } "; -pub const CORPUS: &str = include_str!("../typos/assets/words.csv"); +pub const CORPUS: &str = include_str!("../typos-dict/assets/words.csv"); diff --git a/benches/file.rs b/benches/file.rs index 27a7c31d8..c65300436 100644 --- a/benches/file.rs +++ b/benches/file.rs @@ -12,7 +12,7 @@ fn process_empty(b: &mut test::Bencher) { let sample_path = temp.child("sample"); sample_path.write_str(data::EMPTY).unwrap(); - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let parser = typos::tokens::Parser::new(); let checks = typos::checks::CheckSettings::new().build(&corrections, &parser); b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent)); @@ -26,7 +26,7 @@ fn process_no_tokens(b: &mut test::Bencher) { let sample_path = temp.child("sample"); sample_path.write_str(data::NO_TOKENS).unwrap(); - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let parser = typos::tokens::Parser::new(); let checks = typos::checks::CheckSettings::new().build(&corrections, &parser); b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent)); @@ -40,7 +40,7 @@ fn process_single_token(b: &mut test::Bencher) { let sample_path = temp.child("sample"); sample_path.write_str(data::SINGLE_TOKEN).unwrap(); - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let parser = typos::tokens::Parser::new(); let checks = typos::checks::CheckSettings::new().build(&corrections, &parser); b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent)); @@ -54,7 +54,7 @@ fn process_sherlock(b: &mut test::Bencher) { let sample_path = temp.child("sample"); sample_path.write_str(data::SHERLOCK).unwrap(); - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let parser = typos::tokens::Parser::new(); let checks = typos::checks::CheckSettings::new().build(&corrections, &parser); b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent)); @@ -68,7 +68,7 @@ fn process_code(b: &mut test::Bencher) { let sample_path = temp.child("sample"); sample_path.write_str(data::CODE).unwrap(); - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let parser = typos::tokens::Parser::new(); let checks = typos::checks::CheckSettings::new().build(&corrections, &parser); b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent)); @@ -82,7 +82,7 @@ fn process_corpus(b: &mut test::Bencher) { let sample_path = temp.child("sample"); sample_path.write_str(data::CORPUS).unwrap(); - let corrections = typos::BuiltIn::new(); + let corrections = typos_dict::BuiltIn::new(); let parser = typos::tokens::Parser::new(); let checks = typos::checks::CheckSettings::new().build(&corrections, &parser); b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent)); diff --git a/src/main.rs b/src/main.rs index 319858c64..ef19fc66f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -310,7 +310,7 @@ fn run() -> Result { config.default.update(&args.overrides); let config = config; - let dictionary = typos::BuiltIn::new(); + let dictionary = typos_dict::BuiltIn::new(); let parser = typos::tokens::ParserBuilder::new() .ignore_hex(config.default.ignore_hex()) diff --git a/typos-dict/Cargo.toml b/typos-dict/Cargo.toml new file mode 100644 index 000000000..97fd2d308 --- /dev/null +++ b/typos-dict/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "typos-dict" +version = "0.1.0" +authors = ["Ed Page "] +description = "Source Code Spelling Correction" +repository = "https://github.com/epage/typos" +documentation = "https://docs.rs/typos-dict" +readme = "README.md" +categories = ["development-tools", "text-processing"] +keywords = ["development", "spelling"] +license = "MIT" +edition = "2018" + +[badges] +travis-ci = { repository = "epage/typos" } +appveyor = { repository = "epage/typos" } + +[features] +# Support quickly iterating +iterate_unstable = [] + +[dependencies] +typos = { version = "0.1", path = "../typos" } +phf = { version = "0.7", features = ["unicase"] } +unicase = "1.1" +log = "0.4" + +[build-dependencies] +phf_codegen = "0.7" +csv = "1.0" +unicase = "1.1" diff --git a/typos/assets/main.go b/typos-dict/assets/main.go similarity index 100% rename from typos/assets/main.go rename to typos-dict/assets/main.go diff --git a/typos/assets/words.csv b/typos-dict/assets/words.csv similarity index 100% rename from typos/assets/words.csv rename to typos-dict/assets/words.csv diff --git a/typos/assets/words.go b/typos-dict/assets/words.go similarity index 100% rename from typos/assets/words.go rename to typos-dict/assets/words.go diff --git a/typos/build.rs b/typos-dict/build.rs similarity index 100% rename from typos/build.rs rename to typos-dict/build.rs diff --git a/typos-dict/src/dict.rs b/typos-dict/src/dict.rs new file mode 100644 index 000000000..ed91c68fa --- /dev/null +++ b/typos-dict/src/dict.rs @@ -0,0 +1,97 @@ +use std::borrow::Cow; + +use unicase::UniCase; + +use typos::tokens::Case; + +#[derive(Default)] +pub struct BuiltIn {} + +impl BuiltIn { + pub fn new() -> Self { + Self {} + } + + pub fn correct_ident<'s, 'w>( + &'s self, + _ident: typos::tokens::Identifier<'w>, + ) -> Option> { + None + } + + pub fn correct_word<'s, 'w>(&'s self, word: typos::tokens::Word<'w>) -> Option> { + map_lookup(&crate::dict_codegen::WORD_DICTIONARY, word.token()) + .map(|s| case_correct(s, word.case())) + } +} + +impl typos::Dictionary for BuiltIn { + fn correct_ident<'s, 'w>( + &'s self, + ident: typos::tokens::Identifier<'w>, + ) -> Option> { + BuiltIn::correct_ident(self, ident) + } + + fn correct_word<'s, 'w>(&'s self, word: typos::tokens::Word<'w>) -> Option> { + BuiltIn::correct_word(self, word) + } +} + +fn map_lookup( + map: &'static phf::Map, &'static str>, + key: &str, +) -> Option<&'static str> { + // This transmute should be safe as `get` will not store the reference with + // the expanded lifetime. This is due to `Borrow` being overly strict and + // can't have an impl for `&'static str` to `Borrow<&'a str>`. + // + // + // See https://github.com/rust-lang/rust/issues/28853#issuecomment-158735548 + unsafe { + let key = ::std::mem::transmute::<_, &'static str>(key); + map.get(&UniCase(key)).cloned() + } +} + +fn case_correct(correction: &str, case: Case) -> Cow<'_, str> { + match case { + Case::Lower | Case::None => correction.into(), + Case::Title => { + let mut title = String::with_capacity(correction.as_bytes().len()); + let mut char_indices = correction.char_indices(); + if let Some((_, c)) = char_indices.next() { + title.extend(c.to_uppercase()); + if let Some((i, _)) = char_indices.next() { + title.push_str(&correction[i..]); + } + } + title.into() + } + Case::Scream => correction + .chars() + .flat_map(|c| c.to_uppercase()) + .collect::() + .into(), + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_case_correct() { + let cases = [ + ("foo", Case::Lower, "foo"), + ("foo", Case::None, "foo"), + ("foo", Case::Title, "Foo"), + ("foo", Case::Scream, "FOO"), + ("fOo", Case::None, "fOo"), + ]; + for (correction, case, expected) in cases.iter() { + let actual = case_correct(correction, *case); + assert_eq!(*expected, actual); + } + } +} diff --git a/typos/src/dict_codegen.rs b/typos-dict/src/dict_codegen.rs similarity index 100% rename from typos/src/dict_codegen.rs rename to typos-dict/src/dict_codegen.rs diff --git a/typos-dict/src/lib.rs b/typos-dict/src/lib.rs new file mode 100644 index 000000000..a36726f78 --- /dev/null +++ b/typos-dict/src/lib.rs @@ -0,0 +1,4 @@ +mod dict; +mod dict_codegen; + +pub use crate::dict::*; diff --git a/typos/Cargo.toml b/typos/Cargo.toml index 1588f0aeb..bfc23f34f 100644 --- a/typos/Cargo.toml +++ b/typos/Cargo.toml @@ -15,13 +15,8 @@ edition = "2018" travis-ci = { repository = "epage/typos" } appveyor = { repository = "epage/typos" } -[features] -# Support quickly iterating -iterate_unstable = [] - [dependencies] failure = "0.1" -phf = { version = "0.7", features = ["unicase"] } regex = "1.0" lazy_static = "1.2.0" serde = { version = "1.0", features = ["derive"] } @@ -32,8 +27,3 @@ bstr = "0.2" log = "0.4" unicode-segmentation = "1.3.0" derive_more = "0.15.0" - -[build-dependencies] -phf_codegen = "0.7" -csv = "1.0" -unicase = "1.1" diff --git a/typos/src/dict.rs b/typos/src/dict.rs index 1ff73591e..084cbc422 100644 --- a/typos/src/dict.rs +++ b/typos/src/dict.rs @@ -1,9 +1,5 @@ use std::borrow::Cow; -use unicase::UniCase; - -use crate::tokens::Case; - pub trait Dictionary { fn correct_ident<'s, 'w>( &'s self, @@ -12,95 +8,3 @@ pub trait Dictionary { fn correct_word<'s, 'w>(&'s self, word: crate::tokens::Word<'w>) -> Option>; } - -#[derive(Default)] -pub struct BuiltIn {} - -impl BuiltIn { - pub fn new() -> Self { - Self {} - } - - pub fn correct_ident<'s, 'w>( - &'s self, - _ident: crate::tokens::Identifier<'w>, - ) -> Option> { - None - } - - pub fn correct_word<'s, 'w>(&'s self, word: crate::tokens::Word<'w>) -> Option> { - map_lookup(&crate::dict_codegen::WORD_DICTIONARY, word.token()) - .map(|s| case_correct(s, word.case())) - } -} - -impl Dictionary for BuiltIn { - fn correct_ident<'s, 'w>( - &'s self, - ident: crate::tokens::Identifier<'w>, - ) -> Option> { - BuiltIn::correct_ident(self, ident) - } - - fn correct_word<'s, 'w>(&'s self, word: crate::tokens::Word<'w>) -> Option> { - BuiltIn::correct_word(self, word) - } -} - -fn map_lookup( - map: &'static phf::Map, &'static str>, - key: &str, -) -> Option<&'static str> { - // This transmute should be safe as `get` will not store the reference with - // the expanded lifetime. This is due to `Borrow` being overly strict and - // can't have an impl for `&'static str` to `Borrow<&'a str>`. - // - // - // See https://github.com/rust-lang/rust/issues/28853#issuecomment-158735548 - unsafe { - let key = ::std::mem::transmute::<_, &'static str>(key); - map.get(&UniCase(key)).cloned() - } -} - -fn case_correct(correction: &str, case: Case) -> Cow<'_, str> { - match case { - Case::Lower | Case::None => correction.into(), - Case::Title => { - let mut title = String::with_capacity(correction.as_bytes().len()); - let mut char_indices = correction.char_indices(); - if let Some((_, c)) = char_indices.next() { - title.extend(c.to_uppercase()); - if let Some((i, _)) = char_indices.next() { - title.push_str(&correction[i..]); - } - } - title.into() - } - Case::Scream => correction - .chars() - .flat_map(|c| c.to_uppercase()) - .collect::() - .into(), - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_case_correct() { - let cases = [ - ("foo", Case::Lower, "foo"), - ("foo", Case::None, "foo"), - ("foo", Case::Title, "Foo"), - ("foo", Case::Scream, "FOO"), - ("fOo", Case::None, "fOo"), - ]; - for (correction, case, expected) in cases.iter() { - let actual = case_correct(correction, *case); - assert_eq!(*expected, actual); - } - } -} diff --git a/typos/src/lib.rs b/typos/src/lib.rs index 2c3fd940d..1cb77c994 100644 --- a/typos/src/lib.rs +++ b/typos/src/lib.rs @@ -1,5 +1,4 @@ mod dict; -mod dict_codegen; pub mod checks; pub mod report; From 5b635a1a874eba1290f0babbc7face0c18b217d9 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 10 Aug 2019 18:23:50 -0500 Subject: [PATCH 3/3] chore(CI): Update for workspaces --- .travis.yml | 12 ++++++------ appveyor.yml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 12aebc1ec..d077acd9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,22 +11,22 @@ matrix: install: - rustup component add rustfmt script: - - cargo fmt -- --check + - cargo fmt --all -- --check - env: RUSTFLAGS="-D warnings" rust: 1.35.0 # `stable`: Locking down for consistent behavior install: script: - - cargo check --tests + - cargo check --tests --all - env: CLIPPY rust: 1.35.0 # `stable`: Locking down for consistent behavior install: - rustup component add clippy script: - - cargo clippy --all-features + - cargo clippy --all-features --all - env: BENCH rust: nightly script: - - cargo bench + - cargo bench --all install: - rustc -Vv @@ -34,8 +34,8 @@ install: - export PATH=$HOME/.cargo/bin:$PATH script: -- cargo check --verbose -- cargo test --verbose +- cargo check --verbose --all +- cargo test --verbose --all branches: only: diff --git a/appveyor.yml b/appveyor.yml index 7a8877a9e..e72e37e91 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,8 +26,8 @@ install: - cargo -V test_script: -- cargo check --verbose -- cargo test --verbose +- cargo check --verbose --all +- cargo test --verbose --all branches: only: