Compare commits
14 Commits
Author | SHA1 | Date |
---|---|---|
Bauke | fea1fb3113 | |
Bauke | a1ab028c81 | |
Bauke | 0abf8642d3 | |
Bauke | 67bb812804 | |
Bauke | 4495738d19 | |
Bauke | 5ed5427194 | |
Bauke | 4b56c85574 | |
Bauke | 4ca55decf7 | |
Bauke | 4f8f8e22bf | |
Bauke | d38c3bbebd | |
Bauke | a73c981a82 | |
Bauke | 72fd56f313 | |
Bauke | e5312509b9 | |
Bauke | 581a79fe6b |
|
@ -1,14 +1,5 @@
|
||||||
# Generated by Cargo
|
.direnv/
|
||||||
# will have compiled files and executables
|
coverage/
|
||||||
debug/
|
debug/
|
||||||
target/
|
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
|
Cargo.lock
|
||||||
|
|
||||||
# These are backup files generated by rustfmt
|
|
||||||
**/*.rs.bk
|
|
||||||
|
|
||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
|
||||||
*.pdb
|
|
||||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -3,10 +3,10 @@
|
||||||
[package]
|
[package]
|
||||||
name = "gravatar-rs"
|
name = "gravatar-rs"
|
||||||
description = "Gravatar image URL library"
|
description = "Gravatar image URL library"
|
||||||
authors = ["Holllo <helllo@holllo.cc>"]
|
repository = "https://git.bauke.xyz/Holllo/gravatar-rs"
|
||||||
version = "0.2.0"
|
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/Holllo/gravatar-rs"
|
version = "0.2.3"
|
||||||
|
authors = ["Holllo <helllo@holllo.org>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
keywords = ["gravatar", "ivatar", "libravatar"]
|
keywords = ["gravatar", "ivatar", "libravatar"]
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ path = "source/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
md5 = "0.7.0"
|
md5 = "0.7.0"
|
||||||
urlencoding = "2.1.0"
|
urlencoding = "2.1.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
insta = "1.14.0"
|
insta = "1.34.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -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",
|
||||||
|
]
|
24
README.md
24
README.md
|
@ -1,28 +1,34 @@
|
||||||
# gravatar-rs
|
# Gravatar 📇 Rust
|
||||||
|
|
||||||
> Gravatar image URL library
|
> **Gravatar image URL library for Rust.**
|
||||||
|
|
||||||
## API
|
## 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
|
```rust
|
||||||
use gravatar_rs::Generator;
|
use gravatar_rs::Generator;
|
||||||
|
|
||||||
let generator = Generator::default();
|
let generator = Generator::default();
|
||||||
|
|
||||||
let gravatar_url = generator.generate("helllo@holllo.cc");
|
let gravatar_url = generator.generate("helllo@holllo.org");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gravatar_url,
|
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
|
## 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.
|
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.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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; };
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "stable"
|
||||||
|
components = ["cargo", "clippy", "rustfmt", "rust-src"]
|
|
@ -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
|
||||||
|
];
|
||||||
|
}
|
|
@ -17,11 +17,11 @@
|
||||||
//!
|
//!
|
||||||
//! let generator = Generator::default();
|
//! let generator = Generator::default();
|
||||||
//!
|
//!
|
||||||
//! let gravatar_url = generator.generate("helllo@holllo.cc");
|
//! let gravatar_url = generator.generate("helllo@holllo.org");
|
||||||
//!
|
//!
|
||||||
//! assert_eq!(
|
//! assert_eq!(
|
||||||
//! gravatar_url,
|
//! gravatar_url,
|
||||||
//! "https://www.gravatar.com/avatar/ebff9105dce4954b1bdb57fdab079ff3"
|
//! "https://www.gravatar.com/avatar/e9a2c03d607ec80a5b725ad42c19ee36"
|
||||||
//! );
|
//! );
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
@ -79,11 +79,11 @@ impl Generator {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use gravatar_rs::Generator;
|
/// use gravatar_rs::Generator;
|
||||||
///
|
///
|
||||||
/// let hash = Generator::hash_email("helllo@holllo.cc");
|
/// let hash = Generator::hash_email("helllo@holllo.org");
|
||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// hash,
|
/// hash,
|
||||||
/// "ebff9105dce4954b1bdb57fdab079ff3"
|
/// "e9a2c03d607ec80a5b725ad42c19ee36"
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
@ -114,6 +114,7 @@ impl Generator {
|
||||||
|
|
||||||
/// Returns all configurable options as a query parameter string.
|
/// Returns all configurable options as a query parameter string.
|
||||||
pub fn query_parameters(&self) -> String {
|
pub fn query_parameters(&self) -> String {
|
||||||
|
/// Shorthand for [`urlencoding::encode`].
|
||||||
fn encode<D: std::fmt::Display>(data: D) -> String {
|
fn encode<D: std::fmt::Display>(data: D) -> String {
|
||||||
urlencoding::encode(&data.to_string()).into_owned()
|
urlencoding::encode(&data.to_string()).into_owned()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use gravatar_rs::Generator;
|
use gravatar_rs::Generator;
|
||||||
|
|
||||||
const BAUKE_EMAIL: &str = "me@bauke.xyz";
|
const BAUKE_EMAIL: &str = "me@bauke.xyz";
|
||||||
const HOLLLO_EMAIL: &str = "helllo@holllo.cc";
|
const HOLLLO_EMAIL: &str = "helllo@holllo.org";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hash_email() {
|
fn test_hash_email() {
|
||||||
|
|
|
@ -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/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",
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,14 +7,14 @@ expression: snapshot
|
||||||
"generate-gravatar",
|
"generate-gravatar",
|
||||||
[
|
[
|
||||||
"https://www.gravatar.com/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
|
"https://www.gravatar.com/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
|
||||||
"https://www.gravatar.com/avatar/ebff9105dce4954b1bdb57fdab079ff3",
|
"https://www.gravatar.com/avatar/e9a2c03d607ec80a5b725ad42c19ee36",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"generate-libravatar",
|
"generate-libravatar",
|
||||||
[
|
[
|
||||||
"https://cdn.libravatar.org/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
|
"https://cdn.libravatar.org/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
|
||||||
"https://cdn.libravatar.org/avatar/ebff9105dce4954b1bdb57fdab079ff3",
|
"https://cdn.libravatar.org/avatar/e9a2c03d607ec80a5b725ad42c19ee36",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,14 +17,14 @@ expression: snapshot
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"hash-holllo",
|
"hash-holllo",
|
||||||
"ebff9105dce4954b1bdb57fdab079ff3",
|
"e9a2c03d607ec80a5b725ad42c19ee36",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"hash-holllo-whitespace",
|
"hash-holllo-whitespace",
|
||||||
"ebff9105dce4954b1bdb57fdab079ff3",
|
"e9a2c03d607ec80a5b725ad42c19ee36",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"hash-holllo-casing",
|
"hash-holllo-casing",
|
||||||
"ebff9105dce4954b1bdb57fdab079ff3",
|
"e9a2c03d607ec80a5b725ad42c19ee36",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue