From a7e040170b7eafda61377bd40c292b74aa0cf80a Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:04:28 -0400 Subject: [PATCH 01/14] docs: add link to web demo source code --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eb785ca..183a4b3 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ const output: number = czv.rowCount({ console.log(output); ``` +You can view source code for an example website using `czv-wasm` at https://github.com/rzmk/czv/tree/main/czv-wasm/examples/web-demo. + ### Python ```bash @@ -86,10 +88,10 @@ print(output) # 4 ## Available operations -| czv (Rust) | czv-wasm (JS/TS) | czv-python | Summary | -| ---------------------------------------- | -------------------------------------- | ----------------------------------------------- | ------------------------- | -| [`count::RowCount`](czv/src/count.rs) | [`rowCount`](czv-wasm/src/count.rs) | [`count.row_count`](czv-python/src/count.rs) | Get the number of rows | -| [`count::ColumnCount`](czv/src/count.rs) | [`columnCount`](czv-wasm/src/count.rs) | [`count.column_count`](czv-python/src/count.rs) | Get the number of columns | +| czv (Rust) | czv-wasm (JS/TS) | czv-python | Summary | +| --------------------------------- | -------------------------------------- | ----------------------------------------- | ------------------------- | +| [`RowCount`](czv/src/count.rs) | [`rowCount`](czv-wasm/src/count.rs) | [`row_count`](czv-python/src/count.rs) | Get the number of rows | +| [`ColumnCount`](czv/src/count.rs) | [`columnCount`](czv-wasm/src/count.rs) | [`column_count`](czv-python/src/count.rs) | Get the number of columns | ## Development From f435642358041cce0aeb1e1deb03d35e328a63b0 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:16:47 -0400 Subject: [PATCH 02/14] ci: add `cargo test` & `cargo clippy` on push/PR --- .github/workflows/cargo-runner.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/cargo-runner.yml diff --git a/.github/workflows/cargo-runner.yml b/.github/workflows/cargo-runner.yml new file mode 100644 index 0000000..9e30554 --- /dev/null +++ b/.github/workflows/cargo-runner.yml @@ -0,0 +1,24 @@ +name: Run cargo commands + +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + name: czv - latest + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: + - stable + # - beta + # - nightly + steps: + - uses: actions/checkout@v4 + - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} + - run: cargo clippy + - run: cargo test --verbose From c0b76fa54372fc6dc4b1457b1487a7e3c29cdf38 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:18:38 -0400 Subject: [PATCH 03/14] refactor: improve error-handling, fix lints, & update criterion --- Cargo.lock | 140 +++++++++++++----------------------------- czv-python/Cargo.toml | 2 +- czv-python/src/lib.rs | 8 +-- czv-wasm/src/lib.rs | 20 +++--- czv/Cargo.toml | 2 +- czv/src/lib.rs | 4 +- 6 files changed, 58 insertions(+), 118 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index acccdc7..62866d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,35 +17,24 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + [[package]] name = "anyhow" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -99,24 +88,28 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.25" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ - "bitflags 1.3.2", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +dependencies = [ + "anstyle", "clap_lex", - "indexmap", - "textwrap", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "console_error_panic_hook" @@ -130,19 +123,19 @@ dependencies = [ [[package]] name = "criterion" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ "anes", - "atty", "cast", "ciborium", "clap", "criterion-plot", + "is-terminal", "itertools", - "lazy_static", "num-traits", + "once_cell", "oorandom", "plotters", "rayon", @@ -281,12 +274,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "heck" version = "0.4.1" @@ -295,22 +282,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown", -] +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "indoc" @@ -318,6 +292,17 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + [[package]] name = "itertools" version = "0.10.5" @@ -342,12 +327,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.155" @@ -406,12 +385,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "parking_lot" version = "0.12.3" @@ -471,9 +444,9 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -484,6 +457,7 @@ version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" dependencies = [ + "anyhow", "cfg-if", "indoc", "libc", @@ -576,7 +550,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ - "bitflags 2.5.0", + "bitflags", ] [[package]] @@ -696,9 +670,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.66" +version = "2.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" dependencies = [ "proc-macro2", "quote", @@ -711,12 +685,6 @@ version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" - [[package]] name = "thiserror" version = "1.0.61" @@ -915,22 +883,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.8" @@ -940,12 +892,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/czv-python/Cargo.toml b/czv-python/Cargo.toml index 24b0028..616902d 100644 --- a/czv-python/Cargo.toml +++ b/czv-python/Cargo.toml @@ -13,5 +13,5 @@ crate-type = ["cdylib", "rlib"] anyhow = "1.0.86" csv = "1.3.0" czv = { path = "../czv" } -pyo3 = { version = "0.21.2", features = ["extension-module"] } +pyo3 = { version = "0.21.2", features = ["anyhow", "extension-module"] } thiserror = "1.0.61" diff --git a/czv-python/src/lib.rs b/czv-python/src/lib.rs index 4c401de..8bdcc25 100644 --- a/czv-python/src/lib.rs +++ b/czv-python/src/lib.rs @@ -8,25 +8,25 @@ pub struct CzvError(anyhow::Error); impl From for CzvError { fn from(value: OGError) -> Self { - value.into() + Self(anyhow::anyhow!(value)) } } impl From for CzvError { fn from(value: pyo3::PyErr) -> Self { - value.into() + Self(anyhow::anyhow!(value)) } } impl From for CzvError { fn from(value: csv::Error) -> Self { - value.into() + Self(anyhow::anyhow!(value)) } } impl From for pyo3::PyErr { fn from(value: CzvError) -> Self { - value.into() + anyhow::anyhow!(value).into() } } diff --git a/czv-wasm/src/lib.rs b/czv-wasm/src/lib.rs index f51340d..286e831 100644 --- a/czv-wasm/src/lib.rs +++ b/czv-wasm/src/lib.rs @@ -44,19 +44,13 @@ use wasm_bindgen::JsValue; // Error-handling helpers #[derive(thiserror::Error, Debug)] -#[error("{0}")] -pub struct CzvError(anyhow::Error); - -impl From for CzvError { - fn from(value: csv::Error) -> Self { - value.into() - } -} - -impl From for CzvError { - fn from(value: serde_wasm_bindgen::Error) -> Self { - value.into() - } +pub enum CzvError { + #[error("{0}")] + GeneralError(#[from] anyhow::Error), + #[error("{0}")] + CsvError(#[from] csv::Error), + #[error("{0}")] + SerdeWasmBindgenError(#[from] serde_wasm_bindgen::Error), } impl From for JsValue { diff --git a/czv/Cargo.toml b/czv/Cargo.toml index 9ca4510..5af3ba6 100644 --- a/czv/Cargo.toml +++ b/czv/Cargo.toml @@ -16,7 +16,7 @@ thiserror = "1.0.61" typed-builder = "0.18.2" [dev-dependencies] -criterion = { version = "0.4", features = ["html_reports"] } +criterion = { version = "0.5", features = ["html_reports"] } [[bench]] name = "benches" diff --git a/czv/src/lib.rs b/czv/src/lib.rs index d43d354..32e7969 100644 --- a/czv/src/lib.rs +++ b/czv/src/lib.rs @@ -55,13 +55,13 @@ pub struct CzvError(pub anyhow::Error); impl From for CzvError { fn from(value: anyhow::Error) -> Self { - value.into() + Self(value) } } impl From for CzvError { fn from(value: csv::Error) -> Self { - value.into() + Self(anyhow::anyhow!(value)) } } From b4dc96ac41e1c7d0a9baadac06de9d40c3de2a31 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:28:04 -0400 Subject: [PATCH 04/14] chore: update czv to v0.0.2 (remove `atty` dep) --- Cargo.lock | 2 +- czv/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62866d0..8ce783d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "czv" -version = "0.0.1" +version = "0.0.2" dependencies = [ "anyhow", "criterion", diff --git a/czv/Cargo.toml b/czv/Cargo.toml index 5af3ba6..1fcb3e8 100644 --- a/czv/Cargo.toml +++ b/czv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "czv" -version = "0.0.1" +version = "0.0.2" authors = ["Mueez Khan"] description = "Rust library for performing CSV-related operations for data engineering and analysis." repository = "https://github.com/rzmk/czv" From bdaf0eb853ff79c16669e731a6cf8f77507ee0de Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:38:46 -0400 Subject: [PATCH 05/14] docs: add link to https://docs.rs/czv --- README.md | 2 +- czv-python/README.md | 2 +- czv-python/czv.pyi | 2 +- czv-wasm/README.md | 2 +- czv-wasm/src/lib.rs | 2 +- czv/README.md | 2 +- czv/src/lib.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 183a4b3..9a189ab 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ czv includes libraries for Rust, Python, and WebAssembly (JavaScript and TypeScr ## Links - czv GitHub repository: -- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) +- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) diff --git a/czv-python/README.md b/czv-python/README.md index 284e5c9..db51388 100644 --- a/czv-python/README.md +++ b/czv-python/README.md @@ -5,7 +5,7 @@ Python library for [czv](https://github.com/rzmk/czv). czv is a library of CSV-r ## Links - czv GitHub repository: -- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) +- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) diff --git a/czv-python/czv.pyi b/czv-python/czv.pyi index ed45162..775c69e 100644 --- a/czv-python/czv.pyi +++ b/czv-python/czv.pyi @@ -27,7 +27,7 @@ print(output) # 4 ## Links - czv GitHub repository: -- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) +- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) diff --git a/czv-wasm/README.md b/czv-wasm/README.md index 6e5cbde..18ef562 100644 --- a/czv-wasm/README.md +++ b/czv-wasm/README.md @@ -5,7 +5,7 @@ WebAssembly (JavaScript and TypeScript) library for [czv](https://github.com/rzm ## Links - czv GitHub repository: -- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) +- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) diff --git a/czv-wasm/src/lib.rs b/czv-wasm/src/lib.rs index 286e831..54bb076 100644 --- a/czv-wasm/src/lib.rs +++ b/czv-wasm/src/lib.rs @@ -29,7 +29,7 @@ //! # Links //! //! - czv GitHub repository: -//! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) +//! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv)) //! - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) //! - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) diff --git a/czv/README.md b/czv/README.md index 5b73a3c..e0e38cd 100644 --- a/czv/README.md +++ b/czv/README.md @@ -5,7 +5,7 @@ Rust library for [czv](https://github.com/rzmk/czv). czv is a library of CSV-rel ## Links - czv GitHub repository: -- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) +- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) diff --git a/czv/src/lib.rs b/czv/src/lib.rs index 32e7969..05fd06f 100644 --- a/czv/src/lib.rs +++ b/czv/src/lib.rs @@ -33,7 +33,7 @@ //! # Links //! //! - czv GitHub repository: -//! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) +//! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv)) //! - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) //! - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) From ad526cc7173c55af8b487254464b1f8d9ed7bfa9 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:48:28 -0400 Subject: [PATCH 06/14] docs: add docstring for `ColumnCountBuilder::execute` --- czv/src/count.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/czv/src/count.rs b/czv/src/count.rs index d00cb33..f84bb0b 100644 --- a/czv/src/count.rs +++ b/czv/src/count.rs @@ -207,6 +207,7 @@ impl< __file_path: typed_builder::Optional>, > ColumnCountBuilder<(__file_path, __file_data)> { + /// Returns the column count. pub fn execute(self) -> Result { let builder = self.__build(); column_count(builder.file_path, builder.file_data) From 4e62cc2ecdca74c03c056188bce4fa1271c713eb Mon Sep 17 00:00:00 2001 From: Mueez Khan <30333942+rzmk@users.noreply.github.com> Date: Fri, 21 Jun 2024 00:19:44 -0400 Subject: [PATCH 07/14] docs: fix Rust example to use `include_header_row` --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a189ab..642569c 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,11 @@ apple,2.50 banana,3.00 strawberry,1.50 "; - let output: usize = RowCount::new().file_data(data).execute()?; - println!("{output}"); // 3 + let output: usize = RowCount::new() + .file_data(data) + .include_header_row(true) + .execute()?; + println!("{output}"); // 4 Ok(()) } ``` From 254e34fe053081062b3e4f8628db94ef9e0c92ce Mon Sep 17 00:00:00 2001 From: Mueez Khan <30333942+rzmk@users.noreply.github.com> Date: Fri, 21 Jun 2024 01:18:45 -0400 Subject: [PATCH 08/14] docs: remove links to non-existent files --- czv/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/czv/README.md b/czv/README.md index e0e38cd..022987f 100644 --- a/czv/README.md +++ b/czv/README.md @@ -67,9 +67,9 @@ For benchmarks we use [criterion.rs](https://github.com/bheisler/criterion.rs). Licensed under either of - Apache License, Version 2.0 - ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + (http://www.apache.org/licenses/LICENSE-2.0) - MIT license - ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + (http://opensource.org/licenses/MIT) at your option. From 55835772ed365aa7eec47bb047b9ae1265fd714e Mon Sep 17 00:00:00 2001 From: Mueez Khan <30333942+rzmk@users.noreply.github.com> Date: Fri, 21 Jun 2024 01:32:09 -0400 Subject: [PATCH 09/14] docs: fix czv-wasm node-demo --- czv-wasm/examples/node-demo/sample.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/czv-wasm/examples/node-demo/sample.ts b/czv-wasm/examples/node-demo/sample.ts index f969962..8197c19 100644 --- a/czv-wasm/examples/node-demo/sample.ts +++ b/czv-wasm/examples/node-demo/sample.ts @@ -1,3 +1,5 @@ +// See the README.md file in this file's folder +// for how to run this example import czv from "../../pkg/czv-ts"; const options: czv.RowCountOptions = { @@ -5,6 +7,7 @@ const options: czv.RowCountOptions = { apple,2.50 banana,3.00 strawberry,1.50`, + include_header_row: true }; const output: number = czv.rowCount(options); From 719f3e1512ef6a3e3d3cca07a665b8763dddf7fb Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Fri, 21 Jun 2024 05:52:34 -0400 Subject: [PATCH 10/14] docs: comment slice docstring while disabled --- czv/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/czv/src/lib.rs b/czv/src/lib.rs index 05fd06f..fcf36c8 100644 --- a/czv/src/lib.rs +++ b/czv/src/lib.rs @@ -41,7 +41,7 @@ pub mod count; #[doc(inline)] pub use count::{ColumnCount, RowCount}; -/// Extract a section of rows. +// Extract a section of rows. // pub mod slice; // #[doc(inline)] // pub use slice::Slice; From 358fe0a8b92ed2e29f2a9dcc5326419db3b4099c Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Fri, 21 Jun 2024 23:30:44 -0400 Subject: [PATCH 11/14] test: add row count with header --- czv-wasm/tests/count.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/czv-wasm/tests/count.rs b/czv-wasm/tests/count.rs index d0b8164..4c858c2 100644 --- a/czv-wasm/tests/count.rs +++ b/czv-wasm/tests/count.rs @@ -6,7 +6,7 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); #[test] #[wasm_bindgen_test] -fn basic() -> Result<()> { +fn row_count_nonheader() -> Result<()> { let options = RowCountOptions { file_data: "fruit,price apple,2.00 @@ -19,3 +19,19 @@ strawberry,3.00" assert_eq!(result, 3); Ok(()) } + +#[test] +#[wasm_bindgen_test] +fn row_count_header() -> Result<()> { + let options = RowCountOptions { + file_data: "fruit,price +apple,2.00 +banana,1.50 +strawberry,3.00" + .to_string(), + include_header_row: Some(true), + }; + let result = czv_wasm::count::row_count(options)?; + assert_eq!(result, 4); + Ok(()) +} From 1e7c4a1569ec07a0a7aa2fe29eaf6057aef9e030 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Sat, 22 Jun 2024 08:38:00 -0400 Subject: [PATCH 12/14] test(wasm): add `column_count` --- czv-wasm/tests/count.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/czv-wasm/tests/count.rs b/czv-wasm/tests/count.rs index 4c858c2..7b04e7a 100644 --- a/czv-wasm/tests/count.rs +++ b/czv-wasm/tests/count.rs @@ -1,5 +1,5 @@ use czv_wasm; -use czv_wasm::count::RowCountOptions; +use czv_wasm::count::{ColumnCountOptions, RowCountOptions}; use czv_wasm::Result; use wasm_bindgen_test::*; wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); @@ -35,3 +35,18 @@ strawberry,3.00" assert_eq!(result, 4); Ok(()) } + +#[test] +#[wasm_bindgen_test] +fn column_count() -> Result<()> { + let options = ColumnCountOptions { + file_data: "fruit,price +apple,2.00 +banana,1.50 +strawberry,3.00" + .to_string(), + }; + let result = czv_wasm::count::column_count(options)?; + assert_eq!(result, 2); + Ok(()) +} From 5b8c057e5d3b7d0459383b77a3078e8bc3144ebc Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 25 Jun 2024 21:19:24 -0400 Subject: [PATCH 13/14] test(python): rename tests & add column count test --- czv-python/tests/test_count.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/czv-python/tests/test_count.py b/czv-python/tests/test_count.py index c796835..e5b2f9a 100644 --- a/czv-python/tests/test_count.py +++ b/czv-python/tests/test_count.py @@ -2,12 +2,12 @@ import czv import pytest from .test_data import test_data -class TestCountFunc: +class TestRowCount: @pytest.mark.parametrize( "file_name,expected", [("fruits.csv", 3), ("constituents_altnames.csv", 33971)], ) - def test_count(self, file_name, expected): + def test_row_count(self, file_name, expected): """Count the total number of non-header rows.""" result = czv.row_count(file_path=test_data[file_name]) @@ -17,8 +17,19 @@ class TestCountFunc: "file_name,expected", [("fruits.csv", 4), ("constituents_altnames.csv", 33972)], ) - def test_include_header_row(self, file_name, expected): + def test_row_count_include_header_row(self, file_name, expected): """Count the total number of rows including the header row.""" result = czv.row_count(file_path=test_data[file_name], include_header_row=True) assert result == expected + +class TestColumnCount: + @pytest.mark.parametrize( + "file_name,expected", + [("fruits.csv", 2), ("constituents_altnames.csv", 6)], + ) + def test_column_count(self, file_name, expected): + """Count the total number of columns.""" + + result = czv.column_count(file_path=test_data[file_name]) + assert result == expected From fa02eddc1e607b8fdb11e7938ca03d2d7c7ca735 Mon Sep 17 00:00:00 2001 From: Mueez Khan <30333942+rzmk@users.noreply.github.com> Date: Fri, 7 Mar 2025 06:57:15 -0500 Subject: [PATCH 14/14] chore: delete .github/FUNDING.yml --- .github/FUNDING.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index baa721a..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: [rzmk]