Module: Sevgi

Extended by:
Toplevel
Defined in:
lib/sevgi.rb,
lib/sevgi/svg.rb,
lib/sevgi/skill.rb,
lib/sevgi/version.rb,
lib/sevgi/executor.rb,
lib/sevgi/toplevel.rb,
lib/sevgi/binaries/igsev.rb,
lib/sevgi/binaries/sevgi.rb,
lib/sevgi/executor/error.rb,
lib/sevgi/executor/scope.rb,
lib/sevgi/executor/result.rb,
lib/sevgi/executor/source.rb,
lib/sevgi/toplevel/derender.rb,
lib/sevgi/toplevel/executor.rb,
lib/sevgi/toplevel/function.rb,
lib/sevgi/toplevel/geometry.rb,
lib/sevgi/toplevel/graphics.rb,
lib/sevgi/toplevel/sundries.rb

Overview

Full top-level API for Sevgi library and script consumers.

require "sevgi" 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. The same operations are available on Sevgi for consumers that prefer the full toolkit namespace. Process-level operations such as Sevgi.execute remain on Sevgi rather than 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 Sevgi.execute, Sevgi.execute_file, or command-line script execution. It resolves nested .sevgi files through the active executor scope; it is not a general-purpose replacement for Ruby require.

Examples:

Include the DSL in an object

class Drawing
  include Sevgi
end

See Also:

Defined Under Namespace

Modules: SVG, Toplevel Classes: Executor

Constant Summary collapse

VERSION =

Current version of the Sevgi top-level gem.

"0.98.2"

Class Method Summary collapse

Methods included from Toplevel

Canvas, Decompile, DecompileFile, Derender, DerenderFile, Document, Document!, Evaluate, EvaluateChildren, EvaluateChildrenFile, EvaluateFile, Grid, Load, Mixin, Paper, Paper!, SVG

Class Method Details

.Canvas(...) ⇒ Sevgi::Graphics::Canvas

Builds a canvas from a paper profile or explicit dimensions.

Returns:

  • (Sevgi::Graphics::Canvas)

    canvas value

See Also:



# File 'lib/sevgi.rb', line 59

.Decompile(...) ⇒ Sevgi::Derender::Node

Converts inline SVG/XML into an immutable Derender node.

Returns:

  • (Sevgi::Derender::Node)

    selected node

See Also:



# File 'lib/sevgi.rb', line 59

.DecompileFile(...) ⇒ Sevgi::Derender::Node

Converts an SVG/XML file into an immutable Derender node.

Returns:

  • (Sevgi::Derender::Node)

    selected node

See Also:



# File 'lib/sevgi.rb', line 59

.Derender(...) ⇒ String

Converts inline SVG/XML into formatted Sevgi DSL source.

Returns:

  • (String)

    formatted Sevgi DSL source

See Also:



# File 'lib/sevgi.rb', line 59

.DerenderFile(...) ⇒ String

Converts an SVG/XML file into formatted Sevgi DSL source.

Returns:

  • (String)

    formatted Sevgi DSL source

See Also:



# File 'lib/sevgi.rb', line 59

.Document(...) ⇒ Class

Defines, validates, or looks up a document profile.

Returns:

  • (Class)

    document class

See Also:



# File 'lib/sevgi.rb', line 59

.Document!(...) ⇒ Class

Defines or replaces a document profile.

Returns:

  • (Class)

    document class

See Also:



# File 'lib/sevgi.rb', line 59

.Evaluate(...) ⇒ Sevgi::Graphics::Element?

Includes an inline SVG/XML node under a graphics element.

Returns:

  • (Sevgi::Graphics::Element, nil)

    included element, or nil when no output is produced

See Also:



# File 'lib/sevgi.rb', line 59

.EvaluateChildren(...) ⇒ Array<Sevgi::Graphics::Element>

Includes only an inline SVG/XML node's children under a graphics element.

Returns:

  • (Array<Sevgi::Graphics::Element>)

    immutable included-child snapshot

See Also:



# File 'lib/sevgi.rb', line 59

.EvaluateChildrenFile(...) ⇒ Array<Sevgi::Graphics::Element>

Includes only an SVG/XML file node's children under a graphics element.

Returns:

  • (Array<Sevgi::Graphics::Element>)

    immutable included-child snapshot

See Also:



# File 'lib/sevgi.rb', line 59

.EvaluateFile(...) ⇒ Sevgi::Graphics::Element?

Includes an SVG/XML file node under a graphics element.

Returns:

  • (Sevgi::Graphics::Element, nil)

    included element, or nil when no output is produced

See Also:



# File 'lib/sevgi.rb', line 59

.execute(string, file: nil, line: nil, require: nil, main: false) ⇒ Sevgi::Executor::Result

Note:

Script and required-library failures are captured in Sevgi::Executor::Result#error.

Note:

The default isolated mode does not modify Ruby's top-level main object. main: true preserves the command-line default by installing Sevgi through main before evaluating source in the managed script scope.

Note:

Empty source without require: is a strict no-op; the DSL boot block is unused.

Note:

Reentrant and concurrent calls keep independent executor scope stacks per fiber.

Executes Sevgi script source with the full top-level DSL installed.

Examples:

Execute source in an isolated scope

result = Sevgi.execute("F.pluralize('cat')")
result.value # => "cats"

Parameters:

  • string (String)

    source to evaluate

  • file (String, nil) (defaults to: nil)

    source file name used for errors and backtraces

  • line (Integer, nil) (defaults to: nil)

    starting source line used for errors and backtraces

  • require (String, nil) (defaults to: nil)

    optional Ruby library to require before execution

  • main (Boolean) (defaults to: false)

    whether to install the DSL through Ruby's top-level main object

Returns:

Raises:

  • (Sevgi::ArgumentError)

    when source, file, line, required library, or main mode is invalid

See Also:



28
29
30
# File 'lib/sevgi/toplevel/executor.rb', line 28

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) ⇒ Sevgi::Executor::Result

Note:

File-read, script, and required-library failures are captured in Sevgi::Executor::Result#error.

Note:

The default isolated mode does not modify Ruby's top-level main object. main: true preserves the command-line default by installing Sevgi through main before evaluating source in the managed script scope.

Note:

An empty file without require: is a strict no-op; the DSL boot block is unused.

Note:

Reentrant and concurrent calls keep independent executor scope stacks per fiber.

Executes a Sevgi script file with the full top-level DSL installed.

Parameters:

  • file (String)

    source file to read and execute

  • as (String, nil) (defaults to: nil)

    source basename used for evaluation, diagnostics, and caller-derived output defaults; its extension is replaced with .sevgi and the input file's directory is retained

  • require (String, nil) (defaults to: nil)

    optional Ruby library to require before execution

  • main (Boolean) (defaults to: false)

    whether to install the DSL through Ruby's top-level main object

Returns:

Raises:

  • (Sevgi::ArgumentError)

    when file, logical source name, required library, or main mode is invalid

See Also:



46
47
48
49
# File 'lib/sevgi/toplevel/executor.rb', line 46

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(...) ⇒ Sevgi::Sundries::Grid

Fits a drawable grid to a graphics canvas.

Returns:

  • (Sevgi::Sundries::Grid)

    fitted grid

See Also:



# File 'lib/sevgi.rb', line 59

.Load(...) ⇒ Array<String>

Loads nested .sevgi files through the active executor scope.

Returns:

  • (Array<String>)

    requested file names

See Also:



# File 'lib/sevgi.rb', line 59

.Mixin(...) ⇒ Module?

Extends a document profile with a named or anonymous graphics mixture.

Returns:

  • (Module, nil)

    anonymous mixture when supplied, otherwise nil

See Also:



# File 'lib/sevgi.rb', line 59

.Paper(...) ⇒ Symbol, String

Defines or validates a named paper profile.

Returns:

  • (Symbol, String)

    original paper profile name

See Also:



# File 'lib/sevgi.rb', line 59

.Paper!(...) ⇒ Symbol, String

Defines or overwrites a named paper profile.

Returns:

  • (Symbol, String)

    original paper profile name

See Also:



# File 'lib/sevgi.rb', line 59

.SVG(...) ⇒ Sevgi::Graphics::Document::Proto

Builds an SVG document through the explicit namespaced top-level API.

Returns:

  • (Sevgi::Graphics::Document::Proto)

    SVG document object

See Also:



# File 'lib/sevgi.rb', line 59