1
Fork 0

Compare commits

...

14 Commits
0.2.0 ... main

Author SHA1 Message Date
Bauke fea1fb3113
Version 0.2.3! 2024-01-21 12:43:22 +01:00
Bauke a1ab028c81
Redo the cargo-make configuration to make use of default tasks. 2024-01-21 12:43:04 +01:00
Bauke 0abf8642d3
Add other cargo utilities. 2024-01-21 12:38:51 +01:00
Bauke 67bb812804
Add the Development section. 2024-01-21 12:28:00 +01:00
Bauke 4495738d19
Update dependencies. 2024-01-21 12:26:27 +01:00
Bauke 5ed5427194
Add Nix flake and direnv files. 2024-01-21 12:24:45 +01:00
Bauke 4b56c85574
Version 0.2.2! 2022-09-26 12:15:48 +02:00
Bauke 4ca55decf7
Change repository to Gitea. 2022-09-26 12:15:37 +02:00
Bauke 4f8f8e22bf
Version 0.2.1! 2022-09-26 12:14:40 +02:00
Bauke d38c3bbebd
Update Holllo email. 2022-09-26 12:12:45 +02:00
Bauke a73c981a82
Rewrite readme. 2022-09-26 12:12:31 +02:00
Bauke 72fd56f313
Update dependencies and project style. 2022-09-26 12:09:40 +02:00
Bauke e5312509b9
Add documentation. 2022-09-26 11:55:35 +02:00
Bauke 581a79fe6b
Add cargo-make file. 2022-09-26 11:50:47 +02:00
15 changed files with 231 additions and 37 deletions

3
.envrc Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
use flake

13
.gitignore vendored
View File

@ -1,14 +1,5 @@
# Generated by Cargo
# will have compiled files and executables
.direnv/
coverage/
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

View File

@ -3,10 +3,10 @@
[package]
name = "gravatar-rs"
description = "Gravatar image URL library"
authors = ["Holllo <helllo@holllo.cc>"]
version = "0.2.0"
repository = "https://git.bauke.xyz/Holllo/gravatar-rs"
license = "MIT OR Apache-2.0"
repository = "https://github.com/Holllo/gravatar-rs"
version = "0.2.3"
authors = ["Holllo <helllo@holllo.org>"]
edition = "2021"
keywords = ["gravatar", "ivatar", "libravatar"]
@ -15,7 +15,7 @@ path = "source/lib.rs"
[dependencies]
md5 = "0.7.0"
urlencoding = "2.1.0"
urlencoding = "2.1.3"
[dev-dependencies]
insta = "1.14.0"
insta = "1.34.0"

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Holllo <helllo@holllo.cc>
Copyright (c) 2022 Holllo <helllo@holllo.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

27
Makefile.toml Normal file
View File

@ -0,0 +1,27 @@
# Do a full check of everything.
[tasks.complete-check]
dependencies = [
"clean",
"format",
"check",
"clippy",
"test",
"code-coverage",
"docs",
"build",
"audit-flow",
"outdated-flow"
]
# Run cargo-tarpaulin and output the test coverage.
[tasks.code-coverage]
workspace = false
command = "cargo"
args = [
"tarpaulin",
"--exclude-files=target/*",
"--out=html",
"--output-dir=coverage",
"--skip-clean",
"--target-dir=target/tarpaulin",
]

View File

@ -1,28 +1,34 @@
# gravatar-rs
# Gravatar 📇 Rust
> Gravatar image URL library
> **Gravatar image URL library for Rust.**
## API
For full documentation see [docs.rs].
For full documentation see [docs.rs](https://docs.rs/gravatar-rs).
[docs.rs]: https://docs.rs/gravatar-rs
## Example
```rust
use gravatar_rs::Generator;
let generator = Generator::default();
let gravatar_url = generator.generate("helllo@holllo.cc");
let gravatar_url = generator.generate("helllo@holllo.org");
assert_eq!(
gravatar_url,
"https://www.gravatar.com/avatar/ebff9105dce4954b1bdb57fdab079ff3"
"https://www.gravatar.com/avatar/e9a2c03d607ec80a5b725ad42c19ee36"
);
```
## Development
With [Nix flakes](https://nixos.wiki/wiki/Flakes) and [direnv](https://direnv.net/) installed and enabled, all the required dependencies are automatically loaded from [`shell.nix`](./shell.nix). Then [cargo-make](https://sagiegurari.github.io/cargo-make/) can be used to build, deploy and lint the code. The available tasks are all described in the [`Makefile.toml`](Makefile.toml) configuration.
## Feedback
Found a problem or want to request a new feature? Email [helllo@holllo.org](mailto:helllo@holllo.org) and I'll see what I can do for you.
## License
This project is licensed under either of [Apache License, Version 2.0](https://github.com/Holllo/gravatar-rs/blob/main/LICENSE-Apache) or [MIT license](https://github.com/Holllo/gravatar-rs/blob/main/LICENSE-MIT) at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in either crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Distributed under the [Apache License 2.0](https://spdx.org/licenses/Apache-2.0.html) and [MIT](https://spdx.org/licenses/MIT.html) licenses, see [LICENSE-Apache](https://git.bauke.xyz/Holllo/gravatar-rs/src/branch/main/LICENSE-Apache) and [LICENSE-MIT](https://git.bauke.xyz/Holllo/gravatar-rs/src/branch/main/LICENSE-MIT) for more information.

128
flake.lock Normal file
View File

@ -0,0 +1,128 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1705697961,
"narHash": "sha256-XepT3WS516evSFYkme3GrcI3+7uwXHqtHbip+t24J7E=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e5d1c87f5813afde2dda384ac807c57a105721cc",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1681358109,
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1705803528,
"narHash": "sha256-nChqKQPRXxmGBEkHse39LjNpkNKk4U1xPQ4a4oYlUdw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "bd7e8f4e122e11c934a576abc04327764f9bf19b",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

17
flake.nix Normal file
View File

@ -0,0 +1,17 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
in
{
devShells.default = import ./shell.nix { inherit pkgs; };
}
);
}

3
rustup-toolchain.toml Normal file
View File

@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
components = ["cargo", "clippy", "rustfmt", "rust-src"]

18
shell.nix Normal file
View File

@ -0,0 +1,18 @@
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
let
rustup-toolchain = rust-bin.fromRustupToolchainFile ./rustup-toolchain.toml;
in
mkShell rec {
packages = [
cargo-audit
cargo-edit
cargo-insta
cargo-make
cargo-outdated
cargo-tarpaulin
rustup-toolchain
];
}

View File

@ -17,11 +17,11 @@
//!
//! let generator = Generator::default();
//!
//! let gravatar_url = generator.generate("helllo@holllo.cc");
//! let gravatar_url = generator.generate("helllo@holllo.org");
//!
//! assert_eq!(
//! gravatar_url,
//! "https://www.gravatar.com/avatar/ebff9105dce4954b1bdb57fdab079ff3"
//! "https://www.gravatar.com/avatar/e9a2c03d607ec80a5b725ad42c19ee36"
//! );
//! ```
//!
@ -79,11 +79,11 @@ impl Generator {
/// ```rust
/// use gravatar_rs::Generator;
///
/// let hash = Generator::hash_email("helllo@holllo.cc");
/// let hash = Generator::hash_email("helllo@holllo.org");
///
/// assert_eq!(
/// hash,
/// "ebff9105dce4954b1bdb57fdab079ff3"
/// "e9a2c03d607ec80a5b725ad42c19ee36"
/// );
/// ```
///
@ -114,6 +114,7 @@ impl Generator {
/// Returns all configurable options as a query parameter string.
pub fn query_parameters(&self) -> String {
/// Shorthand for [`urlencoding::encode`].
fn encode<D: std::fmt::Display>(data: D) -> String {
urlencoding::encode(&data.to_string()).into_owned()
}

View File

@ -1,7 +1,7 @@
use gravatar_rs::Generator;
const BAUKE_EMAIL: &str = "me@bauke.xyz";
const HOLLLO_EMAIL: &str = "helllo@holllo.cc";
const HOLLLO_EMAIL: &str = "helllo@holllo.org";
#[test]
fn test_hash_email() {

View File

@ -4,5 +4,5 @@ expression: urls
---
[
"https://cdn.libravatar.org/avatar/ecd836ee843ff0ab75d4720bd40c2baf.jpg?d=identicon&f=y&s=128&r=pg",
"https://cdn.libravatar.org/avatar/ebff9105dce4954b1bdb57fdab079ff3.jpg?d=identicon&f=y&s=128&r=pg",
"https://cdn.libravatar.org/avatar/e9a2c03d607ec80a5b725ad42c19ee36.jpg?d=identicon&f=y&s=128&r=pg",
]

View File

@ -7,14 +7,14 @@ expression: snapshot
"generate-gravatar",
[
"https://www.gravatar.com/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
"https://www.gravatar.com/avatar/ebff9105dce4954b1bdb57fdab079ff3",
"https://www.gravatar.com/avatar/e9a2c03d607ec80a5b725ad42c19ee36",
],
),
(
"generate-libravatar",
[
"https://cdn.libravatar.org/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
"https://cdn.libravatar.org/avatar/ebff9105dce4954b1bdb57fdab079ff3",
"https://cdn.libravatar.org/avatar/e9a2c03d607ec80a5b725ad42c19ee36",
],
),
]

View File

@ -17,14 +17,14 @@ expression: snapshot
),
(
"hash-holllo",
"ebff9105dce4954b1bdb57fdab079ff3",
"e9a2c03d607ec80a5b725ad42c19ee36",
),
(
"hash-holllo-whitespace",
"ebff9105dce4954b1bdb57fdab079ff3",
"e9a2c03d607ec80a5b725ad42c19ee36",
),
(
"hash-holllo-casing",
"ebff9105dce4954b1bdb57fdab079ff3",
"e9a2c03d607ec80a5b725ad42c19ee36",
),
]