Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nicelgueta committed Jun 19, 2024
1 parent 97afe6f commit 70641d0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 42 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/pyci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ on:
- main
tags:
- '*'
pull_request:
workflow_dispatch:
paths:
- src/*
- rustyrs.pyi

permissions:
contents: read
Expand Down Expand Up @@ -140,7 +141,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
# if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, musllinux, windows, macos]
steps:
- uses: actions/download-artifact@v4
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,3 @@ jobs:
archive: $bin-${{ matrix.target }}
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }}
token: ${{ secrets.GITHUB_TOKEN }}

# push-to-registry:
# name: "Push Docker image to Docker Hub"
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
# needs:
# - "get-tag"
# - "upload-assets"
# runs-on: "ubuntu-latest"
# steps:
# - name: "Check out the repo"
# uses: actions/checkout@v3

# - name: "Log in to Docker Hub"
# uses: "docker/login-action@v2"
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: "Extract metadata (tags, labels) for Docker"
# id: "meta"
# uses: "docker/metadata-action@v4"
# with:
# images: "bwks/shazam"

# - name: "Build and push Docker image"
# uses: "docker/build-push-action@v3"
# with:
# context: .
# push: true
# tags: bwks/shazam:latest,bwks/shazam:v${{ needs.get-tag.outputs.pkg-version }}
# labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rustyrs"
version = "0.4.0"
version = "0.4.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Usable as a standalone binary, web applications as a WebAssembly module (WASM),
## Why?
I needed a way to generate random slugs for a web project so thought it was a good opporunity to try out Rust's WebAssembly capabilities while also being able to use the same code as a zero-dependency python module for other projects.

### Key features
- No dependencies
- Fast
- Customizable slug length in words
- Over half a million unique combinations for 2-word slugs ranging up to over **280 trillion** unique combinations for 5-word slugs

## Usage

### As a Rust binary
Expand All @@ -34,7 +40,6 @@ floral-apportioned-bobcat
```
____________


### As a WASM module
```bash
# If wasm pack is not already installed
Expand Down Expand Up @@ -74,18 +79,29 @@ maturin develop --features python

Then from Python:
```python
from rustyrs import generate_slugs
slugs: list[str] = generate_slugs(3, 5)
from rustyrs import random_slugs
slugs: list[str] = random_slugs(3, 5)

# slugs: ['reflecting-unsealed-mamba', 'disabling-addicting-asp', 'pliable-begotten-barnacle', 'vaulting-telepathic-caracal', 'canonical-graven-beetle']
```

Other features:
- `get_slug(word_length: int) -> str`: Generate a single slug of a specific length
- `SlugGenerator(word_length: int)`: Create a generator object to generate slugs of a specific length. Can generate slugs infinitely.
```python
from rustyrs import SlugGenerator
gen = SlugGenerator(3)
print(next(gen)) # 'unwieldy-unsuspecting-ant'
```
- `combinations(word_length: int) -> int`: Get the number of possible combinations for a given word length
```python
from rustyrs import combinations
print(combinations(3)) # 556,284
```

## Performance
- 1m x 2 word slugs: ~4.995s
- 1m x 5 word slugs: ~10.447s

## Word Data
> Sourced from [Corpora](https://github.com/dariusk/corpora/blob/master/data/words) by [Darius Kazemi](https://github.com/dariusk)
## License
MIT
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ mod core {
}
}


#[cfg(test)]
mod tests {

Expand Down

0 comments on commit 70641d0

Please sign in to comment.