test status

Sumi

Sumi is a Ruby toolkit for creating SVG through a compact DSL. It uses SVG element names directly. Drawings stay close to their output while retaining Ruby's composition and reuse.

The full guides, DSL catalog, API reference, and rendered examples are at sumi.alef.tr.

Install

For the complete command-line toolkit, Homebrew is the recommended installation on macOS and Linux:

brew install roktas/tap/toji roktas/tap/sumi

This installs Sumi with Ruby and the sumi and imus commands. It also installs the native PDF and PNG export stack plus the headless pdfcpu and Poppler tools. The packaged agent skill gets a stable location. sumi --skill prints that location for agent setup.

When Sumi is a dependency of a Ruby application, manage it with Bundler in the application's Gemfile instead:

gem "sumie", git: "https://github.com/roktas/sumi.git", tag: "v1.0.0", require: "sumi"

See Sumi Appendix for agent-skill and RuboCop setup, including the difference between Homebrew and versioned gem paths.

Quick start

Build a 120-by-60 SVG document and save it as badge.svg:

require "sumi"

drawing = SVG width: 120, height: 60 do
  rect x: 4, y: 4, width: 112, height: 52, rx: 8, fill: "gold"
  circle cx: 60, cy: 30, r: 16, fill: "tomato"
end

drawing.Save "badge.svg"

Open badge.svg in a browser. The :default profile supplies the SVG namespace and XML declaration. For a data-driven drawing, see Meter. Its runnable source builds a row of LEDs and colors each LED through a callback.

Library operations use capitalized facade methods such as SVG.Canvas. Related Ruby types and namespaces use double-colon names such as SVG::Canvas. Executable .sumi scripts promote those operations as bare DSL words.

Sumi also runs executable .sumi drawing scripts. See Getting Started for installation details and Examples for complete drawings with rendered output. The sumi and imus commands accept a file, -, or standard input when no file is given.

Choose a package

sumie is the umbrella gem. It installs the script runner, the SVG facade, the Appendix development extras, and all runtime component gems. This is the simplest Bundler dependency for applications and drawing scripts:

gem "sumie", git: "https://github.com/roktas/sumi.git", tag: "v1.0.0", require: "sumi"

The source tree also builds separate gems for libraries that need a smaller dependency surface:

Scenario Install Entry point
Build and render SVG only sumi-graphics require "sumi/graphics"
Build and validate SVG without the full toolkit sumi-graphics sumi-standard require "sumi/graphics"
Use geometry values and transformations without the DSL sumi-geometry require "sumi/geometry"
Convert SVG or XML back into Sumi source sumi-derender require "sumi/derender"
Use grids, rulers, tiles, or export integrations sumi-sundries require "sumi/sundries"
Package the agent skill or lint .sumi source sumi-appendix require "sumi/appendix" or the RuboCop plugin

For example, a service that only builds SVG can install sumi-graphics. Its focused API is Sumi::Graphics.SVG(...). The full SVG facade and the sumi executable belong to the umbrella gem. Add sumi-standard to validate element and attribute names. Components install shared support gems such as sumi-function transitively. Native PDF and PNG export gems remain optional with sumi-sundries. The umbrella gem adds sumi --skill to locate the matching Appendix skill.

Requirements

Sumi requires Ruby 3.4 or newer. SVG output has no native graphics dependencies. Gem-based PDF and PNG export uses optional Cairo, librsvg, and HexaPDF integrations documented in Getting Started.

Acknowledgments

Sumi was inspired by Victor. Victor is a smaller alternative for projects that need a narrower API. Some Showcase examples were adapted from Victor's examples with thanks to its author.

License

Sumi is available under the GNU General Public License, version 3 or later.