diff --git a/Cargo.toml b/Cargo.toml index ddcce648..77f65c70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "voca_rs" -version = "1.8.0" +version = "1.9.0" authors = ["Anatol Merezhanyi "] license = "MIT" description = "Voca_rs is a Rust library for manipulating strings. Inspired by Voca.js and string.py" diff --git a/README.md b/README.md index 60dd1bc7..bb8aaac1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# voca_rs [![Build Status](https://travis-ci.org/e1r0nd/voca_rs.svg?branch=master)](https://travis-ci.org/e1r0nd/voca_rs) [![Crates version](http://meritbadge.herokuapp.com/voca_rs)](https://crates.io/crates/voca_rs) [![dependency status](https://deps.rs/crate/voca_rs/1.8.0/status.svg)](https://deps.rs/crate/voca_rs/1.8.0) [![codecov](https://codecov.io/gh/e1r0nd/voca_rs/branch/master/graph/badge.svg)](https://codecov.io/gh/e1r0nd/voca_rs) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bd9aee15841a470da1408b83d05e09f7)](https://app.codacy.com/app/e1r0nd-crg/voca_rs?utm_source=github.com&utm_medium=referral&utm_content=e1r0nd/voca_rs&utm_campaign=Badge_Grade_Dashboard) [![license](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) +# voca_rs [![Build Status](https://travis-ci.org/e1r0nd/voca_rs.svg?branch=master)](https://travis-ci.org/e1r0nd/voca_rs) [![Crates version](http://meritbadge.herokuapp.com/voca_rs)](https://crates.io/crates/voca_rs) [![dependency status](https://deps.rs/crate/voca_rs/1.9.0/status.svg)](https://deps.rs/crate/voca_rs/1.9.0) [![codecov](https://codecov.io/gh/e1r0nd/voca_rs/branch/master/graph/badge.svg)](https://codecov.io/gh/e1r0nd/voca_rs) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bd9aee15841a470da1408b83d05e09f7)](https://app.codacy.com/app/e1r0nd-crg/voca_rs?utm_source=github.com&utm_medium=referral&utm_content=e1r0nd/voca_rs&utm_campaign=Badge_Grade_Dashboard) [![license](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) **Voca_rs is a Rust library for manipulating strings.** @@ -18,13 +18,15 @@ let string_in_words = split::words(&input_string); // => ["Lazy", "Load", "with", "XML", "Http", "Request", "and", "snake", "case"] let words_in_string = &string_in_words.join(" "); // => "Lazy Load with XML Http Request and snake case" -let snake_string = case::snake_case(&chop::slice(&words_in_string, 14, 31)); -// => "xml_http_request" -let truncated_string = chop::prune(&words_in_string, 15, ""); -// => "Lazy Load..." +let truncated_string = chop::prune(&words_in_string, 21, ""); +// => "Lazy Load with XML..." +let sliced_string = chop::slice(&truncated_string, 5, -2); +// => "Load with XML." +let snaked_string = case::snake_case(&sliced_string); +// => "load_with_xml" ``` -Using traits (all methods start from an underscore symbol): +Using traits (all methods start from the underscore symbol): ```rust use voca_rs::Voca; @@ -186,7 +188,6 @@ Build a project: `cargo build` -> `./target/debug` ## Roadmap -- Rewrite the code, so the functions (when it is possible) are accessible directly on String/&str. That can be achieved using an extension trait. - Possible refactoring: all `position` indexes covert to zero-based and add a comment to each doc. - Change all inner arguments to Enums (instead `string` or `bool`) diff --git a/src/utils.rs b/src/utils.rs index 67c57a47..af0ffade 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -7,9 +7,9 @@ /// ``` /// use voca_rs::*; /// utils::VERSION; -/// // => "1.8.0" +/// // => "1.9.0" /// ``` -pub const VERSION: &str = "1.8.0"; +pub const VERSION: &str = "1.9.0"; /// The concatenation of the `ascii_lowercase` and `ascii_uppercase` constants described below. This value is not locale-dependent. /// diff --git a/tests/unit/readme.rs b/tests/unit/readme.rs index c0c2abc4..c11fcb8f 100644 --- a/tests/unit/readme.rs +++ b/tests/unit/readme.rs @@ -9,21 +9,21 @@ fn example_functions() { string_in_words, ["Lazy", "Load", "with", "XML", "Http", "Request", "and", "snake", "case"] ); - let words_in_string = &string_in_words.join(" "); // => "Lazy Load with XML Http Request and snake case" assert_eq!( words_in_string, "Lazy Load with XML Http Request and snake case" ); - - let snake_string = voca_rs::case::snake_case(&voca_rs::chop::slice(&words_in_string, 14, 31)); - // => "xml_http_request" - assert_eq!(snake_string, "xml_http_request"); - - let truncated_string = voca_rs::chop::prune(&words_in_string, 15, ""); - // => "Lazy Load..." - assert_eq!(truncated_string, "Lazy Load..."); + let truncated_string = voca_rs::chop::prune(&words_in_string, 21, ""); + // => "Lazy Load with XML..." + assert_eq!(truncated_string, "Lazy Load with XML..."); + let sliced_string = voca_rs::chop::slice(&truncated_string, 5, -2); + // => "Load with XML." + assert_eq!(sliced_string, "Load with XML."); + let snaked_string = voca_rs::case::snake_case(&sliced_string); + // => "load_with_xml" + assert_eq!(snaked_string, "load_with_xml"); } #[test] @@ -65,4 +65,14 @@ fn example_traits() { ._slice(5, -2); let expected_string5 = "load_with_xml"; assert_eq!(input_string5._snake_case(), expected_string5); + + // Test #6 + let input_string6 = "LazyLoad with XMLHttpRequest and snake_case" + ._words() + .join(" ") + ._prune(21, "") + ._slice(5, -2) + ._snake_case(); + let expected_string6 = "load_with_xml"; + assert_eq!(input_string6, expected_string6); } diff --git a/tests/unit/utils.rs b/tests/unit/utils.rs index 0a1120ed..bce9be3d 100644 --- a/tests/unit/utils.rs +++ b/tests/unit/utils.rs @@ -2,7 +2,7 @@ #[test] fn version() { - assert_eq!(voca_rs::utils::VERSION, "1.8.0"); + assert_eq!(voca_rs::utils::VERSION, "1.9.0"); } #[test] fn ascii_letters() {