sevgi-standard 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: bbd8aa9bd86beedb621d7f5a2231821c3e33e15f038a6b9b858764fc6789e16e
4
- data.tar.gz: c2aa30f2b04fe0b7769667223902ba92d17aa99e3e5d182d79c24ec5fbf53961
3
+ metadata.gz: e30974181bcc1ae3893e5f3bc2348a73815a425dbcf0ee4dce33dcb27388d5ae
4
+ data.tar.gz: 31833cb299407153802ac60e9ad1274141f53d88ebf417fdd958b26c46191c3e
5
5
  SHA512:
6
- metadata.gz: e180e41124e5579fef07b58ff3fb7b54371feebd118919a33ca1720bf3d50623d4accdd419d0465df0721b16ca866a9722a8196177d5aa1c7194ef8093fc906d
7
- data.tar.gz: a28509223d1ec39ff0feb51d60df71f4a1b3c1d459173d596f67f7c76a8a1a2c06457f6d60fd1ce1b2e16786ea0ffd7bc89ac49e1a928750a9a6c3c7b79b7fb0
6
+ metadata.gz: 1087087f3ca625e836654958ea79705219b806bb64eac1ae6e43e2e4f6b0e1ff4e368681a1f8b77fd0514ecd4fd785f06245dad9b53f1f105cd3286adddc224b
7
+ data.tar.gz: dbfda5403aeb0289afbbc0e76e508d1e9b02ad1b88f2c3a5b89722e5eaf4db0f4ed442e648dca0ee6966a0b78d8b75810cddbf15820275e39f9e00b490849fda
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 Standard
2
2
 
3
- SVG element, attribute, and conformance data used by Sevgi validation.
3
+ Sevgi Standard supplies the SVG element and attribute data used by validation.
4
4
 
5
5
  ## Install
6
6
 
@@ -19,19 +19,23 @@ require "sevgi/standard"
19
19
  ```ruby
20
20
  Sevgi::Standard.element?(:rect)
21
21
  Sevgi::Standard.attribute?(:width)
22
+ Sevgi::Standard.conform(:rect, attributes: %i[width height]) # => true
22
23
  ```
23
24
 
25
+ The component validates names, attributes, content, and nesting against Sevgi's bundled SVG compatibility data.
26
+ `conform` raises `Sevgi::ValidationError` when a known usage violates that data.
27
+
24
28
  ## Ruby compatibility
25
29
 
26
- Requires Ruby 3.4.0 or newer. CI verifies Ruby 3.4.0 and the current development Ruby from `.ruby-version`.
30
+ Requires Ruby 3.4.0 or newer. CI verifies the current Ruby 3.4 release and the development Ruby from `.ruby-version`.
27
31
 
28
32
  ## Native prerequisites
29
33
 
30
- None beyond Ruby and this gem's Ruby dependencies.
34
+ This gem needs only Ruby and its Ruby dependencies.
31
35
 
32
36
  ## Links
33
37
 
34
- - Documentation: https://sevgi.roktas.dev
35
- - API documentation: https://www.rubydoc.info/gems/sevgi-standard
36
- - Source: https://github.com/roktas/sevgi/tree/main/standard
37
- - Changelog: https://github.com/roktas/sevgi/blob/main/CHANGELOG.md
38
+ - Documentation: <https://sevgi.roktas.dev>
39
+ - API documentation: <https://www.rubydoc.info/gems/sevgi-standard>
40
+ - Source: <https://github.com/roktas/sevgi/tree/main/standard>
41
+ - Changelog: <https://github.com/roktas/sevgi/blob/main/CHANGELOG.md>
@@ -38,6 +38,7 @@ module Sevgi
38
38
  # @param elements [Array<String, Symbol>, String, Symbol, nil] child element names
39
39
  # @return [Boolean] true when the usage conforms
40
40
  # @raise [Sevgi::ArgumentError] when any name is not a valid public name
41
+ # @raise [Sevgi::ArgumentError] when cdata is not a String or nil
41
42
  # @raise [Sevgi::ValidationError] when the usage violates the standard data
42
43
  def call(attributes: nil, cdata: nil, elements: nil)
43
44
  if attributes
@@ -60,33 +61,45 @@ module Sevgi
60
61
  # @param elements [Array<String, Symbol>, nil] child element names
61
62
  # @return [Boolean] true when the usage conforms or the element is ignored
62
63
  # @raise [Sevgi::ArgumentError] when any name is not a valid public name
64
+ # @raise [Sevgi::ArgumentError] when cdata is not a String or nil
63
65
  # @raise [Sevgi::ValidationError] when the usage violates the standard data
64
66
  # @raise [Sevgi::PanicError] when the standard data refers to an invalid model
65
67
  def self.call(element, attributes: nil, cdata: nil, elements: nil)
66
68
  element = Name.normalize!(element, context: "element")
67
69
  attributes = Name.list!(attributes, context: "attribute")
68
70
  elements = Name.list!(elements, context: "element") || []
71
+ cdata = normalize_cdata(cdata)
69
72
 
70
73
  Element.ignore?(element) or
71
74
  validate(element, attributes:, elements:, cdata:)
72
75
  end
73
76
 
74
- def self.validate(element, attributes:, elements:, cdata:)
75
- validator = @cache[element] || new(element)
76
- result = validator.call(**arguments(attributes, elements, cdata))
77
- @cache[element] ||= validator
78
- result
79
- end
77
+ class << self
78
+ private
80
79
 
81
- def self.arguments(attributes, elements, cdata)
82
- {
83
- attributes: Attribute.concerns(attributes),
84
- elements: Element.concerns(elements),
85
- cdata:
86
- }
87
- end
80
+ def validate(element, attributes:, elements:, cdata:)
81
+ validator = @cache[element] || new(element)
82
+ result = validator.call(**arguments(attributes, elements, cdata))
83
+ @cache[element] ||= validator
84
+ result
85
+ end
86
+
87
+ def arguments(attributes, elements, cdata)
88
+ {
89
+ attributes: Attribute.concerns(attributes),
90
+ elements: Element.concerns(elements),
91
+ cdata:
92
+ }
93
+ end
94
+
95
+ def normalize_cdata(cdata)
96
+ unless cdata.nil? || cdata.is_a?(::String)
97
+ ArgumentError.("Character data must be a String or nil: #{cdata.inspect}")
98
+ end
88
99
 
89
- private_class_method :arguments, :validate
100
+ cdata unless cdata == ""
101
+ end
102
+ end
90
103
  end
91
104
 
92
105
  private_constant :Conform, :Model
@@ -494,7 +494,7 @@ module Sevgi
494
494
  RESERVED_NAMESPACE_PREFIXES = %w[xlink: xml:].freeze
495
495
  private_constant :RESERVED_NAMESPACE_PREFIXES
496
496
 
497
- # Reports whether an attribute name should be ignored by standard validation.
497
+ # Reports whether standard validation ignores an attribute name.
498
498
  # @param attribute [String, Symbol, Object] candidate attribute name
499
499
  # @return [Boolean] true for valid private, data, xmlns, or foreign namespaced attributes
500
500
  def ignore?(attribute)
@@ -265,9 +265,9 @@ module Sevgi
265
265
  ]
266
266
  )
267
267
 
268
- # Reports whether an element name should be ignored by standard validation.
268
+ # Reports whether standard validation ignores an element name.
269
269
  # @param element [String, Symbol, Object] candidate element name
270
- # @return [Boolean] true for valid private or namespaced element names that Sevgi should not validate
270
+ # @return [Boolean] true for valid private or namespaced element names outside Sevgi validation
271
271
  def ignore?(element)
272
272
  return false unless element.is_a?(::String) || element.is_a?(::Symbol)
273
273
 
@@ -43,6 +43,10 @@ module Sevgi
43
43
  # @return [Set<Symbol>] mutation-isolated set snapshot
44
44
  def all = Snapshot.copy(@all ||= Set[*data.values.flatten.uniq.sort])
45
45
 
46
+ # Returns accepted group names for this data list.
47
+ # @return [Set<Symbol>] frozen group-name snapshot
48
+ def groups = @groups ||= Set[*data.keys.sort].freeze
49
+
46
50
  # Checks whether a name belongs to a group.
47
51
  # @param name [Symbol] item name
48
52
  # @param group [Symbol] group name
@@ -82,7 +86,7 @@ module Sevgi
82
86
 
83
87
  # Removes ignored names from a list.
84
88
  # @param names [Array<Symbol>, nil] names to filter
85
- # @return [Array<Symbol>, nil] names that should be validated
89
+ # @return [Array<Symbol>, nil] names selected for validation
86
90
  def concerns(names) = names ? names.reject { ignore?(it) } : names
87
91
 
88
92
  # Installs low-level list helpers into data modules.
@@ -94,6 +98,8 @@ module Sevgi
94
98
 
95
99
  private_constant :Common
96
100
 
101
+ # SVG attribute registry implementation.
102
+ # @api private
97
103
  module Attribute
98
104
  extend Common
99
105
  extend self
@@ -103,6 +109,8 @@ module Sevgi
103
109
 
104
110
  private_constant :Attribute
105
111
 
112
+ # SVG element registry implementation.
113
+ # @api private
106
114
  module Element
107
115
  extend Common
108
116
  extend self
@@ -112,6 +120,8 @@ module Sevgi
112
120
 
113
121
  private_constant :Element
114
122
 
123
+ # SVG specification registry implementation.
124
+ # @api private
115
125
  module Specification
116
126
  extend List
117
127
  extend self
@@ -162,11 +172,6 @@ module Sevgi
162
172
  names.replace(names.flat_map { |name| group?(name) ? list[name] : name }.uniq)
163
173
  end
164
174
 
165
- # For testing purposes
166
-
167
- def charge = data.each_key { expand(it) }
168
-
169
- def flush = (@spec = {})
170
175
  end
171
176
 
172
177
  private_constant :Specification
@@ -71,15 +71,12 @@ module Sevgi
71
71
  def self.extended(base)
72
72
  super
73
73
 
74
- base.class_exec do
75
- @data = {}
76
-
77
- class << self
78
- attr_reader :data
79
- private :data
80
- end
81
- end
74
+ base.instance_variable_set(:@data, {})
82
75
  end
76
+
77
+ private
78
+
79
+ attr_reader :data
83
80
  end
84
81
 
85
82
  private_constant :List
@@ -3,6 +3,6 @@
3
3
  module Sevgi
4
4
  module Standard
5
5
  # Current version of the Sevgi standard gem.
6
- VERSION = "0.95.0"
6
+ VERSION = "1.0.0"
7
7
  end
8
8
  end
@@ -13,8 +13,12 @@ require_relative "standard/version"
13
13
  module Sevgi
14
14
  # SVG standard data and validation helpers.
15
15
  # The registry is a Sevgi compatibility set based on SVG 2 plus the split-out SVG modules and legacy entries already
16
- # modeled in the bundled specifications. Supported element names must have matching specification data; abandoned or
16
+ # modeled in the bundled specifications. Supported element names must have matching specification data. Abandoned or
17
17
  # unspecified proposal entries are not exposed as supported elements.
18
+ #
19
+ # @example Validate an SVG element usage
20
+ # Sevgi::Standard.conform(:rect, attributes: %i[width height]) #=> true
21
+ # Sevgi::Standard.element?(:foreignObject) #=> true
18
22
  module Standard
19
23
  extend self
20
24
 
@@ -22,8 +26,16 @@ module Sevgi
22
26
  # Returns SVG attributes, optionally restricted to one or more attribute groups.
23
27
  # @param groups [Array<String, Symbol>] attribute group names
24
28
  # @return [Set<Symbol>] mutation-isolated attribute-name snapshot
29
+ # @raise [Sevgi::ArgumentError] when a group name is invalid or not listed by {.attribute_groups}
30
+ # @example Discover and apply an attribute group
31
+ # Sevgi::Standard.attribute_groups.include?(:Core) #=> true
32
+ # Sevgi::Standard.attributes(:Core).include?(:id) #=> true
25
33
  def attributes(...) = Attribute.set(...)
26
34
 
35
+ # Returns accepted attribute group names.
36
+ # @return [Set<Symbol>] frozen group-name snapshot
37
+ def attribute_groups = Attribute.groups
38
+
27
39
  # Reports whether an attribute name is recognized by the SVG standard data.
28
40
  # @param name [String, Symbol] attribute name
29
41
  # @return [Boolean]
@@ -40,16 +52,26 @@ module Sevgi
40
52
  # @return [Boolean] true when the usage conforms
41
53
  # @raise [Sevgi::ArgumentError] when any name is not a String or Symbol
42
54
  # @raise [Sevgi::ArgumentError] when any name is not a valid SVG-style name
55
+ # @raise [Sevgi::ArgumentError] when cdata is not a String or nil
43
56
  # @raise [Sevgi::ValidationError] when the usage violates the standard data
44
57
  # @raise [Sevgi::PanicError] when the standard data refers to an invalid model
58
+ # @note Empty character data is treated as absent.
45
59
  def conform(...) = Conform.(...)
46
60
 
47
61
  # @overload elements(*groups)
48
62
  # Returns SVG elements, optionally restricted to one or more element groups.
49
63
  # @param groups [Array<String, Symbol>] element group names
50
64
  # @return [Set<Symbol>] mutation-isolated element-name snapshot
65
+ # @raise [Sevgi::ArgumentError] when a group name is invalid or not listed by {.element_groups}
66
+ # @example Discover and apply an element group
67
+ # Sevgi::Standard.element_groups.include?(:Descriptive) #=> true
68
+ # Sevgi::Standard.elements(:Descriptive) #=> Set[:desc, :metadata, :title]
51
69
  def elements(...) = Element.set(...)
52
70
 
71
+ # Returns accepted element group names.
72
+ # @return [Set<Symbol>] frozen group-name snapshot
73
+ def element_groups = Element.groups
74
+
53
75
  # Reports whether an element name is recognized by the SVG standard data.
54
76
  # @param name [String, Symbol] element name
55
77
  # @return [Boolean]
@@ -67,7 +89,7 @@ module Sevgi
67
89
  def model?(...) = Specification.model?(...)
68
90
 
69
91
  # Returns the expanded standard contract for an SVG element.
70
- # The returned hash and nested arrays are mutation-isolated snapshots; changing them does not alter the registry.
92
+ # The returned hash and nested arrays are mutation-isolated snapshots. Changing them does not alter the registry.
71
93
  # @param name [String, Symbol] SVG element name
72
94
  # @return [Hash, nil] expanded specification snapshot, or nil when name is unknown
73
95
  # @raise [Sevgi::ArgumentError] when name is not a String or Symbol
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevgi-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.95.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recai Oktaş
@@ -15,15 +15,15 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.95.0
18
+ version: 1.0.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.95.0
26
- description: Validates elements and attributes according to the SVG specification.
25
+ version: 1.0.0
26
+ description: Checks generated SVG against standard element and attribute rules.
27
27
  email: roktas@gmail.com
28
28
  executables: []
29
29
  extensions: []
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubygems_version: 4.0.11
68
+ rubygems_version: 4.0.20
69
69
  specification_version: 4
70
- summary: SVG Validation for the Sevgi toolkit.
70
+ summary: SVG element and attribute validation for Sevgi.
71
71
  test_files: []