Module: Sumi
- Extended by:
- Toplevel
- Defined in:
- graphics/lib/sumi/graphics/attribute.rb,
function/lib/sumi/core.rb,
function/lib/sumi/function.rb,
function/lib/sumi/function/ui.rb,
function/lib/sumi/function/file.rb,
function/lib/sumi/function/math.rb,
function/lib/sumi/function/color.rb,
function/lib/sumi/function/shell.rb,
function/lib/sumi/function/locate.rb,
function/lib/sumi/function/string.rb,
function/lib/sumi/function/version.rb,
geometry/lib/sumi/geometry.rb,
geometry/lib/sumi/geometry/point.rb,
geometry/lib/sumi/geometry/errors.rb,
geometry/lib/sumi/geometry/element.rb,
geometry/lib/sumi/geometry/segment.rb,
geometry/lib/sumi/geometry/version.rb,
geometry/lib/sumi/geometry/equation.rb,
geometry/lib/sumi/geometry/internal.rb,
geometry/lib/sumi/geometry/operation.rb,
geometry/lib/sumi/geometry/predicate.rb,
geometry/lib/sumi/geometry/elements/arc.rb,
geometry/lib/sumi/geometry/element/arced.rb,
geometry/lib/sumi/geometry/element/lined.rb,
geometry/lib/sumi/geometry/elements/line.rb,
geometry/lib/sumi/geometry/elements/rect.rb,
geometry/lib/sumi/geometry/operation/box.rb,
geometry/lib/sumi/geometry/elements/circle.rb,
geometry/lib/sumi/geometry/equation/linear.rb,
geometry/lib/sumi/geometry/operation/align.rb,
geometry/lib/sumi/geometry/operation/sweep.rb,
geometry/lib/sumi/geometry/elements/ellipse.rb,
geometry/lib/sumi/geometry/elements/polygon.rb,
geometry/lib/sumi/geometry/elements/polyline.rb,
geometry/lib/sumi/geometry/elements/triangle.rb,
geometry/lib/sumi/geometry/equation/quadratic.rb,
geometry/lib/sumi/geometry/elements/parallelogram.rb,
geometry/lib/sumi/geometry/elements/ellipse/affine.rb,
geometry/lib/sumi/geometry/elements/ellipse/length.rb,
graphics/lib/sumi/graphics.rb,
graphics/lib/sumi/graphics/element.rb,
graphics/lib/sumi/graphics/version.rb,
graphics/lib/sumi/graphics/document.rb,
graphics/lib/sumi/graphics/mixtures.rb,
graphics/lib/sumi/graphics/mixtures/rdf.rb,
graphics/lib/sumi/graphics/auxiliary/xml.rb,
graphics/lib/sumi/graphics/document/base.rb,
graphics/lib/sumi/graphics/document/html.rb,
graphics/lib/sumi/graphics/mixtures/call.rb,
graphics/lib/sumi/graphics/mixtures/core.rb,
graphics/lib/sumi/graphics/mixtures/lint.rb,
graphics/lib/sumi/graphics/mixtures/save.rb,
graphics/lib/sumi/graphics/mixtures/tile.rb,
graphics/lib/sumi/graphics/mixtures/hatch.rb,
graphics/lib/sumi/graphics/auxiliary/paper.rb,
graphics/lib/sumi/graphics/mixtures/export.rb,
graphics/lib/sumi/graphics/mixtures/render.rb,
graphics/lib/sumi/graphics/auxiliary/canvas.rb,
graphics/lib/sumi/graphics/auxiliary/margin.rb,
graphics/lib/sumi/graphics/auxiliary/scalar.rb,
graphics/lib/sumi/graphics/document/default.rb,
graphics/lib/sumi/graphics/document/minimal.rb,
graphics/lib/sumi/graphics/mixtures/imprint.rb,
graphics/lib/sumi/graphics/mixtures/include.rb,
graphics/lib/sumi/graphics/mixtures/symbols.rb,
graphics/lib/sumi/graphics/auxiliary/content.rb,
graphics/lib/sumi/graphics/document/inkscape.rb,
graphics/lib/sumi/graphics/mixtures/identify.rb,
graphics/lib/sumi/graphics/mixtures/inkscape.rb,
graphics/lib/sumi/graphics/mixtures/validate.rb,
graphics/lib/sumi/graphics/mixtures/wrappers.rb,
graphics/lib/sumi/graphics/auxiliary/snapshot.rb,
graphics/lib/sumi/graphics/mixtures/duplicate.rb,
graphics/lib/sumi/graphics/mixtures/polyfills.rb,
graphics/lib/sumi/graphics/mixtures/transform.rb,
graphics/lib/sumi/graphics/mixtures/underscore.rb,
standard/lib/sumi/standard.rb,
standard/lib/sumi/standard/data.rb,
standard/lib/sumi/standard/model.rb,
standard/lib/sumi/standard/errors.rb,
standard/lib/sumi/standard/conform.rb,
standard/lib/sumi/standard/version.rb,
standard/lib/sumi/standard/internal.rb,
standard/lib/sumi/standard/data/color.rb,
standard/lib/sumi/standard/data/element.rb,
standard/lib/sumi/standard/data/attribute.rb,
standard/lib/sumi/standard/data/specification.rb,
derender/lib/sumi/derender.rb,
derender/lib/sumi/binaries/imus.rb,
derender/lib/sumi/derender/node.rb,
derender/lib/sumi/derender/version.rb,
derender/lib/sumi/derender/document.rb,
derender/lib/sumi/derender/elements.rb,
derender/lib/sumi/derender/internal.rb,
derender/lib/sumi/derender/evaluator.rb,
derender/lib/sumi/derender/attributes.rb,
derender/lib/sumi/derender/elements/any.rb,
derender/lib/sumi/derender/elements/root.rb,
derender/lib/sumi/derender/elements/text.rb,
derender/lib/sumi/derender/elements/style.rb,
derender/lib/sumi/derender/elements/comment.rb,
derender/lib/sumi/derender/elements/instruction.rb,
sundries/lib/sumi/sundries.rb,
sundries/lib/sumi/sundries/grid.rb,
sundries/lib/sumi/sundries/tile.rb,
sundries/lib/sumi/sundries/ruler.rb,
sundries/lib/sumi/sundries/export.rb,
sundries/lib/sumi/sundries/imprint.rb,
sundries/lib/sumi/sundries/version.rb,
sundries/lib/sumi/sundries/export/input.rb,
sundries/lib/sumi/sundries/export/system.rb,
sundries/lib/sumi/sundries/export/staging.rb,
sundries/lib/sumi/sundries/export/metadata.rb,
sundries/lib/sumi/sundries/export/native/stamp.rb,
sundries/lib/sumi/sundries/export/native/render.rb,
sundries/lib/sumi/sundries/export/metadata/fields.rb,
sundries/lib/sumi/sundries/export/metadata/packet.rb,
sundries/lib/sumi/sundries/export/native/stamp/scanner.rb,
appendix/lib/sumi/appendix.rb,
appendix/lib/sumi/appendix/version.rb,
toplevel/lib/sumi.rb,
toplevel/lib/sumi/svg.rb,
toplevel/lib/sumi/skill.rb,
toplevel/lib/sumi/version.rb,
toplevel/lib/sumi/executor.rb,
toplevel/lib/sumi/toplevel.rb,
toplevel/lib/sumi/binaries/sumi.rb,
toplevel/lib/sumi/executor/error.rb,
toplevel/lib/sumi/executor/scope.rb,
toplevel/lib/sumi/executor/result.rb,
toplevel/lib/sumi/executor/source.rb,
toplevel/lib/sumi/toplevel/derender.rb,
toplevel/lib/sumi/toplevel/executor.rb,
toplevel/lib/sumi/toplevel/function.rb,
toplevel/lib/sumi/toplevel/geometry.rb,
toplevel/lib/sumi/toplevel/graphics.rb,
toplevel/lib/sumi/toplevel/sundries.rb,
showcase/lib/sumi/showcase/dark.rb,
showcase/lib/sumi/showcase/passive.rb,
showcase/lib/sumi/showcase/version.rb,
showcase/lib/sumi/showcase/minitest.rb,
showcase/lib/sumi/showcase/minitest/suite.rb,
showcase/lib/sumi/showcase/minitest/script.rb
Overview
Full top-level API for Sumi library and script consumers.
require "sumi" installs the global document builder SVG(...) and the independent SVG facade. SVG-domain
operations use capitalized method names on that facade, such as SVG.Canvas, SVG.Paper, and SVG.Derender. Types
and namespaces use Ruby's double-colon notation, such as SVG::Canvas. Promoted toolkit operations are also
available on Sumi for consumers that prefer the full namespace. SVG.Module is a facade-only convenience
constructor. Process-level operations such as Sumi.execute remain on Sumi, not the SVG facade.
Including this module in a class or module installs the DSL methods plus convenience constants F, Geometry,
Origin, and Export. Script execution provides the same promoted scope. Extending a module does the same. Extending
an ordinary object installs methods only and does not write promoted constants to Object. Focused component requires
expose their namespaced component APIs instead of this full top-level surface.
Load is meaningful only during Sumi.execute, Sumi.execute_file, or command-line script execution. It resolves
nested .sumi files through the active executor scope. It is not a general-purpose replacement for Ruby require.
Defined Under Namespace
Modules: Appendix, Derender, Function, Geometry, Graphics, SVG, Showcase, Standard, Sundries, Toplevel Classes: Error, Executor, MissingComponentError, ValidationError
Constant Summary collapse
- ENVVOMIT =
Environment variable that asks command-line tools to re-raise captured errors.
"SUMI_VOMIT"- EXTENSION =
Default file extension for Sumi scripts.
"sumi"- PanicError =
Error raised for broken internal invariants and unreachable implementation paths.
Class.new(Error)
- ArgumentError =
Error raised for invalid public API usage.
Class.new(Error)
- Undefined =
Sentinel object used to distinguish an omitted value from nil.
Object .new .tap do |undefined| # Returns the sentinel name. # @return [String] def undefined.to_s = "Undefined" # Returns the sentinel inspection string. # @return [String] def undefined.inspect = "Undefined" # Resolves a value unless it is {Sumi::Undefined}. # @param x [Object] candidate value # @param y [Object] fallback value # @yield computes the fallback when both x and y are undefined # @yieldreturn [Object] # @return [Object] x, y, or the yielded fallback def undefined.default(x, y = self) return x unless equal?(x) equal?(y) ? yield : y end # Maps a value unless it is {Sumi::Undefined}. # @param value [Object] candidate value # @yield maps a defined value # @yieldparam value [Object] the defined value # @yieldreturn [Object] # @return [Object] the sentinel or the mapped value def undefined.map(value) = equal?(value) ? self : yield(value) # Returns the sentinel itself. # @return [Sumi::Undefined] def undefined.dup = self # Returns the sentinel itself. # @return [Sumi::Undefined] def undefined.clone(**) = self # Returns the first argument that is not {Sumi::Undefined}. # @param args [Array<Object>] candidate values # @return [Object, nil] first defined value, including nil, or nil when none exists # @example Resolve an optional value # Sumi::Undefined.coalesce(Sumi::Undefined, nil) # => nil # @see #default def undefined.coalesce(*args) = args.find { |x| !equal?(x) } end .freeze
- F =
Supported helper facade for Sumi extensions and advanced consumers.
Function- InvalidAttributesError =
Raised when an element contains invalid attributes.
ValidationError.variant("Invalid attribute(s)")
- InvalidElementsError =
Raised when an element contains invalid child elements.
ValidationError.variant("Invalid element(s)")
- UnallowedCDataError =
Raised when character data appears where the SVG model forbids it.
ValidationError.variant("Character data not allowed")
- UnallowedElementsError =
Raised when an element contains disallowed child elements.
ValidationError.variant("Element(s) not allowed")
- UnmetConditionError =
Raised when a conditional SVG content model requirement is not met.
ValidationError.variant("Condition unmet for the element")
- VERSION =
Current version of the Sumi top-level gem.
"1.0.0"
Class Method Summary collapse
-
.Canvas(...) ⇒ Sumi::Graphics::Canvas
Builds a canvas from a paper profile or explicit dimensions.
-
.Decompile(...) ⇒ Sumi::Derender::Node
Converts inline SVG/XML into an immutable Derender node.
-
.DecompileFile(...) ⇒ Sumi::Derender::Node
Converts an SVG/XML file into an immutable Derender node.
-
.Derender(...) ⇒ String
Converts inline SVG/XML into formatted Sumi DSL source.
-
.DerenderFile(...) ⇒ String
Converts an SVG/XML file into formatted Sumi DSL source.
-
.Document(...) ⇒ Class
Defines, validates, or looks up a document profile.
-
.Document!(...) ⇒ Class
Defines or replaces a document profile.
-
.Evaluate(...) ⇒ Sumi::Graphics::Element?
Includes an inline SVG/XML node under a graphics element.
-
.EvaluateChildren(...) ⇒ Array<Sumi::Graphics::Element>
Includes only an inline SVG/XML node's children under a graphics element.
-
.EvaluateChildrenFile(...) ⇒ Array<Sumi::Graphics::Element>
Includes only an SVG/XML file node's children under a graphics element.
-
.EvaluateFile(...) ⇒ Sumi::Graphics::Element?
Includes an SVG/XML file node under a graphics element.
-
.execute(string, file: nil, line: nil, require: nil, main: false) ⇒ Sumi::Executor::Result
Executes Sumi script source with the full top-level DSL installed.
-
.execute_file(file, as: nil, require: nil, main: false) ⇒ Sumi::Executor::Result
Executes a Sumi script file with the full top-level DSL installed.
-
.Grid(...) ⇒ Sumi::Sundries::Grid
Fits a drawable grid to a graphics canvas.
-
.Load(...) ⇒ Array<String>
Loads nested
.sumifiles through the active executor scope. -
.Mixin(...) ⇒ Module?
Extends a document profile with a named or anonymous graphics mixture.
-
.Paper(...) ⇒ Symbol, String
Defines or validates a named paper profile.
-
.Paper!(...) ⇒ Symbol, String
Defines or overwrites a named paper profile.
-
.Ruler(...) ⇒ Sumi::Sundries::Ruler
Fits major and minor intervals into a span.
-
.SVG(...) ⇒ Sumi::Graphics::Document::Proto
Builds an SVG document through the explicit namespaced top-level API.
Methods included from Toplevel
Canvas, Decompile, DecompileFile, Derender, DerenderFile, Document, Document!, Evaluate, EvaluateChildren, EvaluateChildrenFile, EvaluateFile, Grid, Load, Mixin, Paper, Paper!, Ruler, SVG
Class Method Details
.Canvas(...) ⇒ Sumi::Graphics::Canvas
Builds a canvas from a paper profile or explicit dimensions.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Decompile(...) ⇒ Sumi::Derender::Node
Converts inline SVG/XML into an immutable Derender node.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.DecompileFile(...) ⇒ Sumi::Derender::Node
Converts an SVG/XML file into an immutable Derender node.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Derender(...) ⇒ String
Converts inline SVG/XML into formatted Sumi DSL source.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.DerenderFile(...) ⇒ String
Converts an SVG/XML file into formatted Sumi DSL source.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Document(...) ⇒ Class
Defines, validates, or looks up a document profile.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Document!(...) ⇒ Class
Defines or replaces a document profile.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Evaluate(...) ⇒ Sumi::Graphics::Element?
Includes an inline SVG/XML node under a graphics element.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.EvaluateChildren(...) ⇒ Array<Sumi::Graphics::Element>
Includes only an inline SVG/XML node's children under a graphics element.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.EvaluateChildrenFile(...) ⇒ Array<Sumi::Graphics::Element>
Includes only an SVG/XML file node's children under a graphics element.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.EvaluateFile(...) ⇒ Sumi::Graphics::Element?
Includes an SVG/XML file node under a graphics element.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.execute(string, file: nil, line: nil, require: nil, main: false) ⇒ Sumi::Executor::Result
Script and required-library failures are captured in Sumi::Executor::Result#error.
The default isolated mode does not modify Ruby's top-level main object. main: true preserves the command-line
default by installing Sumi through main before evaluating source in the managed script scope.
Empty source without require: is a strict no-op. The DSL boot block is unused.
Reentrant and concurrent calls keep independent executor scope stacks per fiber. The host retains its signal handlers. An Interrupt is captured only if it reaches this execution, not redirected from the main thread.
Executes Sumi script source with the full top-level DSL installed.
34 35 36 |
# File 'toplevel/lib/sumi/toplevel/executor.rb', line 34 def self.execute(string, file: nil, line: nil, require: nil, main: false) Executor.__send__(:execute, string, file:, line:, require:, receiver: execution_receiver(main), &BootBlock) end |
.execute_file(file, as: nil, require: nil, main: false) ⇒ Sumi::Executor::Result
File-read, script, and required-library failures are captured in Sumi::Executor::Result#error.
The default isolated mode does not modify Ruby's top-level main object. main: true preserves the command-line
default by installing Sumi through main before evaluating source in the managed script scope.
An empty file without require: is a strict no-op. The DSL boot block is unused.
Reentrant and concurrent calls keep independent executor scope stacks per fiber. The host retains its signal handlers. An Interrupt is captured only if it reaches this execution, not redirected from the main thread.
Executes a Sumi script file with the full top-level DSL installed.
53 54 55 56 |
# File 'toplevel/lib/sumi/toplevel/executor.rb', line 53 def self.execute_file(file, as: nil, require: nil, main: false) as = source_name(file, as) if as Executor.__send__(:execute_file, file, as:, require:, receiver: execution_receiver(main), &BootBlock) end |
.Grid(...) ⇒ Sumi::Sundries::Grid
Fits a drawable grid to a graphics canvas.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Load(...) ⇒ Array<String>
Loads nested .sumi files through the active executor scope.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Mixin(...) ⇒ Module?
Extends a document profile with a named or anonymous graphics mixture.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Paper(...) ⇒ Symbol, String
Defines or validates a named paper profile.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Paper!(...) ⇒ Symbol, String
Defines or overwrites a named paper profile.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.Ruler(...) ⇒ Sumi::Sundries::Ruler
Fits major and minor intervals into a span.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|
.SVG(...) ⇒ Sumi::Graphics::Document::Proto
Builds an SVG document through the explicit namespaced top-level API.
|
|
# File 'toplevel/lib/sumi.rb', line 59
|