Skip to content

Commit

Permalink
Finilized v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
a-merezhanyi committed Dec 1, 2019
1 parent 8c11c0b commit e5123b7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "voca_rs"
version = "1.8.0"
version = "1.9.0"
authors = ["Anatol Merezhanyi <a.merezhanyi@gmail.com>"]
license = "MIT"
description = "Voca_rs is a Rust library for manipulating strings. Inspired by Voca.js and string.py"
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.**

Expand All @@ -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;
Expand Down Expand Up @@ -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`)

Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
28 changes: 19 additions & 9 deletions tests/unit/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion tests/unit/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e5123b7

Please sign in to comment.