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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +59 -0
  3. data/.github/workflows/links.yml +99 -0
  4. data/.github/workflows/rake.yml +5 -1
  5. data/.github/workflows/release.yml +7 -3
  6. data/.gitignore +5 -0
  7. data/.rubocop.yml +11 -3
  8. data/.rubocop_todo.yml +252 -0
  9. data/Gemfile +4 -2
  10. data/README.adoc +23 -1
  11. data/Rakefile +13 -0
  12. data/docs/Gemfile +18 -0
  13. data/docs/_config.yml +179 -0
  14. data/docs/features/conversion.adoc +205 -0
  15. data/docs/features/external-dependencies.adoc +305 -0
  16. data/docs/features/format-detection.adoc +173 -0
  17. data/docs/features/index.adoc +205 -0
  18. data/docs/getting-started/core-concepts.adoc +214 -0
  19. data/docs/getting-started/index.adoc +37 -0
  20. data/docs/getting-started/installation.adoc +318 -0
  21. data/docs/getting-started/quick-start.adoc +160 -0
  22. data/docs/guides/error-handling.adoc +400 -0
  23. data/docs/guides/index.adoc +197 -0
  24. data/docs/index.adoc +146 -0
  25. data/docs/lychee.toml +25 -0
  26. data/docs/reference/api.adoc +355 -0
  27. data/docs/reference/index.adoc +189 -0
  28. data/docs/understanding/architecture.adoc +277 -0
  29. data/docs/understanding/index.adoc +148 -0
  30. data/docs/understanding/inkscape-wrapper.adoc +270 -0
  31. data/lib/vectory/capture.rb +165 -37
  32. data/lib/vectory/cli.rb +2 -0
  33. data/lib/vectory/configuration.rb +177 -0
  34. data/lib/vectory/conversion/ghostscript_strategy.rb +77 -0
  35. data/lib/vectory/conversion/inkscape_strategy.rb +124 -0
  36. data/lib/vectory/conversion/strategy.rb +58 -0
  37. data/lib/vectory/conversion.rb +104 -0
  38. data/lib/vectory/datauri.rb +1 -1
  39. data/lib/vectory/emf.rb +17 -5
  40. data/lib/vectory/eps.rb +45 -3
  41. data/lib/vectory/errors.rb +25 -0
  42. data/lib/vectory/file_magic.rb +2 -2
  43. data/lib/vectory/ghostscript_wrapper.rb +160 -0
  44. data/lib/vectory/image_resize.rb +2 -2
  45. data/lib/vectory/inkscape_wrapper.rb +205 -0
  46. data/lib/vectory/pdf.rb +76 -0
  47. data/lib/vectory/platform.rb +105 -0
  48. data/lib/vectory/ps.rb +47 -3
  49. data/lib/vectory/svg.rb +46 -3
  50. data/lib/vectory/svg_document.rb +40 -24
  51. data/lib/vectory/system_call.rb +36 -9
  52. data/lib/vectory/vector.rb +3 -23
  53. data/lib/vectory/version.rb +1 -1
  54. data/lib/vectory.rb +16 -11
  55. metadata +34 -3
  56. data/lib/vectory/inkscape_converter.rb +0 -141
@@ -0,0 +1,318 @@
1
+ ---
2
+ layout: default
3
+ title: Installation
4
+ parent: Getting Started
5
+ nav_order: 2
6
+ ---
7
+
8
+ Install and configure Vectory on your system.
9
+
10
+ == Purpose
11
+
12
+ This guide covers installing Vectory and its external dependencies on different platforms. Vectory leverages several external tools for vector image conversion:
13
+
14
+ * **Inkscape** - Primary conversion tool for most format conversions
15
+ * **Ghostscript** - EPS/PS to PDF conversion with bounding box preservation
16
+ * **emf2svg** (gem) - EMF format support
17
+
18
+ == Installing the Gem
19
+
20
+ Add Vectory to your Gemfile:
21
+
22
+ [source,ruby]
23
+ ----
24
+ gem 'vectory'
25
+ ----
26
+
27
+ Then run:
28
+
29
+ [source,shell]
30
+ ----
31
+ bundle install
32
+ ----
33
+
34
+ Or install the gem directly:
35
+
36
+ [source,shell]
37
+ ----
38
+ gem install vectory
39
+ ----
40
+
41
+ == External Dependencies Overview
42
+
43
+ Vectory requires external tools for vector image conversion. These tools are invoked by Vectory to perform the actual conversion operations.
44
+
45
+ === Tool Matrix
46
+
47
+ [cols="1,2a,2a"]
48
+ |===
49
+ |Tool|Purpose|Required For
50
+
51
+ |**Inkscape**
52
+ |Vector graphics editor with CLI interface
53
+ |SVG ↔ EPS/PS/EMF/PDF conversions, dimension queries
54
+
55
+ |**Ghostscript**
56
+ |PostScript and PDF interpreter
57
+ |EPS/PS → PDF conversion (bounding box preservation)
58
+
59
+ |**emf2svg**
60
+ |EMF to SVG converter (Ruby gem)
61
+ |EMF → SVG conversion
62
+
63
+ |**moxml**
64
+ |XML/HTML parser (Ruby gem)
65
+ |Metanorma SVG mapping (link rewriting, ID preservation)
66
+ |===
67
+
68
+ === Inkscape
69
+
70
+ Inkscape is the primary conversion tool used by Vectory. It handles:
71
+
72
+ * **SVG → EPS/PS/EMF/PDF**: Direct export to various vector formats
73
+ * **EPS/PS/EMF/PDF → SVG**: Import and convert to SVG format
74
+ * **Dimension queries**: Query image dimensions without full rendering
75
+ * **High-quality output**: Professional-grade vector conversion
76
+
77
+ ==== Version Requirements
78
+
79
+ [cols="1,2a"]
80
+ |===
81
+ |Version|Notes
82
+
83
+ |**1.0+ (recommended)**
84
+ |Best compatibility and performance
85
+
86
+ |**0.92+**
87
+ |Minimum supported version
88
+
89
+ |**1.3.0 (Windows)**
90
+ |Use this version on Windows (1.3.1+ has EPS/PS issues)
91
+
92
+ |**1.3.1+ (avoid on Windows)**
93
+ |Known issues with EPS/PS conversion on Windows
94
+ |===
95
+
96
+ ==== Installation
97
+
98
+ * **macOS**: `brew install --cask inkscape`
99
+ * **Ubuntu/Debian**: `sudo apt install inkscape`
100
+ * **Windows**: Download from https://inkscape.org/release/
101
+ * **Fedora**: `sudo dnf install inkscape`
102
+ * **Arch Linux**: `sudo pacman -S inkscape`
103
+
104
+ ==== Verification
105
+
106
+ [source,shell]
107
+ ----
108
+ inkscape --version
109
+ # Inkscape 1.3.0 (or similar)
110
+ ----
111
+
112
+ === Ghostscript
113
+
114
+ Ghostscript is required for EPS and PS format support. It handles:
115
+
116
+ * **EPS/PS → PDF**: Converts PostScript to PDF with bounding box preservation
117
+ * **BoundingBox handling**: Maintains exact dimensions from EPS/PS files
118
+ * **Font embedding**: Preserves fonts during conversion
119
+ * **Intermediate format**: Creates PDF as intermediate step for EPS/PS → SVG
120
+
121
+ ==== Version Requirements
122
+
123
+ * **Version 9.0 or later** recommended
124
+ * Versions 8.x may work but have limited features
125
+ * Must be in system PATH or configured via `GHOSTSCRIPT_PATH`
126
+
127
+ ==== Installation
128
+
129
+ * **macOS**: `brew install ghostscript`
130
+ * **Ubuntu/Debian**: `sudo apt install ghostscript`
131
+ * **Windows**: Download from https://www.ghostscript.com/download/gsdnld.html
132
+ * **Fedora**: `sudo dnf install ghostscript`
133
+ * **Arch Linux**: `sudo pacman -S ghostscript`
134
+
135
+ ==== Verification
136
+
137
+ [source,shell]
138
+ ----
139
+ gs --version
140
+ # 10.02.0 (or similar)
141
+ ----
142
+
143
+ === emf2svg (Ruby Gem)
144
+
145
+ The `emf2svg` gem is automatically installed with Vectory. It handles:
146
+
147
+ * **EMF → SVG**: Converts Windows Enhanced Metafile format to SVG
148
+ * **Windows format support**: Provides EMF format support on all platforms
149
+ * **Native conversion**: No external tool dependency for EMF
150
+
151
+ This gem is installed automatically as a dependency of Vectory.
152
+
153
+ === moxml (Ruby Gem)
154
+
155
+ The `moxml` gem is used for Metanorma integration. It handles:
156
+
157
+ * **XML parsing**: Parse XML/HTML documents for SVG mapping
158
+ * **Link rewriting**: Rewrite internal SVG links for embedded use
159
+ * **ID preservation**: Maintain unique IDs when embedding SVGs
160
+
161
+ This gem is installed automatically as a dependency of Vectory.
162
+
163
+ == Verifying Installation
164
+
165
+ Test that Vectory can find the required tools:
166
+
167
+ [source,ruby]
168
+ ----
169
+ require 'vectory'
170
+
171
+ # Check Inkscape availability
172
+ inkscape = Vectory::InkscapeWrapper.instance
173
+ puts "Inkscape found: #{inkscape.executable}"
174
+ puts "Inkscape version: #{inkscape.version}"
175
+
176
+ # Check Ghostscript availability
177
+ gs = Vectory::GhostscriptWrapper.instance
178
+ puts "Ghostscript found: #{gs.executable}"
179
+ ----
180
+
181
+ == Platform-Specific Notes
182
+
183
+ === macOS
184
+
185
+ Inkscape may require X11 on older versions. On macOS Catalina and later, Inkscape runs without X11 but may timeout during conversions.
186
+
187
+ To prevent timeouts, Vectory automatically sets `DISPLAY=""` on macOS for headless operation.
188
+
189
+ [cols="1,2a"]
190
+ |===
191
+ |Tool|macOS Notes
192
+
193
+ |Inkscape
194
+ |Install via Homebrew; timeout prevention via `DISPLAY=""`
195
+
196
+ |Ghostscript
197
+ |Install via Homebrew; standard Unix behavior
198
+
199
+ |emf2svg gem
200
+ |Works natively on macOS
201
+ |===
202
+
203
+ === Windows
204
+
205
+ Windows has specific considerations for external tools:
206
+
207
+ * Ensure Inkscape and Ghostscript are in your PATH
208
+ * Use Inkscape 1.3.0 for EPS/PS conversion (1.3.1+ has known issues)
209
+ * Process management differs from Unix platforms (taskkill vs Process.kill)
210
+ * Temp file handling uses Windows temp directory
211
+
212
+ [cols="1,2a"]
213
+ |===
214
+ |Tool|Windows Notes
215
+
216
+ |Inkscape
217
+ |Install from installer or MSYS2; version 1.3.0 recommended for EPS/PS
218
+
219
+ |Ghostscript
220
+ |Install from 32-bit or 64-bit installer; must be in PATH
221
+
222
+ |emf2svg gem
223
+ |Works natively on Windows
224
+ |===
225
+
226
+ === Linux
227
+
228
+ Standard Unix behavior applies on Linux distributions.
229
+
230
+ [cols="1,2a"]
231
+ |===
232
+ |Tool|Linux Notes
233
+
234
+ |Inkscape
235
+ |Available in all major distributions; ensure X11 libraries
236
+
237
+ |Ghostscript
238
+ |Standard package; may need `gsfonts` for full functionality
239
+
240
+ |emf2svg gem
241
+ |Works natively on Linux
242
+ |===
243
+
244
+ === CI/CD Environments
245
+
246
+ For GitHub Actions, GitLab CI, or similar:
247
+
248
+ * Install Inkscape and Ghostscript in your workflow
249
+ * Set `DISPLAY=""` for headless environments
250
+ * Consider caching tool installations for faster builds
251
+
252
+ Example GitHub Actions setup:
253
+
254
+ [source,yaml]
255
+ ----
256
+ - name: Install dependencies
257
+ run: |
258
+ sudo apt-get update
259
+ sudo apt-get install -y inkscape ghostscript
260
+ env:
261
+ DISPLAY: ""
262
+ ----
263
+
264
+ == Configuration
265
+
266
+ Vectory can be configured via environment variables:
267
+
268
+ [cols="1,2a"]
269
+ |===
270
+ |Variable|Description
271
+
272
+ |`VECTORY_LOG`
273
+ |Enable debug logging (set to `1` or `true`)
274
+
275
+ |`INKSCAPE_PATH`
276
+ |Custom path to Inkscape executable
277
+
278
+ |`GHOSTSCRIPT_PATH`
279
+ |Custom path to Ghostscript executable
280
+ |===
281
+
282
+ == Troubleshooting
283
+
284
+ === Inkscape Not Found
285
+
286
+ [source,ruby]
287
+ ----
288
+ Vectory::InkscapeNotFoundError: Inkscape not found in PATH
289
+ ----
290
+
291
+ **Solution**: Install Inkscape or set `INKSCAPE_PATH` environment variable.
292
+
293
+ === Conversion Timeout
294
+
295
+ [source,ruby]
296
+ ----
297
+ Vectory::SystemCallError: Command timed out: inkscape
298
+ ----
299
+
300
+ **Solution**:
301
+ * Check if input file is valid
302
+ * Verify Inkscape version compatibility
303
+ * Increase timeout (default is 60 seconds)
304
+
305
+ === Ghostscript Errors
306
+
307
+ [source,ruby]
308
+ ----
309
+ Vectory::SystemCallError: Ghostscript conversion failed
310
+ ----
311
+
312
+ **Solution**: Install Ghostscript or check input EPS/PS file validity.
313
+
314
+ == Next Steps
315
+
316
+ After installation, try the link:quick-start[Quick Start] guide to learn basic conversions.
317
+
318
+ See link:../reference/environment-variables[Environment Variables] for complete configuration options.
@@ -0,0 +1,160 @@
1
+ ---
2
+ layout: default
3
+ title: Quick Start
4
+ parent: Getting Started
5
+ nav_order: 1
6
+ ---
7
+
8
+ Learn the basics of Vectory with simple examples.
9
+
10
+ == Purpose
11
+
12
+ This guide introduces Vectory's core functionality through practical examples. After completing this guide, you will be able to convert vector images between different formats and query image dimensions.
13
+
14
+ == Installation
15
+
16
+ Add Vectory to your Gemfile:
17
+
18
+ [source,ruby]
19
+ ----
20
+ gem 'vectory'
21
+ ----
22
+
23
+ Or install it yourself:
24
+
25
+ [source,shell]
26
+ ----
27
+ gem install vectory
28
+ ----
29
+
30
+ Ensure you have https://inkscape.org/[Inkscape] and https://www.ghostscript.com/[Ghostscript] installed on your system.
31
+
32
+ == Basic Conversion
33
+
34
+ === Converting EPS to SVG
35
+
36
+ The most common use case is converting EPS files to SVG:
37
+
38
+ [source,ruby]
39
+ ----
40
+ require 'vectory'
41
+
42
+ # Load an EPS file
43
+ eps = Vectory::Eps.from_path("diagram.eps")
44
+
45
+ # Convert to SVG
46
+ svg = eps.to_svg
47
+
48
+ # Write to file
49
+ svg.write("diagram.svg")
50
+ ----
51
+
52
+ === Converting SVG to EPS
53
+
54
+ Convert SVG files back to EPS:
55
+
56
+ [source,ruby]
57
+ ----
58
+ require 'vectory'
59
+
60
+ # Load an SVG file
61
+ svg = Vectory::Svg.from_path("drawing.svg")
62
+
63
+ # Convert to EPS
64
+ eps = svg.to_eps
65
+
66
+ # Write to file
67
+ eps.write("drawing.eps")
68
+ ----
69
+
70
+ == Format Detection
71
+
72
+ Vectory can automatically detect file formats from content:
73
+
74
+ [source,ruby]
75
+ ----
76
+ require 'vectory'
77
+
78
+ # Detect format from file
79
+ image = Vectory::Image.from_path("unknown_file")
80
+ puts image.class # => Vectory::Eps, Vectory::Svg, etc.
81
+
82
+ # Or detect from content string
83
+ content = File.read("unknown_file")
84
+ format = Vectory::FileMagic.detect_format(content)
85
+ puts format # => :eps, :ps, :emf, :svg, or :unknown
86
+ ----
87
+
88
+ == Querying Dimensions
89
+
90
+ Get image dimensions without full conversion:
91
+
92
+ [source,ruby]
93
+ ----
94
+ require 'vectory'
95
+
96
+ eps = Vectory::Eps.from_path("diagram.eps")
97
+ width, height = eps.dimensions
98
+
99
+ puts "Width: #{width} points"
100
+ puts "Height: #{height} points"
101
+ ----
102
+
103
+ == Working with Content
104
+
105
+ Load images from content strings instead of files:
106
+
107
+ [source,ruby]
108
+ ----
109
+ require 'vectory'
110
+
111
+ # Load from content string
112
+ eps_content = File.read("diagram.eps")
113
+ eps = Vectory::Eps.from_content(eps_content)
114
+
115
+ # Convert and get content
116
+ svg = eps.to_svg
117
+ svg_content = svg.content
118
+
119
+ # Write to file later
120
+ svg.write("diagram.svg")
121
+ ----
122
+
123
+ == Error Handling
124
+
125
+ Handle common errors gracefully:
126
+
127
+ [source,ruby]
128
+ ----
129
+ require 'vectory'
130
+
131
+ begin
132
+ svg = Vectory::Eps.from_path("diagram.eps").to_svg
133
+ svg.write("diagram.svg")
134
+ rescue Vectory::InkscapeNotFoundError => e
135
+ puts "Inkscape not found: #{e.message}"
136
+ puts "Please install Inkscape"
137
+ rescue Vectory::ConversionError => e
138
+ puts "Conversion failed: #{e.message}"
139
+ rescue Vectory::Error => e
140
+ puts "Vectory error: #{e.message}"
141
+ end
142
+ ----
143
+
144
+ == Supported Conversions
145
+
146
+ Vectory supports pairwise conversion between:
147
+
148
+ * **EPS** (Encapsulated PostScript)
149
+ * **PS** (PostScript)
150
+ * **EMF** (Enhanced Metafile)
151
+ * **SVG** (Scalable Vector Graphics)
152
+ * **PDF** (intermediate format)
153
+
154
+ See link:../features/conversion/[Conversion Features] for complete conversion paths.
155
+
156
+ == Next Steps
157
+
158
+ . Read link:core-concepts[Core Concepts] to understand Vectory's architecture
159
+ . Explore link:../guides/[Guides] for specific use cases
160
+ . Check link:../reference/api[API Reference] for complete documentation