sevgi 0.95.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47a098e5eabd1f185ef25e4d5797d347db21ccf9bddcb0dea480f921115cc129
4
- data.tar.gz: 1bc7cac24e7ab2771d670edaaf4e4323a454c7a331a2663e812df3d9a1868a82
3
+ metadata.gz: 27a50b6890ad4f1ae6f47470e8b79896ad1281e2bdb54b7cfabd8310cd683c45
4
+ data.tar.gz: 7839ad48af80ceffb800314422b942406cb4bed1b7bb5c13e2774d121d0746ca
5
5
  SHA512:
6
- metadata.gz: 6e9b877a8a87ab2493b64bd3a4e3bba4b718697e47fe860b3c98bc40db29271d9b1700113657e627cdb6e0810efc109f73b8e23ef1eb582d8976f7ab2ec8889f
7
- data.tar.gz: 05d88614f5030aafcf8ce3f8e05f738decf86614ade78eae319c348d9402c4db1d7657a2743cf4f2f84f2b31f21fdf39f7bf9fef6e4078257d90aa24c9b86140
6
+ metadata.gz: 53837c04457e0ea48aa71642ea1c25a6fc352ba737b09dc073f988b4694d9cab561699695e6e2e6e89248a1704ccc659f4009e8aa4396737f7dc5a4b7b2ff5e3
7
+ data.tar.gz: 7f1ffa5979ce5af033451baf13c8746002f719782b633a4af16856d6283f828390eefb92bc2d17fdfbfa387f8e8e2675980dec86b992a483d17db35bdd56552d
data/CHANGELOG.md CHANGED
@@ -3,7 +3,226 @@
3
3
  This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
- ## Unreleased
6
+ ## 1.0.0 - 2026-09-16
7
+
8
+ ### Added
9
+
10
+ - Added Hatch and Orb Showcase examples and displayed both arc lengths in the Arc example.
11
+
12
+ ### Changed
13
+
14
+ - Matched documentation page widths to the homepage Showcase.
15
+ - Aligned Derender user guidance with UTF-8 normalization and safe subtree selection rules.
16
+ - Clarified the packaged skill's script invocation, subtree copying, and Derender selection and encoding rules.
17
+ - Allowed Canvas and Paper values as the first `SVG` argument when using the default document profile.
18
+ - Made element `dup` and `clone` own independent subtrees while retaining IDs and Ruby copy semantics.
19
+ - Made Segment equality compare length and direction; ordering still compares length only.
20
+ - Limited Tile cell, row, and column queries to the requested geometry and accelerated XML character validation.
21
+ - Simplified the first-run guide and aligned library constructor examples.
22
+ - Updated the packaged skill for canvas origins, alignment, Paper lookup, curved geometry, and export constraints.
23
+ - Revised DSL catalog examples and packaged Sevgi skill guidance to use statement-style calls and show inspection results.
24
+ - Refined Showcase example tabs, made Ruby and XML views fill their panels, and hid executable preambles from Ruby views.
25
+ - Documented non-rendering element data and clarified the related DSL catalog examples.
26
+ - Refined Showcase heading spacing, page-title colors, and DSL catalog cards across light and dark themes.
27
+ - Removed an obsolete ruler example and unused site code.
28
+ - Kept the Squared and Copperplate guidesheet examples together at the end of the Showcase.
29
+ - Updated the packaged skill to avoid duplicate semantic shapes and unnecessary paint passes.
30
+
31
+ ### Fixed
32
+
33
+ - Kept horizontal scrollbars visible in Showcase example code panels.
34
+ - Read Derender input in its declared XML encoding and normalized generated source, XML declarations, and markup to UTF-8.
35
+ - Preserved open-path endpoints and derived edges independently of display precision.
36
+ - Kept near-axis and near-parallel line equations and intersections independent of angle and slope rounding.
37
+ - Corrected the Showcase social image dimensions.
38
+ - Added SVG namespaces to standalone drawing examples and regenerated their outputs.
39
+ - Made failed Sevgi Rake tasks stop dependent tasks and captured required-library failures in executor results.
40
+ - Removed executor signal-handler replacement so the host and shell retain SIGINT ownership.
41
+ - Escaped late export CSS as XML text and inserted it only at a supported final root closing tag.
42
+ - Preserved Derender processing instructions and rejected custom entity references and unsupported trailing document nodes before inclusion.
43
+ - Included both box origins in `Align`, unified Tile index validation, and isolated custom numeric attribute snapshots.
44
+ - Prevented avoidable overflow and underflow in point distances.
45
+ - Corrected browser source-panel expectations and added executable documentation, YARD, and packaged-skill checks.
46
+ - Rendered inline code in DSL catalog summaries and kept linked task themes visible below the sticky header.
47
+ - Restored Showcase tab icons with embedded Font Awesome SVGs.
48
+
49
+ ## 0.100.0 - 2026-09-09
50
+
51
+ ### Added
52
+
53
+ - Added `ArcTo` and `ArcBy` for SVG-native elliptical arc paths.
54
+ - Added Geometry `Arc`, `Ellipse`, and `Circle` with bounds, length, predicates, affine transformations, and
55
+ linear/quadratic intersections. Closed ellipses and circles support sweeps and hatching.
56
+ - Added Geometry `Point.midpoint`, `Element#closed?`, lined `vertices`, open-path traversal, and `Rect#center`.
57
+ - Added Geometry aggregate bounding boxes through `Operation.box`, point collinearity through `Point.collinear?`, and
58
+ polygon `simple?`, `convex?`, and `concave?` predicates.
59
+ - Added Protractor and Arc examples and documented the drawing and calculation APIs.
60
+
61
+ ### Changed
62
+
63
+ - Removed redundant parent scans while duplicating element subtrees.
64
+ - Reused source bounds across Tile cells to reduce repeated calculations and object allocations.
65
+
66
+ ### Fixed
67
+
68
+ - Preserved Showcase card HTML through Markdown rendering so all examples and their tabs remain visible.
69
+ - Preserved XML declarations, pre-root comments, CDATA sections, inline comments, and namespace-only leaves in
70
+ Derender output and evaluation.
71
+ - Limited PDF stamp recoloring to replaced text and carried graphics state across a page's content streams.
72
+ - Corrected decimal interval fitting and made Grid point queries honor the active numeric precision.
73
+ - Prevented implicit shell interpretation of single executable arguments in `F.sh` and `F.sh!`, including paths with spaces or shell metacharacters.
74
+ - Preserved inherited namespaces on detached Derender nodes in generated source and direct evaluation, including imports through `EvaluateChildren` and `IncludeChildren`.
75
+ - Prevented sweep and Hatch lines from crossing the exterior between two tangent vertices of a concave polygon.
76
+ - Aligned Tile cells with their declared bounds for circles, rotated shapes, and polygons whose first vertex differs from their bounding-box origin.
77
+ - Limited `Load` chains to 128 active sources with `Executor::LoadDepthError`, preserving cycle detection and nested load diagnostics.
78
+ - Rejected nil and false aggregate-box inputs with the documented geometry error.
79
+ - Restored precision-aware rejection of zero-length Triangle sides.
80
+ - Made point-set collinearity independent of input order and removed eager polygon edge-pair storage.
81
+ - Applied the collinearity tolerance to every three-point subset, removing coordinate-axis-dependent baseline selection.
82
+
83
+ ## 0.99.0 - 2026-08-09
84
+
85
+ ### Added
86
+
87
+ - Added `SVG.Module` for building anonymous callable drawing modules with their contract installed before definition.
88
+ - Added responsive Mermaid diagrams for the Derender round trip and SVG validation lifecycle.
89
+
90
+ ### Changed
91
+
92
+ - Reorganized the documentation around getting started, usage, composition, documents, layout, output, and examples.
93
+ - Documented how the `igves` and `igsev` command names reflect their conversion directions.
94
+ - Normalized DSL catalog provider labels to lowercase and simplified polyfill-backed editor entries to `inkscape`.
95
+
96
+ ### Fixed
97
+
98
+ - Allowed A5-on-A4 pdfcpu conversion to replace an existing output file.
99
+ - Pre-rendered Mermaid diagrams as inline SVG instead of parsing them in site visitors' browsers.
100
+ - Removed duplicate provider and context labels from DSL catalog entries.
101
+
102
+ ## 0.98.2 - 2026-07-25
103
+
104
+ ### Fixed
105
+
106
+ - Restored the `sevgi` CLI's main-object scope so bare toolkit calls remain available inside script helper classes.
107
+
108
+ ## 0.98.1 - 2026-07-20
109
+
110
+ ### Changed
111
+
112
+ - Changed the `sevgi` CLI to use the executor's isolated scope by default.
113
+
114
+ ### Removed
115
+
116
+ - Removed the redundant `-n` and `--nomain` CLI options; library consumers can still select `main: true` through
117
+ `Sevgi.execute` and `Sevgi.execute_file` when needed.
118
+
119
+ ## 0.98.0 - 2026-07-20
120
+
121
+ ### Added
122
+
123
+ - Added standard-input support to `sevgi`, `igves`, and `igsev`; `sevgi --as NAME` and
124
+ `Sevgi.execute_file(..., as: NAME)` supply the logical source basename used by implicit SVG, PDF, and PNG
125
+ destinations without changing physical load identity.
126
+
127
+ ## 0.97.0 - 2026-07-19
128
+
129
+ ### Added
130
+
131
+ - Added `sevgi-appendix`, containing the Sevgi agent skill and a RuboCop plugin for preserving readable `.sevgi` DSL
132
+ source alongside rubyfmt-formatted Ruby; the umbrella `sevgi` gem installs the matching Appendix version.
133
+ - Added `sevgi --skill` to report the validated path of the matching packaged agent skill for product-neutral setup.
134
+ - Added `igsev` to the umbrella gem for normalizing an SVG file through a complete SVG-to-Sevgi-to-SVG round trip.
135
+
136
+ ### Changed
137
+
138
+ - Made Homebrew the recommended complete CLI installation while retaining Bundler and focused component gems for Ruby
139
+ application dependencies.
140
+
141
+ ## 0.96.0 - 2026-07-18
142
+
143
+ ### Added
144
+
145
+ - Added exact, subtree-wide attribute omission to Derender content/file conversion, evaluation, and inclusion APIs;
146
+ `igves --omit` exposes the same behavior from the command line.
147
+ - Added `Sevgi.SVG` as the explicit namespaced form of the top-level SVG document entrypoint.
148
+ - Added the opt-in recursive `SVG::Modules` contract for callable drawing namespaces.
149
+ - Added callable drawing-module `base` blocks, document and paper registry introspection, Canvas structural equality,
150
+ renderer options on `RenderChildren`, axis translation helpers, and a CC BY RDF helper.
151
+ - Formalized non-rendering `-` metadata and `+` attribute updates as `Attributes::META_PREFIX` and
152
+ `Attributes::UPDATE_SUFFIX`; repeated Array updates now concatenate into a stable flat value.
153
+
154
+ ### Changed
155
+
156
+ - Breaking: replaced the `SVG = Sevgi::Graphics` alias with an independent SVG facade. Facade operations now use
157
+ capitalized names such as `SVG.Canvas` and `SVG.Document`; lowercase component helpers remain on
158
+ `Sevgi::Graphics`, and the stuttering `SVG.SVG` form was removed.
159
+ - Breaking: made low-level `Executor.execute` and `execute_file` runners private; consumers use
160
+ `Sevgi.execute` and `Sevgi.execute_file` while retaining the public result and error types.
161
+ - Breaking: removed the abstract `Document::Base` layer from the selectable document-profile registry; `Minimal` and
162
+ `Default` are now sibling concrete profiles, and custom profile hierarchies should derive from `Base`.
163
+ - Breaking: renamed Parallelogram segment and constraint arguments by geometric role: `base`, `side`, and
164
+ `constraint` replace axis-implying constructor names.
165
+ - Made degree-based sine and cosine exact at integer quarter turns, eliminating cardinal Geometry residue.
166
+ - Documented complete file-system failure families for file comparison, output, touch, and upward location helpers.
167
+ - Formalized generated Tile ids, positional CSS classes, template placement, and per-use callback signatures.
168
+ - Formalized String and Symbol ids across Derender selection APIs and documented file-read failures consistently.
169
+ - Breaking: made top-level `Decompile`, `Derender`, `Evaluate`, and `EvaluateChildren` consume inline SVG/XML;
170
+ file inputs now use the corresponding `File`-suffixed entrypoints.
171
+ - Breaking: replaced callable drawing module `call` block registration with argument-independent `base` blocks;
172
+ inherited bases run parent-first, and modules with one drawing method conventionally name it `call`.
173
+ - Breaking: made bracket and call notation the canonical Geometry constructors. Among Data value types, bracket notation
174
+ is public only for Point, Segment, LengthAngle, Margin, and Paper; use `.new` for Location and result carriers, and
175
+ `Stay` for traversal stop tokens.
176
+ - Breaking: aligned Point and Segment comparison with Ruby `Comparable`; malformed or unrelated comparison operands now
177
+ return nil from `<=>`.
178
+ - Breaking: executor entrypoints now return immutable `Executor::Result` values and expose only `execute` and
179
+ `execute_file`; inspect `result.error`, `result.stack`, and `result.value` instead of executor scopes or lifecycle state.
180
+ - Breaking: wrapper attributes and callable arguments use distinct channels, `With` rejects parentless receivers, and
181
+ unsupported direct constructors are private; use the documented factories for Content, concrete Geometry lined
182
+ elements, and Grid query values.
183
+ - Breaking: Canvas uses `.new` for explicit fields, `.from_paper(paper, **overrides)` for paper conversion, and
184
+ `.call`/`Graphics.canvas` for dispatch; the misleading keyword-only `.from_paper(width:, height:)` form was removed.
185
+ - Breaking: `Save`, `Write`, `PNG`, `PDF`, and Sundries native export normalize successful destinations to expanded
186
+ String paths and create missing parent directories; change-aware SVG writes still return nil when unchanged.
187
+ - Breaking: renamed `Derender.evaluate_file_children` to `evaluate_children_file`; decompiled nodes now own immutable
188
+ public state while parser, strategy, and construction plumbing remain private.
189
+ - Expanded runtime/YARD parity checks and exact contracts for inherited, extended, generated, and dynamic API surfaces,
190
+ forwarded options, error channels, path ownership, whitespace, namespaces, nil behavior, and return values.
191
+
192
+ ### Fixed
193
+
194
+ - Rejected directories from default file discovery while preserving custom locator matchers.
195
+ - Kept `Ancestral` context in non-rendering `-context` metadata instead of leaking it into SVG attributes.
196
+ - Preserved source Canvas units and names when deriving fitted Grid canvases.
197
+ - Prevented stale documentation assets from mixing old layouts with new HTML, and moved sidebar navigation into the
198
+ tablet menu at 1024px and below.
199
+ - Normalized numeric slots owned by path, shape, transform, tile, and Inkscape page helpers to finite SVG number spelling;
200
+ arbitrary user-supplied attributes remain untouched.
201
+ - Made named callable wrapper and symbol ids stable while omitting defaults for anonymous modules, and indexed every
202
+ rendered id value, including false and numeric values, through its serialized string.
203
+ - Preserved signed Geometry constraint directions, rejected invalid sweep/export channels through Sevgi error families,
204
+ and validated raw output paths before expansion or rendering.
205
+ - Made callable module configuration copy-owned and freeze-aware, document subclasses inherit their nearest profile, and
206
+ false executor boot receivers remain explicit rather than defaulting to an internal scope.
207
+ - Made element trees, attributes, identifiers, locator results, document profiles, Derender nodes, shell results, and
208
+ executor results retain owned immutable snapshots where their public contracts promise value semantics.
209
+ - Corrected Shell combined-output separators, nil export density errors, document render-option routing, executor source
210
+ snapshots, selected-node namespace/whitespace documentation, and Standard character-data validation.
211
+
212
+ ### Removed
213
+
214
+ - Removed public access to pluralization tables and the internal SVG save extension; pluralization rules are now deeply
215
+ immutable.
216
+ - Removed public documentation and constant access for command-line implementation modules; the `sevgi` and `igves`
217
+ executables remain unchanged.
218
+ - Removed eager loading and public documentation of private Showcase build/test support; explicit support entrypoints
219
+ now keep the harness under the Showcase namespace.
220
+ - Removed public access to document profile name normalizers; registry operations retain them as private plumbing.
221
+ - Removed the redundant `Margin.margin` constructor; use canonical bracket notation.
222
+ - Removed public executor orchestration, obsolete callable-module hooks, the old public attribute syntax constants, and
223
+ direct construction of abstract or internally wired Content, Element, and Grid query types.
224
+ - Removed accidental public access to abstract Lined factories, internal element-name/export maps, result/location
225
+ bracket constructors, and direct Stop construction.
7
226
 
8
227
  ## 0.95.0 - 2026-07-11
9
228
 
@@ -87,7 +306,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
87
306
 
88
307
  ### Changed
89
308
 
90
- - Added the checker board example to the documentation showcase flow.
309
+ - Added the checkerboard example to the documentation showcase flow.
91
310
  - Consolidated Victor Book attribution for adapted showcase examples into a single documentation note.
92
311
 
93
312
  ### Fixed
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sevgi
2
2
 
3
- Top-level API and `.sevgi` script runner.
3
+ The `sevgi` gem provides the top-level API and the `.sevgi` script runner.
4
4
 
5
5
  ## Install
6
6
 
@@ -17,20 +17,38 @@ require "sevgi"
17
17
  ## Example
18
18
 
19
19
  ```ruby
20
- SVG(:minimal) do
21
- rect(width: 3, height: 5)
20
+ SVG :minimal do
21
+ rect width: 3, height: 5
22
22
  end.call
23
23
  ```
24
24
 
25
- ## Executable
25
+ ## Executables
26
26
 
27
27
  ```sh
28
28
  sevgi drawing.sevgi
29
+ igsev drawing.svg
29
30
  ```
30
31
 
32
+ Both commands read standard input when the file is omitted or `-`. For `sevgi`, implicit `Save`, `PDF`, and `PNG`
33
+ destinations use `output` as the input name. Use `--as NAME` to choose another basename:
34
+
35
+ ```sh
36
+ sevgi --as badge < drawing.sevgi
37
+ igsev < drawing.svg > normalized.svg
38
+ ```
39
+
40
+ `NAME` cannot include a directory. An explicit output path or `default:` argument in the script remains authoritative.
41
+ With a file operand, `--as` keeps the file's source directory so relative `Load` calls continue to resolve there.
42
+
43
+ `sevgi --skill` prints the validated path of the matching packaged agent skill. See the
44
+ [Appendix documentation](https://github.com/roktas/sevgi/tree/main/appendix) for installation guidance.
45
+
46
+ `igsev` converts an SVG file to Sevgi source, evaluates it with the complete DSL, and prints the resulting normalized
47
+ SVG. Use `igves` from `sevgi-derender` when the generated Sevgi source itself is the desired output.
48
+
31
49
  ## Ruby compatibility
32
50
 
33
- Requires Ruby 3.4.0 or newer. CI verifies Ruby 3.4.0 and the current development Ruby from `.ruby-version`.
51
+ Requires Ruby 3.4.0 or newer. CI verifies the current Ruby 3.4 release and the development Ruby from `.ruby-version`.
34
52
 
35
53
  ## Native prerequisites
36
54
 
@@ -55,7 +73,7 @@ gem install cairo rsvg2 hexapdf
55
73
 
56
74
  ## Links
57
75
 
58
- - Documentation: https://sevgi.roktas.dev
59
- - API documentation: https://www.rubydoc.info/gems/sevgi
60
- - Source: https://github.com/roktas/sevgi/tree/main/toplevel
61
- - Changelog: https://github.com/roktas/sevgi/blob/main/CHANGELOG.md
76
+ - Documentation: <https://sevgi.roktas.dev>
77
+ - API documentation: <https://www.rubydoc.info/gems/sevgi>
78
+ - Source: <https://github.com/roktas/sevgi/tree/main/toplevel>
79
+ - Changelog: <https://github.com/roktas/sevgi/blob/main/CHANGELOG.md>
data/bin/igsev ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "sevgi/binaries/igsev"
5
+
6
+ Sevgi.const_get(:Binaries, false)::Igsev.(ARGV)
data/bin/sevgi CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  require "sevgi/binaries/sevgi"
5
5
 
6
- Sevgi::Binaries::Sevgi.(ARGV)
6
+ Sevgi.const_get(:Binaries, false)::Sevgi.(ARGV)
@@ -0,0 +1,161 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sevgi"
4
+
5
+ module Sevgi
6
+ # Command-line entrypoint implementations shipped with Sevgi.
7
+ # @api private
8
+ module Binaries
9
+ # Implements the `igsev` executable that round-trips SVG files through Sevgi.
10
+ # @api private
11
+ module Igsev
12
+ extend self
13
+
14
+ # Executable name used in help output.
15
+ PROGNAME = "igsev"
16
+
17
+ # Error raised for invalid command-line usage.
18
+ Error = Class.new(::Sevgi::Error)
19
+
20
+ FLAGS = {
21
+ "--exception" => :vomit,
22
+ "--help" => :help,
23
+ "--version" => :version,
24
+ "-h" => :help,
25
+ "-v" => :version,
26
+ "-x" => :vomit
27
+ }.freeze
28
+ private_constant :FLAGS
29
+
30
+ # Parsed command-line options for the `igsev` executable.
31
+ # @api private
32
+ Options = Struct.new(:require, :vomit, :help, :version, :omit) do
33
+ # Parses command-line options and removes them from the argv array.
34
+ # @param argv [Array<String>] mutable command-line argument array
35
+ # @return [Sevgi::Binaries::Igsev::Options] parsed options
36
+ # @raise [Sevgi::Binaries::Igsev::Error] when an option is not recognized or a required value is missing
37
+ def self.parse(argv)
38
+ new.tap do |options|
39
+ until argv.empty? || argv.first == "-" || !argv.first.start_with?("-")
40
+ if argv.first == "--"
41
+ argv.shift
42
+ break
43
+ end
44
+
45
+ option(argv, options)
46
+ end
47
+ end
48
+ end
49
+
50
+ class << self
51
+ private
52
+
53
+ def option(argv, options)
54
+ arg = argv.shift
55
+ return options[FLAGS[arg]] = true if FLAGS.key?(arg)
56
+ if ["-r", "--require"].include?(arg)
57
+ return options.require = argv.shift || Error.("Option requires a library: #{arg}")
58
+ end
59
+
60
+ return (options.omit ||= []) << (argv.shift || Error.("No attribute given for --omit")) if arg == "--omit"
61
+
62
+ Error.("Not a valid option: #{arg}")
63
+ end
64
+ end
65
+ end
66
+
67
+ private_constant :Options
68
+
69
+ # Runs the `igsev` command-line interface.
70
+ # @param argv [Array<String>, String, nil] command-line arguments
71
+ # @return [nil]
72
+ # @raise [StandardError] when `--exception` or `SEVGI_VOMIT` requests raw errors
73
+ # @raise [SystemExit] when argv does not match `[options...] [--] [file|-]` or conversion aborts
74
+ def call(argv)
75
+ dispatch(Array(argv))
76
+ rescue Binaries::Igsev::Error => e
77
+ abort("#{e.message}\n\n#{help}")
78
+ end
79
+
80
+ private
81
+
82
+ def backtrace(error)
83
+ return error.load_backtrace if error.respond_to?(:load_backtrace)
84
+
85
+ error.backtrace || []
86
+ end
87
+
88
+ def die(error)
89
+ warn(error.message)
90
+ warn("")
91
+ backtrace(error).each { warn(" #{it}") }
92
+
93
+ exit(1)
94
+ end
95
+
96
+ def dispatch(argv)
97
+ options = Options.parse(argv)
98
+ return puts(help) if options.help
99
+ return puts(::Sevgi::VERSION) if options.version
100
+
101
+ emit(operand(argv), options)
102
+ rescue Binaries::Igsev::Error
103
+ raise
104
+ rescue ::StandardError => e
105
+ raise if raw_error?(options)
106
+
107
+ die(e)
108
+ end
109
+
110
+ def emit(file, options)
111
+ result = run(file, options)
112
+ unless result.success?
113
+ raise result.error if raw_error?(options)
114
+
115
+ die(result.error)
116
+ end
117
+
118
+ result.value.Out()
119
+ end
120
+
121
+ def help
122
+ <<~HELP
123
+ Usage: #{PROGNAME} [options...] [--] [SVG file|-]
124
+
125
+ See documentation for detailed help.
126
+
127
+ Options:
128
+
129
+ --omit ATTRIBUTE Omit an attribute (repeatable)
130
+ -r, --require LIB Require Ruby LIB while evaluating generated source
131
+ -x, --exception Raise exception instead of abort
132
+ -- Stop option parsing
133
+
134
+ -h, --help Show this help
135
+ -v, --version Display version
136
+ HELP
137
+ end
138
+
139
+ def operand(argv)
140
+ file = argv.shift
141
+ Error.("Unexpected argument: #{argv.first}") unless argv.empty?
142
+
143
+ file unless file == "-"
144
+ end
145
+
146
+ def raw_error?(options) = options&.vomit || ENV.fetch(ENVVOMIT, nil)
147
+
148
+ def run(file, options)
149
+ source = if file
150
+ ::Sevgi::Derender.derender_file(file, omit: options.omit)
151
+ else
152
+ ::Sevgi::Derender.derender($stdin.read, omit: options.omit)
153
+ end
154
+
155
+ ::Sevgi.execute(source, require: options.require)
156
+ end
157
+ end
158
+ end
159
+
160
+ private_constant :Binaries
161
+ end
@@ -14,15 +14,20 @@ module FileUtils
14
14
  # @param file [String] Sevgi script file, with or without `.sevgi` extension
15
15
  # @param args [Array] positional arguments exposed to the script as `ARGA`
16
16
  # @param kwargs [Hash] keyword arguments exposed to the script as `ARGH`
17
- # @return [Sevgi::Executor::Scope, nil] execution scope, or nil for an empty file
17
+ # @return [Sevgi::Executor::Result] immutable execution result
18
18
  # @raise [Sevgi::ArgumentError] when the script file cannot be found
19
- # @see Sevgi::Executor.execute_file
19
+ # @raise [Sevgi::Executor::Error] when execution fails, so Rake stops dependent tasks
20
+ # @see Sevgi.execute_file
20
21
  def sevgi(file, *args, **kwargs)
21
- Sevgi::Executor.execute_file(Sevgi::F.existing!(file, [Sevgi::EXTENSION])) do
22
+ result = Sevgi::Executor.__send__(:execute_file, Sevgi::F.existing!(file, [Sevgi::EXTENSION])) do
22
23
  extend(Sevgi)
23
24
 
24
25
  const_set(:ARGA, args).freeze
25
26
  const_set(:ARGH, kwargs).freeze
26
27
  end
28
+
29
+ raise result.error if result.error?
30
+
31
+ result
27
32
  end
28
33
  end