Title: | Create Custom Pipeline Badges |
---|---|
Description: | You can use this package to create custom pipeline badges in a standard 'svg' format. This is useful for a company to use internally, where it may not be possible to create badges through external providers. This project was inspired by the 'anybadge' library in python. |
Authors: | Lorenzo Meninato |
Maintainer: | Lorenzo Meninato <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-02-07 02:55:43 UTC |
Source: | https://github.com/lmeninato/anybadger |
The Badge class is used to create badges.
The Badge class is used to create badges.
It is likely easier to use the create_badge
to create the badge svg in a single step.
new()
Badge constructor
Used to create badge object.
Badge$new( label, value, color = "#4c1", num_padding_chars = 0.5, thresholds = NULL, font_name = "DejaVu Sans,Verdana,Geneva,sans-serif", font_size = 11, label_text_color = "#fff", value_text_color = "#fff", svg_template_path = NULL )
label
left hand side of badge, e.g. "pipeline" in pipeline status badge
value
right hand side of badge, e.g. "passing" in pipeline status badge
color
to view available colors:
config::get("colors", file = anybadger:::get_sys("config.yml"))
alternatively you can also pass in the hex of your desired color. For instance,
"#fe7d37" or "orange", either is accepted.
num_padding_chars
NULL, can be passed in, but calculated automatically based on text length
thresholds
TODO, thresholds are not implemented yet, coming soon!
font_name
NULL, valid svg font will work, but sizing might be off
font_size
NULL, if passing custom svg font
label_text_color
NULL, set this to change the label text color
value_text_color
NULL, set this to change the value text color
svg_template_path
NULL, to use a different template in svg (not recommended)
NULL
tmp <- tempfile() b <- Badge$new(label = "Pipeline", value = "Passing") b$create_svg(tmp)
create_svg()
Fills in the svg template
Badge$create_svg(path = "default_badge.svg")
path
file path to save badge svg to
invisibly returns the svg text
tmp <- tempfile() b <- Badge$new(label = "Any", value = "Badger") b$create_svg(tmp)
clone()
The objects of this class are cloneable with this method.
Badge$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------ ## Method `Badge$new` ## ------------------------------------------------ tmp <- tempfile() b <- Badge$new(label = "Pipeline", value = "Passing") b$create_svg(tmp) ## ------------------------------------------------ ## Method `Badge$create_svg` ## ------------------------------------------------ tmp <- tempfile() b <- Badge$new(label = "Any", value = "Badger") b$create_svg(tmp)
## ------------------------------------------------ ## Method `Badge$new` ## ------------------------------------------------ tmp <- tempfile() b <- Badge$new(label = "Pipeline", value = "Passing") b$create_svg(tmp) ## ------------------------------------------------ ## Method `Badge$create_svg` ## ------------------------------------------------ tmp <- tempfile() b <- Badge$new(label = "Any", value = "Badger") b$create_svg(tmp)
Create badge svg
create_badge(path, ...)
create_badge(path, ...)
path |
path to save svg to |
... |
parameters to pass to @seealso [Badge] |
svg text
tmp <- tempfile() create_badge(tmp, label = "any", value = "badger", color = "fuchsia")
tmp <- tempfile() create_badge(tmp, label = "any", value = "badger", color = "fuchsia")