📛 Shields::Badge
RubyGem version of the interactive tool found at shields.io/badges.
If you use this project, or badges from Shields.io, please help increase Shields.io's rate limit by authorizing the Shields.io GitHub application. Read more about how it works.
Federated DVCS Repository | Status | Issues | PRs | Wiki | CI | Discussions |
---|---|---|---|---|---|---|
🧪 galtzo-floss/shields-badge on GitLab | The Truth | 💚 | 💚 | 💚 | 🏀 Tiny Matrix | ➖ |
🧊 galtzo-floss/shields-badge on CodeBerg | An Ethical Mirror (Donate) | ➖ | 💚 | ➖ | ⭕️ No Matrix | ➖ |
🐙 galtzo-floss/shields-badge on GitHub | A Dirty Mirror | 💚 | 💚 | ➖ | 💯 Full Matrix | ➖ |
🎮️ Discord Server | Let’s | talk | about | this | library! |
Upgrading Runtime Gem Dependencies
Great care has been taken to ensure this gem is working with all the
leading versions per each minor version of Ruby of all the runtime dependencies it can install with.
What does that mean specifically for the runtime dependencies?
We are approaching 100% test coverage of lines and branches, and this test suite runs across a large matrix
covering the latest patch for each of the following minor versions:
- MRI Ruby @ v3.1, v3.2, v3.3, v3.4, HEAD
- JRuby @ v9.4, v10.0, HEAD
- TruffleRuby @ v24.1, HEAD
- gem
castkit
@ v0, HEAD ⏩️ bnlucas/castkit - gem
version_gem
@ v1, HEAD ⏩️ oauth-xx/version_gem
You should upgrade this gem with confidence*.
- This gem follows a strict & correct (according to the maintainer of SemVer; more info) interpretation of SemVer.
- Dropping support for any of the runtime dependency versions above will be a major version bump.
- If you aren’t on one of the minor versions above, make getting there a priority.
- You should upgrade the dependencies of this gem with confidence*.
- Please do upgrade, and then, when it goes smooth as butter please sponsor me. Thanks!
* MIT license; I am unable to make guarantees.
🚚 Test matrix brought to you by | 🔎 appraisal++ |
---|---|
Adds back support for old Rubies | ✨ appraisal PR #250 |
Adds support for eval_gemfile
|
✨ appraisal PR #248 |
Please review | my PRs! |
Standard Library Dependencies
The various versions are tested within whatever Ruby includes them, via the Ruby test matrix. * uri If you use a discrete gem version it should also work fine!Quick Usage Example for AI and Copy / Pasting
Do you ever lay awake at night thinking?
- How is the CI looking for
kettle-soup-cover
? - What is the current coverage on
oauth2
gem? - How many commits have there been since last release of
gem_bench
? - What is the download rank (all time) for
anonymous_active_record
? - What is the download rank (today) for
sanitize_email
? - What are the total downloads of
rubocop-lts
? - How many stars does
flag_shih_tzu
have?
Or maybe you want to build a dashboard of badges for all your projects…
For the badges that have been implemented, all options on Shields.io are available.
# Optional: Eager load all badges (otherwise they will load the first time called through method_missing)
Shields::Badge.register_all
# All Path Parameters are supported
Shields::Badge.github_branch_check_runs(user: "kettle-rb", repo: "kettle-soup-cover", branch: "main")
# => "[](https://github.com/kettle-rb/kettle-soup-cover/actions)"
Shields::Badge.coveralls(user: "oauth-xx", repo: "oauth2", vcs_type: "github")
# => "[](https://github.com/oauth-xx/oauth2/actions)"
Shields::Badge.github_commits_since_latest_release(user: "pboling", repo: "gem_bench")
# => "[](https://github.com/pboling/gem_bench/releases)"
Shields::Badge.gem_download_rank(period: "rt", gem: "anonymous_active_record")
# => "[](https://rubygems.org/gems/anonymous_active_record)"
Shields::Badge.gem_download_rank(gem: "sanitize_email", period: "rd")
# => "[](https://rubygems.org/gems/sanitize_email)"
Shields::Badge.gem_total_downloads(gem: "rubocop-lts")
# => "[](https://rubygems.org/gems/rubocop-lts)"
Shields::Badge.github_repo_stars(user: "pboling", repo: "flag_shih_tzu")
# => "[](https:///github.com/pboling/flag_shih_tzu/stargazers)"
# All Query Parameters are supported; check Usage section below.
💡 Info you can shake a stick at
Tokens to Remember |
|
---|---|
Works with JRuby |
|
Works with Truffle Ruby |
|
Works with MRI Ruby 3 |
|
Source |
|
Documentation |
|
Compliance |
|
Style |
|
Support |
|
Enterprise Support |
💡Subscribe for support guarantees covering all FLOSS dependencies! 💡Tidelift is part of Sonar! 💡Tidelift pays maintainers to maintain the software you depend on! 📊 @ Pointy Haired Boss: An enterprise support subscription is “never gonna let you down”, and supports open source maintainers! |
Comrade BDFL 🎖️ |
|
... 💖 |
|
🚀 Release Documentation
Version 1.0.x
1.0.x CHANGELOGs and READMEs
| Version | Release Date | CHANGELOG | README | |---------|--------------|-------------------------------------|-------------------------------| | 1.0.0 | 2025-05-29 | [v1.0.0 CHANGELOG][1.0.0-changelog] | [v1.0.0 README][1.0.0-readme] |✨ Installation
Install the gem and add to the application’s Gemfile by executing:
$ bundle add shields-badge
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install shields-badge
🔒 Secure Installation
shields-badge
is cryptographically signed, and has verifiable SHA-256 and SHA-512 checksums by
stone_checksums. Be sure the gem you install hasn’t been tampered with
by following the instructions below.
Add my public key (if you haven’t already, expires 2045-04-29) as a trusted certificate:
gem cert --add <(curl -Ls https://raw.github.com/galtzo-floss/shields-badge/main/certs/pboling.pem)
You only need to do that once. Then proceed to install with:
gem install shields-badge -P MediumSecurity
The MediumSecurity
trust profile will verify signed gems, but allow the installation of unsigned dependencies.
This is necessary because not all of shields-badge
’s dependencies are signed, so we cannot use HighSecurity
.
If you want to up your security game full-time:
bundle config set --global trust-policy MediumSecurity
NOTE: Be prepared to track down certs for signed gems and add them the same way you added mine.
Shields::Badge for Enterprise
Available as part of the Tidelift Subscription.
The maintainers of this and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.
Security contact information
To report a security vulnerability, please use the Tidelift security contact.
Tidelift will coordinate the fix and disclosure.
For more see SECURITY.md.
Compatibility
Targeted ruby compatibility is non-EOL versions of Ruby, currently 3.2, 3.3, and 3.4.
Compatibility is further distinguished as “Best Effort Support” or “Incidental Support” for older versions of Ruby.
This gem will install on Ruby versions >= v3.1 for 1.x releases.
Ruby Engine Compatibility Policy
This gem is tested against MRI, JRuby, and Truffleruby. Each of those has varying versions that target a specific version of MRI Ruby. This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility of each version, though there are exceptions for certain things.Ruby Version Compatibility Policy
If something doesn't work on one of the supported versions, it's a bug.Ruby Shields::Badge Version | Maintenance Branch | Targeted Support | Best Effort Support | Incidental Support | |
---|---|---|---|---|---|
1️⃣ | 1.0.x | main |
3.2, 3.3, 3.4 | 3.1 | N/A |
NOTE: The 1.4 series will only receive critical security updates.
See SECURITY.md.
🔧 Basic Usage
All parameters are in snake case when passing as Ruby arguments.
Certain parameters are configured to serialize as camel case (lower first) when formatted.
This is all automatic, and you don’t need to worry about it.
You can even supply the parameters in camel case (lower first) if you want.
Setup
Require the library (if this gem is in your Gemfile
bundler will do this for you):
require "shields/badge"
Prefer method_missing or eager load?
The first time they are invoked, the badge generation methods on Shields::Badge
will automatically require the badge tooling they need to generate a badge. If you want to avoid method_missing
, you can eager load all the badges with Shields::Badge.register_all
.
Path Parameters
These are generally required arguments and vary from badge to badge.
See the specs for examples. There is a spec for every badge, and at least one spec that utilizes every available path parameter.
Query Parameters
Most of these are optional arguments, but the odd one is required.
The query parameters that all badges share are:
path_parameters = {gem: "orange"}
query_parameters = {
style: "flat",
logo: "github",
logo_color: "yellow",
logo_size: "auto",
label: "banana",
label_color: "blue",
color: "black",
cache_seconds: "3600",
link: "https://example.com/green/red",
}
# NOTE: You can specify path and query parameters separately, or as top-level arguments.
Shields::Badge.gem_total_downloads(path_parameters:, query_parameters:)
# => "[](https://rubygems.org/gems/orange)
Shields::Badge.gem_total_downloads(**path_parameters, **query_parameters)
# => "[](https://rubygems.org/gems/orange)
All the optional values supported by Shields.io are supported. Some badges have additional query parameters.
For the arguments that are designated as camel case (lower first) on Shields.io, it doesn’t matter if you supply the arguments in camel case (lower first) or snake case, as they will both work.
The above snake case arguments result in the same badge as the below camel case arguments:
path_parameters = {gem: "orange"}
query_parameters = {
style: "flat",
logo: "github",
logoColor: "yellow",
logoSize: "auto",
label: "banana",
labelColor: "blue",
color: "black",
cacheSeconds: "3600",
link: "https://example.com/green/red",
}
Shields::Badge.gem_total_downloads(path_parameters:, query_parameters:)
# => "[](https://rubygems.org/gems/orange)
# And again it doesn't matter if the arguments are top-level or nested inside path and query parameters:
Shields::Badge.gem_total_downloads(**path_parameters, **query_parameters)
# => "[](https://rubygems.org/gems/orange)
See the specs for more examples. There is a spec for every badge, and at least one spec that utilizes every available query parameter.
Formatters
Shields.io has 5 output formats. Of those, 2 have been implemented here, and PRs are welcome for the remainder.
URL | Markdown | rSt | AsciiDoc | HTML | |
---|---|---|---|---|---|
Implemented | 💚 | 💚 | ⏳️ | ⏳️ | ⏳️ |
Module | ...::ImageSrcUrl |
...::Markdown |
⏳️ | ⏳️ | ⏳️ |
Source | image_src_url.rb | markdown.rb | ⏳️ | ⏳️ | ⏳️ |
Legend
-
...
=>Shields::Formatters
-
⏳️
=> Please submit a Pull Request to implement this formatter
Check the sources of the two that are done. They are very easy to write. This is a great project to get started with open source, because it is well tested, and patterned after the Shields.io website.
🔐 Security
See SECURITY.md.
🤝 Contributing
If you need some ideas of where to help, you could work on adding more code coverage,
or if it is already 💯 (see below) check issues, or PRs,
or use the gem and think about how it could be better.
We so if you make changes, remember to update it.
See CONTRIBUTING.md for more detailed instructions.
🚀 Release Instructions
See CONTRIBUTING.md.
Code Coverage
🪇 Code of Conduct
Everyone interacting in this project’s codebases, issue trackers,
chat rooms and mailing lists is expected to follow the .
🌈 Contributors
Made with contributors-img.
Also see GitLab Contributors: https://gitlab.com/galtzo-floss/shields-badge/-/graphs/main
⭐️ Star History
</a>
📌 Versioning
This Library adheres to .
Violations of this scheme should be reported as bugs.
Specifically, if a minor or patch version is released that breaks backward compatibility,
a new version should be immediately released that restores compatibility.
Breaking changes to the public API will only be introduced with new major versions.
📌 Is “Platform Support” part of the public API?
Yes. But I’m obligated to include notes…
SemVer should, but doesn’t explicitly, say that dropping support for specific Platforms
is a breaking change to an API.
It is obvious to many, but not all, and since the spec is silent, the bike shedding is endless.
dropping support for a platform is both obviously and objectively a breaking change
- Jordan Harband (@ljharb, maintainer of SemVer) in SemVer issue 716
To get a better understanding of how SemVer is intended to work over a project’s lifetime,
read this article from the creator of SemVer:
As a result of this policy, and the interpretive lens used by the maintainer,
you can (and should) specify a dependency on these libraries using
the Pessimistic Version Constraint with two digits of precision.
For example:
spec.add_dependency("shields-badge", "~> 1.0")
See CHANGELOG.md for list of releases.
📄 License
The gem is available as open source under the terms of
the MIT License .
See LICENSE.txt for the official Copyright Notice.
© Copyright
-
2025 Peter H. Boling, of
Galtzo.com
🤑 One more thing
You made it to the bottom of the page,
so perhaps you’ll indulge me for another 20 seconds.
I maintain many dozens of gems, including this one,
because I want Ruby to be a great place for people to solve problems, big and small.
Please consider supporting my efforts via the giant yellow link below,
or one of the others at the head of this README.