vectory 0.8.0 → 0.8.1
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 +4 -4
- data/.github/workflows/docs.yml +59 -0
- data/.github/workflows/links.yml +99 -0
- data/.github/workflows/rake.yml +5 -1
- data/.github/workflows/release.yml +7 -3
- data/.gitignore +5 -0
- data/.rubocop.yml +11 -3
- data/.rubocop_todo.yml +252 -0
- data/Gemfile +4 -2
- data/README.adoc +23 -1
- data/Rakefile +13 -0
- data/docs/Gemfile +18 -0
- data/docs/_config.yml +179 -0
- data/docs/features/conversion.adoc +205 -0
- data/docs/features/external-dependencies.adoc +305 -0
- data/docs/features/format-detection.adoc +173 -0
- data/docs/features/index.adoc +205 -0
- data/docs/getting-started/core-concepts.adoc +214 -0
- data/docs/getting-started/index.adoc +37 -0
- data/docs/getting-started/installation.adoc +318 -0
- data/docs/getting-started/quick-start.adoc +160 -0
- data/docs/guides/error-handling.adoc +400 -0
- data/docs/guides/index.adoc +197 -0
- data/docs/index.adoc +146 -0
- data/docs/lychee.toml +25 -0
- data/docs/reference/api.adoc +355 -0
- data/docs/reference/index.adoc +189 -0
- data/docs/understanding/architecture.adoc +277 -0
- data/docs/understanding/index.adoc +148 -0
- data/docs/understanding/inkscape-wrapper.adoc +270 -0
- data/lib/vectory/capture.rb +165 -37
- data/lib/vectory/cli.rb +2 -0
- data/lib/vectory/configuration.rb +177 -0
- data/lib/vectory/conversion/ghostscript_strategy.rb +77 -0
- data/lib/vectory/conversion/inkscape_strategy.rb +124 -0
- data/lib/vectory/conversion/strategy.rb +58 -0
- data/lib/vectory/conversion.rb +104 -0
- data/lib/vectory/datauri.rb +1 -1
- data/lib/vectory/emf.rb +17 -5
- data/lib/vectory/eps.rb +45 -3
- data/lib/vectory/errors.rb +25 -0
- data/lib/vectory/file_magic.rb +2 -2
- data/lib/vectory/ghostscript_wrapper.rb +160 -0
- data/lib/vectory/image_resize.rb +2 -2
- data/lib/vectory/inkscape_wrapper.rb +205 -0
- data/lib/vectory/pdf.rb +76 -0
- data/lib/vectory/platform.rb +105 -0
- data/lib/vectory/ps.rb +47 -3
- data/lib/vectory/svg.rb +46 -3
- data/lib/vectory/svg_document.rb +40 -24
- data/lib/vectory/system_call.rb +36 -9
- data/lib/vectory/vector.rb +3 -23
- data/lib/vectory/version.rb +1 -1
- data/lib/vectory.rb +16 -11
- metadata +34 -3
- data/lib/vectory/inkscape_converter.rb +0 -141
data/docs/index.adoc
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Home
|
|
4
|
+
nav_order: 1
|
|
5
|
+
description: "Vectory: Vector image conversion library for Ruby"
|
|
6
|
+
permalink: /
|
|
7
|
+
---
|
|
8
|
+
= Vectory Documentation
|
|
9
|
+
:toc: macro
|
|
10
|
+
:toclevels: 2
|
|
11
|
+
|
|
12
|
+
[.lead]
|
|
13
|
+
Vectory provides pairwise vector image conversion for Ruby applications, supporting EPS, PS, EMF, SVG, and PDF formats through integration with external conversion tools.
|
|
14
|
+
|
|
15
|
+
toc::[]
|
|
16
|
+
|
|
17
|
+
== Welcome
|
|
18
|
+
|
|
19
|
+
Vectory helps you:
|
|
20
|
+
|
|
21
|
+
* **Convert** between vector image formats (EPS, PS, EMF, SVG, PDF)
|
|
22
|
+
* **Preserve** document metadata and bounding boxes
|
|
23
|
+
* **Leverage** external tools (Inkscape, Ghostscript, emf2svg) for reliable conversions
|
|
24
|
+
* **Process** images from files, content, or data URIs
|
|
25
|
+
* **Query** image dimensions without full rendering
|
|
26
|
+
|
|
27
|
+
== Quick Navigation
|
|
28
|
+
|
|
29
|
+
=== By Your Role
|
|
30
|
+
|
|
31
|
+
**Application Developer**::
|
|
32
|
+
Start with link:features/ruby-api/[Ruby API] to integrate Vectory into your applications.
|
|
33
|
+
|
|
34
|
+
**Metanorma User**::
|
|
35
|
+
Start with link:guides/metanorma-integration[Metanorma Integration] for SVG mapping in XML documents.
|
|
36
|
+
|
|
37
|
+
**Library Maintainer**::
|
|
38
|
+
Start with link:understanding/architecture[Architecture] to understand Vectory's design.
|
|
39
|
+
|
|
40
|
+
=== By Task
|
|
41
|
+
|
|
42
|
+
**Convert EPS to SVG**::
|
|
43
|
+
* link:getting-started/quick-start#converting-eps-to-svg[Quick Start: EPS to SVG]
|
|
44
|
+
* link:features/conversion/[Conversion Features]
|
|
45
|
+
|
|
46
|
+
**Batch process images**::
|
|
47
|
+
* link:guides/batch-processing[Guide: Batch Processing]
|
|
48
|
+
* link:reference/api[API Reference]
|
|
49
|
+
|
|
50
|
+
**Handle format detection**::
|
|
51
|
+
* link:features/format-detection[Format Detection]
|
|
52
|
+
* link:guides/error-handling[Guide: Error Handling]
|
|
53
|
+
|
|
54
|
+
**Query image dimensions**::
|
|
55
|
+
* link:guides/dimension-query[Guide: Dimension Query]
|
|
56
|
+
|
|
57
|
+
=== By Format
|
|
58
|
+
|
|
59
|
+
link:features/formats/eps[**EPS (Encapsulated PostScript)**]::
|
|
60
|
+
PostScript-based vector format with bounding box support
|
|
61
|
+
|
|
62
|
+
link:features/formats/ps[**PS (PostScript)**]::
|
|
63
|
+
Full PostScript document format
|
|
64
|
+
|
|
65
|
+
link:features/formats/emf[**EMF (Enhanced Metafile)**]::
|
|
66
|
+
Windows vector metafile format
|
|
67
|
+
|
|
68
|
+
link:features/formats/svg[**SVG (Scalable Vector Graphics)**]::
|
|
69
|
+
XML-based vector format for web graphics
|
|
70
|
+
|
|
71
|
+
link:features/formats/pdf[**PDF (Portable Document Format)**]::
|
|
72
|
+
Intermediate format for conversion pipeline
|
|
73
|
+
|
|
74
|
+
== Learning Path
|
|
75
|
+
|
|
76
|
+
=== Level 1: Get Started (5 minutes)
|
|
77
|
+
|
|
78
|
+
. link:getting-started/installation[Install Vectory]
|
|
79
|
+
. link:getting-started/quick-start[Try basic examples]
|
|
80
|
+
. link:getting-started/core-concepts[Understand core concepts]
|
|
81
|
+
|
|
82
|
+
=== Level 2: Learn Features (15 minutes)
|
|
83
|
+
|
|
84
|
+
. link:features/conversion/[Conversion methods]
|
|
85
|
+
. link:features/format-detection/[Automatic format detection]
|
|
86
|
+
. link:features/dimension-query/[Dimension queries]
|
|
87
|
+
|
|
88
|
+
=== Level 3: Understand Vectory (30 minutes)
|
|
89
|
+
|
|
90
|
+
. link:understanding/architecture[Architecture overview]
|
|
91
|
+
. link:understanding/external-dependencies/[External tools: Inkscape and Ghostscript]
|
|
92
|
+
. link:understanding/conversion-pipeline/[Conversion pipeline]
|
|
93
|
+
|
|
94
|
+
=== Level 4: Advanced Topics (As needed)
|
|
95
|
+
|
|
96
|
+
* link:features/speed[Speed optimizations]
|
|
97
|
+
* link:guides/metanorma-integration[Metanorma SVG mapping]
|
|
98
|
+
* link:reference/error-handling[Error handling reference]
|
|
99
|
+
|
|
100
|
+
== Popular Topics
|
|
101
|
+
|
|
102
|
+
* link:features/conversion/[Supported Conversions] - All format-to-format conversion paths
|
|
103
|
+
* link:reference/api[Public API] - Complete class and method reference
|
|
104
|
+
* link:features/inkscape-version[Inkscape Version Handling] - Version 0.x vs 1.x+ compatibility
|
|
105
|
+
* link:guides/error-handling[Error Handling] - Common errors and solutions
|
|
106
|
+
* link:reference/configuration[Configuration Options] - Environment variables and settings
|
|
107
|
+
|
|
108
|
+
== Requirements
|
|
109
|
+
|
|
110
|
+
Vectory requires external tools for vector image conversion:
|
|
111
|
+
|
|
112
|
+
=== Required Tools
|
|
113
|
+
|
|
114
|
+
* **Inkscape** (version 0.92 or later recommended)
|
|
115
|
+
** for SVG ↔ EPS/PS/EMF/PDF conversions
|
|
116
|
+
** for dimension queries
|
|
117
|
+
** Version 1.0+ recommended; 1.3.0 for Windows (1.3.1+ has EPS/PS issues)
|
|
118
|
+
|
|
119
|
+
* **Ghostscript** (version 9.0 or later)
|
|
120
|
+
** for EPS/PS → PDF conversion (bounding box preservation)
|
|
121
|
+
** required for EPS and PS format support
|
|
122
|
+
|
|
123
|
+
* **Ruby** (version 3.1 or later)
|
|
124
|
+
** runtime environment for Vectory gem
|
|
125
|
+
|
|
126
|
+
=== Ruby Gems (installed automatically)
|
|
127
|
+
|
|
128
|
+
* **emf2svg** (~> 1.0)
|
|
129
|
+
** for EMF → SVG conversion
|
|
130
|
+
** provides Windows EMF format support
|
|
131
|
+
|
|
132
|
+
* **moxml** (~> 0.5)
|
|
133
|
+
** for XML/HTML parsing (Metanorma integration)
|
|
134
|
+
|
|
135
|
+
See link:getting-started/installation[Installation] for detailed setup instructions including platform-specific requirements.
|
|
136
|
+
|
|
137
|
+
== Getting Help
|
|
138
|
+
|
|
139
|
+
**Found a bug?**::
|
|
140
|
+
link:https://github.com/metanorma/vectory/issues[Report an issue on GitHub]
|
|
141
|
+
|
|
142
|
+
**Have a question?**::
|
|
143
|
+
Search this documentation or check link:reference/glossary[Glossary]
|
|
144
|
+
|
|
145
|
+
**Want to contribute?**::
|
|
146
|
+
See link:contributing[Contributing to Documentation]
|
data/docs/lychee.toml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Lychee configuration for Vectory documentation
|
|
2
|
+
# Excludes certain patterns from link checking
|
|
3
|
+
|
|
4
|
+
# Exclude common localhost patterns
|
|
5
|
+
exclude = [
|
|
6
|
+
'http://localhost:*',
|
|
7
|
+
'http://127.0.0.1:*',
|
|
8
|
+
'file:///*',
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
# Exclude mailto: links
|
|
12
|
+
exclude = [
|
|
13
|
+
'mailto:*',
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
# Exclude version-specific URLs that may break
|
|
17
|
+
exclude = [
|
|
18
|
+
'https://github.com/*/releases/tag/*', # GitHub release tags
|
|
19
|
+
'https://rubygems.org/gems/*/versions/*', # RubyGem version history
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
# Allow certain redirects
|
|
23
|
+
exclude = [
|
|
24
|
+
'https://example.com/*', # Example domains used in docs
|
|
25
|
+
]
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Public API
|
|
4
|
+
parent: Reference
|
|
5
|
+
nav_order: 1
|
|
6
|
+
---
|
|
7
|
+
= API Reference
|
|
8
|
+
|
|
9
|
+
Complete reference for Vectory's public API.
|
|
10
|
+
|
|
11
|
+
== Format Classes
|
|
12
|
+
|
|
13
|
+
=== Vectory::Image
|
|
14
|
+
|
|
15
|
+
Base class for all image types.
|
|
16
|
+
|
|
17
|
+
[source,ruby]
|
|
18
|
+
----
|
|
19
|
+
# Factory method (auto-detects format)
|
|
20
|
+
image = Vectory::Image.from_path("diagram.eps")
|
|
21
|
+
----
|
|
22
|
+
|
|
23
|
+
**Methods**:
|
|
24
|
+
|
|
25
|
+
* `Vectory::Image.from_path(path)` - Load from file path
|
|
26
|
+
* `Vectory::Image.from_content(content)` - Load from content string
|
|
27
|
+
* `Vectory::Image.from_datauri(uri)` - Load from data URI
|
|
28
|
+
|
|
29
|
+
=== Vectory::Vector
|
|
30
|
+
|
|
31
|
+
Abstract base class for vector formats. Inherits from `Vectory::Image`.
|
|
32
|
+
|
|
33
|
+
[source,ruby]
|
|
34
|
+
----
|
|
35
|
+
# Conversion methods available on all vector formats
|
|
36
|
+
vector.to_eps
|
|
37
|
+
vector.to_ps
|
|
38
|
+
vector.to_emf
|
|
39
|
+
vector.to_svg
|
|
40
|
+
vector.to_pdf
|
|
41
|
+
----
|
|
42
|
+
|
|
43
|
+
=== Vectory::Eps
|
|
44
|
+
|
|
45
|
+
Encapsulated PostScript format.
|
|
46
|
+
|
|
47
|
+
[source,ruby]
|
|
48
|
+
----
|
|
49
|
+
# Load EPS
|
|
50
|
+
eps = Vectory::Eps.from_path("diagram.eps")
|
|
51
|
+
|
|
52
|
+
# Convert to other formats
|
|
53
|
+
svg = eps.to_svg
|
|
54
|
+
pdf = eps.to_pdf
|
|
55
|
+
ps = eps.to_ps
|
|
56
|
+
----
|
|
57
|
+
|
|
58
|
+
**Key Methods**:
|
|
59
|
+
|
|
60
|
+
* `Vectory::Eps.from_path(path)` - Load from file
|
|
61
|
+
* `Vectory::Eps.from_content(content)` - Load from string
|
|
62
|
+
* `Vectory::Eps.from_datauri(uri)` - Load from data URI
|
|
63
|
+
* `#dimensions` - Get [width, height] in points
|
|
64
|
+
* `#to_svg` - Convert to SVG
|
|
65
|
+
* `#to_pdf` - Convert to PDF
|
|
66
|
+
* `#to_eps` - Return self
|
|
67
|
+
* `#to_ps` - Convert to PS
|
|
68
|
+
* `#to_emf` - Convert to EMF (via SVG)
|
|
69
|
+
* `#write(path = nil)` - Write to file
|
|
70
|
+
* `#content` - Raw file content
|
|
71
|
+
* `#initial_path` - Original file location
|
|
72
|
+
* `#path` - Current write location
|
|
73
|
+
|
|
74
|
+
=== Vectory::Ps
|
|
75
|
+
|
|
76
|
+
PostScript format. Same API as `Vectory::Eps`.
|
|
77
|
+
|
|
78
|
+
[source,ruby]
|
|
79
|
+
----
|
|
80
|
+
ps = Vectory::Ps.from_path("document.ps")
|
|
81
|
+
svg = ps.to_svg
|
|
82
|
+
----
|
|
83
|
+
|
|
84
|
+
=== Vectory::Svg
|
|
85
|
+
|
|
86
|
+
Scalable Vector Graphics format.
|
|
87
|
+
|
|
88
|
+
[source,ruby]
|
|
89
|
+
----
|
|
90
|
+
svg = Vectory::Svg.from_path("drawing.svg")
|
|
91
|
+
eps = svg.to_eps
|
|
92
|
+
pdf = svg.to_pdf
|
|
93
|
+
----
|
|
94
|
+
|
|
95
|
+
=== Vectory::Emf
|
|
96
|
+
|
|
97
|
+
Enhanced Metafile format.
|
|
98
|
+
|
|
99
|
+
[source,ruby]
|
|
100
|
+
----
|
|
101
|
+
emf = Vectory::Emf.from_path("chart.emf")
|
|
102
|
+
svg = emf.to_svg
|
|
103
|
+
----
|
|
104
|
+
|
|
105
|
+
Uses the emf2svg gem for conversion.
|
|
106
|
+
|
|
107
|
+
=== Vectory::Pdf
|
|
108
|
+
|
|
109
|
+
PDF format (used internally as intermediate format).
|
|
110
|
+
|
|
111
|
+
[source,ruby]
|
|
112
|
+
----
|
|
113
|
+
pdf = Vectory::Pdf.from_path("document.pdf")
|
|
114
|
+
svg = pdf.to_svg
|
|
115
|
+
----
|
|
116
|
+
|
|
117
|
+
## Factory Methods
|
|
118
|
+
|
|
119
|
+
All format classes support these factory methods:
|
|
120
|
+
|
|
121
|
+
### from_path
|
|
122
|
+
|
|
123
|
+
Load from file path:
|
|
124
|
+
|
|
125
|
+
[source,ruby]
|
|
126
|
+
----
|
|
127
|
+
eps = Vectory::Eps.from_path("diagram.eps")
|
|
128
|
+
----
|
|
129
|
+
|
|
130
|
+
### from_content
|
|
131
|
+
|
|
132
|
+
Load from content string:
|
|
133
|
+
|
|
134
|
+
[source,ruby]
|
|
135
|
+
----
|
|
136
|
+
content = File.read("diagram.eps")
|
|
137
|
+
eps = Vectory::Eps.from_content(content)
|
|
138
|
+
----
|
|
139
|
+
|
|
140
|
+
### from_datauri
|
|
141
|
+
|
|
142
|
+
Load from data URI:
|
|
143
|
+
|
|
144
|
+
[source,ruby]
|
|
145
|
+
----
|
|
146
|
+
uri = "data:image/svg+xml;base64,PHN2Zy..."
|
|
147
|
+
svg = Vectory::Svg.from_datauri(uri)
|
|
148
|
+
----
|
|
149
|
+
|
|
150
|
+
### from_node
|
|
151
|
+
|
|
152
|
+
Load from XML node (Metanorma integration):
|
|
153
|
+
|
|
154
|
+
[source,ruby]
|
|
155
|
+
----
|
|
156
|
+
# Used internally by Metanorma
|
|
157
|
+
svg = Vectory::Svg.from_node(xml_node)
|
|
158
|
+
----
|
|
159
|
+
|
|
160
|
+
## Conversion Methods
|
|
161
|
+
|
|
162
|
+
All format classes support conversion to any other format:
|
|
163
|
+
|
|
164
|
+
[source,ruby]
|
|
165
|
+
----
|
|
166
|
+
# Convert EPS to SVG
|
|
167
|
+
svg = Vectory::Eps.from_path("diagram.eps").to_svg
|
|
168
|
+
|
|
169
|
+
# Convert SVG to EPS
|
|
170
|
+
eps = Vectory::Svg.from_path("diagram.svg").to_eps
|
|
171
|
+
|
|
172
|
+
# Convert EMF to SVG
|
|
173
|
+
svg = Vectory::Emf.from_path("chart.emf").to_svg
|
|
174
|
+
----
|
|
175
|
+
|
|
176
|
+
## Properties
|
|
177
|
+
|
|
178
|
+
### content
|
|
179
|
+
|
|
180
|
+
Raw file content as string:
|
|
181
|
+
|
|
182
|
+
[source,ruby]
|
|
183
|
+
----
|
|
184
|
+
eps = Vectory::Eps.from_path("diagram.eps")
|
|
185
|
+
raw = eps.content
|
|
186
|
+
----
|
|
187
|
+
|
|
188
|
+
### initial_path
|
|
189
|
+
|
|
190
|
+
Original file location (read-only):
|
|
191
|
+
|
|
192
|
+
[source,ruby]
|
|
193
|
+
----
|
|
194
|
+
eps = Vectory::Eps.from_path("diagram.eps")
|
|
195
|
+
puts eps.initial_path # => "diagram.eps"
|
|
196
|
+
----
|
|
197
|
+
|
|
198
|
+
### path
|
|
199
|
+
|
|
200
|
+
Current file location (raises error if not written):
|
|
201
|
+
|
|
202
|
+
[source,ruby]
|
|
203
|
+
----
|
|
204
|
+
eps = Vectory::Eps.from_path("diagram.eps")
|
|
205
|
+
|
|
206
|
+
# WRONG: raises error
|
|
207
|
+
puts eps.path # => NotWrittenToDiskError
|
|
208
|
+
|
|
209
|
+
# CORRECT: write first
|
|
210
|
+
eps.write("output.eps")
|
|
211
|
+
puts eps.path # => "output.eps"
|
|
212
|
+
----
|
|
213
|
+
|
|
214
|
+
### dimensions
|
|
215
|
+
|
|
216
|
+
Image dimensions as [width, height]:
|
|
217
|
+
|
|
218
|
+
[source,ruby]
|
|
219
|
+
----
|
|
220
|
+
eps = Vectory::Eps.from_path("diagram.eps")
|
|
221
|
+
width, height = eps.dimensions
|
|
222
|
+
puts "Size: #{width}x#{height}"
|
|
223
|
+
----
|
|
224
|
+
|
|
225
|
+
## Methods
|
|
226
|
+
|
|
227
|
+
### write
|
|
228
|
+
|
|
229
|
+
Write image to file:
|
|
230
|
+
|
|
231
|
+
[source,ruby]
|
|
232
|
+
----
|
|
233
|
+
# Write to specific path
|
|
234
|
+
svg.write("output.svg")
|
|
235
|
+
|
|
236
|
+
# Write to temp directory
|
|
237
|
+
svg.write
|
|
238
|
+
----
|
|
239
|
+
|
|
240
|
+
Returns the path to the written file.
|
|
241
|
+
|
|
242
|
+
## Utility Classes
|
|
243
|
+
|
|
244
|
+
### Vectory::FileMagic
|
|
245
|
+
|
|
246
|
+
Format detection utilities:
|
|
247
|
+
|
|
248
|
+
[source,ruby]
|
|
249
|
+
----
|
|
250
|
+
# Detect format from content
|
|
251
|
+
content = File.read("unknown_file")
|
|
252
|
+
format = Vectory::FileMagic.detect_format(content)
|
|
253
|
+
|
|
254
|
+
# Format symbols: :eps, :ps, :emf, :svg, :unknown
|
|
255
|
+
----
|
|
256
|
+
|
|
257
|
+
### Vectory::InkscapeWrapper
|
|
258
|
+
|
|
259
|
+
Singleton wrapper for Inkscape:
|
|
260
|
+
|
|
261
|
+
[source,ruby]
|
|
262
|
+
----
|
|
263
|
+
inkscape = Vectory::InkscapeWrapper.instance
|
|
264
|
+
|
|
265
|
+
# Check availability
|
|
266
|
+
inkscape.available?
|
|
267
|
+
|
|
268
|
+
# Get version
|
|
269
|
+
inkscape.version
|
|
270
|
+
|
|
271
|
+
# Get executable path
|
|
272
|
+
inkscape.executable
|
|
273
|
+
|
|
274
|
+
# Check if modern version (1.x)
|
|
275
|
+
inkscape.modern?
|
|
276
|
+
----
|
|
277
|
+
|
|
278
|
+
### Vectory::GhostscriptWrapper
|
|
279
|
+
|
|
280
|
+
Singleton wrapper for Ghostscript:
|
|
281
|
+
|
|
282
|
+
[source,ruby]
|
|
283
|
+
----
|
|
284
|
+
gs = Vectory::GhostscriptWrapper.instance
|
|
285
|
+
|
|
286
|
+
# Check availability
|
|
287
|
+
gs.available?
|
|
288
|
+
|
|
289
|
+
# Get executable path
|
|
290
|
+
gs.executable
|
|
291
|
+
----
|
|
292
|
+
|
|
293
|
+
## Error Classes
|
|
294
|
+
|
|
295
|
+
[source,ruby]
|
|
296
|
+
----
|
|
297
|
+
Vectory::Error # Base error
|
|
298
|
+
├── SystemCallError # External tool failures
|
|
299
|
+
├── NotWrittenToDiskError # Path access before write
|
|
300
|
+
├── ParsingError # Content parsing failures
|
|
301
|
+
├── InkscapeNotFoundError # Inkscape unavailable
|
|
302
|
+
├── ConversionError # Conversion failures
|
|
303
|
+
└── InkscapeQueryError # Dimension query failures
|
|
304
|
+
----
|
|
305
|
+
|
|
306
|
+
## Usage Examples
|
|
307
|
+
|
|
308
|
+
=== Basic Conversion
|
|
309
|
+
|
|
310
|
+
[source,ruby]
|
|
311
|
+
----
|
|
312
|
+
require 'vectory'
|
|
313
|
+
|
|
314
|
+
# EPS to SVG
|
|
315
|
+
svg = Vectory::Eps.from_path("diagram.eps").to_svg
|
|
316
|
+
svg.write("diagram.svg")
|
|
317
|
+
----
|
|
318
|
+
|
|
319
|
+
=== Batch Processing
|
|
320
|
+
|
|
321
|
+
[source,ruby]
|
|
322
|
+
----
|
|
323
|
+
Dir["diagrams/*.eps"].each do |eps_file|
|
|
324
|
+
svg = Vectory::Eps.from_path(eps_file).to_svg
|
|
325
|
+
svg.write(eps_file.sub(".eps", ".svg"))
|
|
326
|
+
end
|
|
327
|
+
----
|
|
328
|
+
|
|
329
|
+
=== Error Handling
|
|
330
|
+
|
|
331
|
+
[source,ruby]
|
|
332
|
+
----
|
|
333
|
+
begin
|
|
334
|
+
svg = Vectory::Eps.from_path("diagram.eps").to_svg
|
|
335
|
+
rescue Vectory::InkscapeNotFoundError => e
|
|
336
|
+
puts "Inkscape not found: #{e.message}"
|
|
337
|
+
rescue Vectory::ConversionError => e
|
|
338
|
+
puts "Conversion failed: #{e.message}"
|
|
339
|
+
end
|
|
340
|
+
----
|
|
341
|
+
|
|
342
|
+
=== Dimension Query
|
|
343
|
+
|
|
344
|
+
[source,ruby]
|
|
345
|
+
----
|
|
346
|
+
eps = Vectory::Eps.from_path("diagram.eps")
|
|
347
|
+
width, height = eps.dimensions
|
|
348
|
+
puts "Dimensions: #{width}x#{height}"
|
|
349
|
+
----
|
|
350
|
+
|
|
351
|
+
## See Also
|
|
352
|
+
|
|
353
|
+
* link:../guides/error-handling/[Error Handling Guide] - Common errors and solutions
|
|
354
|
+
* link:../understanding/architecture/[Architecture] - Design patterns
|
|
355
|
+
* link:../features/conversion/[Conversion Features] - Conversion details
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Reference
|
|
4
|
+
nav_order: 7
|
|
5
|
+
has_children: true
|
|
6
|
+
---
|
|
7
|
+
= Reference
|
|
8
|
+
|
|
9
|
+
Complete API reference and technical documentation.
|
|
10
|
+
|
|
11
|
+
== Overview
|
|
12
|
+
|
|
13
|
+
This section provides comprehensive reference documentation for Vectory's public API, configuration options, and technical details.
|
|
14
|
+
|
|
15
|
+
== API Reference
|
|
16
|
+
|
|
17
|
+
link:api[**Public API**]::
|
|
18
|
+
Complete class and method reference.
|
|
19
|
+
+
|
|
20
|
+
`Vectory::Image`, `Vectory::Vector`, format-specific classes.
|
|
21
|
+
|
|
22
|
+
link:factory-methods[**Factory Methods**]::
|
|
23
|
+
Class methods for creating image objects.
|
|
24
|
+
+
|
|
25
|
+
`from_path`, `from_content`, `from_datauri`, `from_node`.
|
|
26
|
+
|
|
27
|
+
link:conversion-methods[**Conversion Methods**]::
|
|
28
|
+
Format conversion methods.
|
|
29
|
+
+
|
|
30
|
+
`to_eps`, `to_ps`, `to_emf`, `to_svg`, `to_pdf`.
|
|
31
|
+
|
|
32
|
+
== Configuration
|
|
33
|
+
|
|
34
|
+
link:environment-variables[**Environment Variables**]::
|
|
35
|
+
All configurable environment variables.
|
|
36
|
+
+
|
|
37
|
+
`VECTORY_LOG`, tool paths, timeout settings.
|
|
38
|
+
|
|
39
|
+
link:tool-configuration[**External Tool Configuration**]::
|
|
40
|
+
Inkscape and Ghostscript configuration.
|
|
41
|
+
+
|
|
42
|
+
Version requirements, path discovery, compatibility.
|
|
43
|
+
|
|
44
|
+
== Error Reference
|
|
45
|
+
|
|
46
|
+
link:error-classes[**Error Classes**]::
|
|
47
|
+
Complete exception hierarchy.
|
|
48
|
+
+
|
|
49
|
+
`Vectory::Error`, `SystemCallError`, `NotWrittenToDiskError`, etc.
|
|
50
|
+
|
|
51
|
+
link:error-messages[**Error Messages**]::
|
|
52
|
+
Common error messages and their causes.
|
|
53
|
+
+
|
|
54
|
+
Interpretation and resolution strategies.
|
|
55
|
+
|
|
56
|
+
== Format Reference
|
|
57
|
+
|
|
58
|
+
link:format-specs[**Format Specifications**]::
|
|
59
|
+
Technical details for each supported format.
|
|
60
|
+
+
|
|
61
|
+
EPS, PS, EMF, SVG, PDF specifications and limitations.
|
|
62
|
+
|
|
63
|
+
link:magic-numbers[**Magic Numbers**]::
|
|
64
|
+
File signatures used for format detection.
|
|
65
|
+
+
|
|
66
|
+
Byte patterns for EPS, PS, EMF identification.
|
|
67
|
+
|
|
68
|
+
== External Tools
|
|
69
|
+
|
|
70
|
+
link:inkscape[**Inkscape**]::
|
|
71
|
+
Inkscape requirements and compatibility.
|
|
72
|
+
+
|
|
73
|
+
Version differences, command-line options, known issues.
|
|
74
|
+
|
|
75
|
+
link:ghostscript[**Ghostscript**]::
|
|
76
|
+
Ghostscript requirements and usage.
|
|
77
|
+
+
|
|
78
|
+
EPS/PS to PDF conversion, bounding box handling.
|
|
79
|
+
|
|
80
|
+
link:emf2svg[**emf2svg**]::
|
|
81
|
+
emf2svg gem integration.
|
|
82
|
+
+
|
|
83
|
+
EMF format support and limitations.
|
|
84
|
+
|
|
85
|
+
== Platform Reference
|
|
86
|
+
|
|
87
|
+
link:windows[**Windows Platform**]::
|
|
88
|
+
Windows-specific behavior and requirements.
|
|
89
|
+
+
|
|
90
|
+
Path handling, process management, tool compatibility.
|
|
91
|
+
|
|
92
|
+
link:macos[**macOS Platform**]::
|
|
93
|
+
macOS-specific configuration.
|
|
94
|
+
+
|
|
95
|
+
Display environment, X11 requirements.
|
|
96
|
+
|
|
97
|
+
link:linux[**Linux Platform**]::
|
|
98
|
+
Linux-specific behavior.
|
|
99
|
+
+
|
|
100
|
+
Package requirements, tool availability.
|
|
101
|
+
|
|
102
|
+
== Quick Reference
|
|
103
|
+
|
|
104
|
+
=== Class Hierarchy
|
|
105
|
+
|
|
106
|
+
[source,text]
|
|
107
|
+
----
|
|
108
|
+
Vectory::Image (base class)
|
|
109
|
+
└── Vectory::Vector (abstract base)
|
|
110
|
+
├── Vectory::Eps
|
|
111
|
+
├── Vectory::Ps
|
|
112
|
+
├── Vectory::Emf
|
|
113
|
+
├── Vectory::Svg
|
|
114
|
+
└── Vectory::Pdf (intermediate format)
|
|
115
|
+
----
|
|
116
|
+
|
|
117
|
+
=== Factory Methods
|
|
118
|
+
|
|
119
|
+
All format classes support:
|
|
120
|
+
* `from_path(path)` - Load from file path
|
|
121
|
+
* `from_content(content)` - Load from content string
|
|
122
|
+
* `from_datauri(uri)` - Load from data URI
|
|
123
|
+
* `from_node(node)` - Load from XML node (Metanorma)
|
|
124
|
+
|
|
125
|
+
=== Conversion Methods
|
|
126
|
+
|
|
127
|
+
All format classes support:
|
|
128
|
+
* `to_eps` - Convert to EPS
|
|
129
|
+
* `to_ps` - Convert to PS
|
|
130
|
+
* `to_emf` - Convert to EMF
|
|
131
|
+
* `to_svg` - Convert to SVG
|
|
132
|
+
* `to_pdf` - Convert to PDF (intermediate)
|
|
133
|
+
|
|
134
|
+
=== Properties
|
|
135
|
+
|
|
136
|
+
* `content` - Raw file content (string)
|
|
137
|
+
* `path` - Current file location (raises error if not written)
|
|
138
|
+
* `initial_path` - Original file location
|
|
139
|
+
* `dimensions` - Array of [width, height]
|
|
140
|
+
* `write(path = nil)` - Write to file (temp directory if no path)
|
|
141
|
+
|
|
142
|
+
== Method Signatures
|
|
143
|
+
|
|
144
|
+
=== Vectory::Eps.from_path
|
|
145
|
+
|
|
146
|
+
[source,ruby]
|
|
147
|
+
----
|
|
148
|
+
def self.from_path(path)
|
|
149
|
+
# @param path [String] Path to EPS file
|
|
150
|
+
# @return [Vectory::Eps] EPS image object
|
|
151
|
+
end
|
|
152
|
+
----
|
|
153
|
+
|
|
154
|
+
=== Vectory::Eps#to_svg
|
|
155
|
+
|
|
156
|
+
[source,ruby]
|
|
157
|
+
----
|
|
158
|
+
def to_svg
|
|
159
|
+
# @return [Vectory::Svg] Converted SVG image
|
|
160
|
+
# @raise [Vectory::ConversionError] If conversion fails
|
|
161
|
+
end
|
|
162
|
+
----
|
|
163
|
+
|
|
164
|
+
=== Vectory::Eps#dimensions
|
|
165
|
+
|
|
166
|
+
[source,ruby]
|
|
167
|
+
----
|
|
168
|
+
def dimensions
|
|
169
|
+
# @return [Array<Integer>] [width, height] in points
|
|
170
|
+
# @raise [Vectory::InkscapeQueryError] If query fails
|
|
171
|
+
end
|
|
172
|
+
----
|
|
173
|
+
|
|
174
|
+
=== Vectory::Eps#write
|
|
175
|
+
|
|
176
|
+
[source,ruby]
|
|
177
|
+
----
|
|
178
|
+
def write(path = nil)
|
|
179
|
+
# @param path [String, nil] Output path (uses temp if nil)
|
|
180
|
+
# @return [String] Path to written file
|
|
181
|
+
# @raise [Vectory::SystemCallError] If write fails
|
|
182
|
+
end
|
|
183
|
+
----
|
|
184
|
+
|
|
185
|
+
== See Also
|
|
186
|
+
|
|
187
|
+
* link:../features/[Features] - Feature documentation
|
|
188
|
+
* link:../guides/[Guides] - How-to guides
|
|
189
|
+
* link:../understanding/[Understanding] - Internal architecture
|