ukiryu 0.1.1 → 0.1.3
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/release.yml +58 -14
- data/.gitignore +3 -0
- data/.rubocop_todo.yml +170 -79
- data/Gemfile +1 -1
- data/README.adoc +1603 -576
- data/docs/.gitignore +1 -0
- data/docs/Gemfile +10 -0
- data/docs/INDEX.adoc +261 -0
- data/docs/_config.yml +180 -0
- data/docs/advanced/custom-tool-classes.adoc +581 -0
- data/docs/advanced/index.adoc +20 -0
- data/docs/features/configuration.adoc +657 -0
- data/docs/features/index.adoc +31 -0
- data/docs/features/platform-support.adoc +488 -0
- data/docs/getting-started/core-concepts.adoc +666 -0
- data/docs/getting-started/index.adoc +36 -0
- data/docs/getting-started/installation.adoc +216 -0
- data/docs/getting-started/quick-start.adoc +258 -0
- data/docs/guides/env-var-sets.adoc +388 -0
- data/docs/guides/index.adoc +20 -0
- data/docs/interfaces/cli.adoc +609 -0
- data/docs/interfaces/index.adoc +153 -0
- data/docs/interfaces/ruby-api.adoc +538 -0
- data/docs/lychee.toml +49 -0
- data/docs/reference/configuration-options.adoc +720 -0
- data/docs/reference/error-codes.adoc +634 -0
- data/docs/reference/index.adoc +20 -0
- data/docs/reference/ruby-api.adoc +1217 -0
- data/docs/understanding/index.adoc +20 -0
- data/lib/ukiryu/cli.rb +43 -58
- data/lib/ukiryu/cli_commands/base_command.rb +16 -27
- data/lib/ukiryu/cli_commands/cache_command.rb +100 -0
- data/lib/ukiryu/cli_commands/commands_command.rb +8 -8
- data/lib/ukiryu/cli_commands/commands_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/config_command.rb +49 -7
- data/lib/ukiryu/cli_commands/definitions_command.rb +254 -0
- data/lib/ukiryu/cli_commands/describe_command.rb +13 -7
- data/lib/ukiryu/cli_commands/describe_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/docs_command.rb +148 -0
- data/lib/ukiryu/cli_commands/exec_inline_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/extract_command.rb +2 -2
- data/lib/ukiryu/cli_commands/info_command.rb +7 -7
- data/lib/ukiryu/cli_commands/lint_command.rb +167 -0
- data/lib/ukiryu/cli_commands/list_command.rb +6 -6
- data/lib/ukiryu/cli_commands/opts_command.rb +2 -2
- data/lib/ukiryu/cli_commands/opts_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/register_command.rb +144 -0
- data/lib/ukiryu/cli_commands/resolve_command.rb +124 -0
- data/lib/ukiryu/cli_commands/run_command.rb +38 -14
- data/lib/ukiryu/cli_commands/run_file_command.rb +2 -2
- data/lib/ukiryu/cli_commands/system_command.rb +50 -32
- data/lib/ukiryu/cli_commands/validate_command.rb +452 -51
- data/lib/ukiryu/cli_commands/which_command.rb +5 -5
- data/lib/ukiryu/command_builder.rb +81 -23
- data/lib/ukiryu/config/env_provider.rb +3 -3
- data/lib/ukiryu/config/env_schema.rb +6 -6
- data/lib/ukiryu/config.rb +11 -11
- data/lib/ukiryu/definition/definition_cache.rb +238 -0
- data/lib/ukiryu/definition/definition_composer.rb +257 -0
- data/lib/ukiryu/definition/definition_linter.rb +460 -0
- data/lib/ukiryu/definition/definition_validator.rb +320 -0
- data/lib/ukiryu/definition/discovery.rb +239 -0
- data/lib/ukiryu/definition/documentation_generator.rb +429 -0
- data/lib/ukiryu/definition/lint_issue.rb +168 -0
- data/lib/ukiryu/definition/loader.rb +139 -0
- data/lib/ukiryu/definition/metadata.rb +159 -0
- data/lib/ukiryu/definition/source.rb +87 -0
- data/lib/ukiryu/definition/sources/file.rb +138 -0
- data/lib/ukiryu/definition/sources/string.rb +88 -0
- data/lib/ukiryu/definition/validation_result.rb +158 -0
- data/lib/ukiryu/definition/version_resolver.rb +194 -0
- data/lib/ukiryu/definition.rb +40 -0
- data/lib/ukiryu/errors.rb +6 -0
- data/lib/ukiryu/execution_context.rb +11 -11
- data/lib/ukiryu/executor.rb +6 -0
- data/lib/ukiryu/extractors/extractor.rb +6 -5
- data/lib/ukiryu/extractors/help_parser.rb +13 -19
- data/lib/ukiryu/logger.rb +3 -1
- data/lib/ukiryu/models/command_definition.rb +3 -3
- data/lib/ukiryu/models/command_info.rb +1 -1
- data/lib/ukiryu/models/components.rb +1 -3
- data/lib/ukiryu/models/env_var_definition.rb +11 -3
- data/lib/ukiryu/models/flag_definition.rb +15 -0
- data/lib/ukiryu/models/option_definition.rb +7 -7
- data/lib/ukiryu/models/platform_profile.rb +6 -3
- data/lib/ukiryu/models/routing.rb +1 -1
- data/lib/ukiryu/models/tool_definition.rb +2 -4
- data/lib/ukiryu/models/tool_metadata.rb +6 -6
- data/lib/ukiryu/models/validation_result.rb +1 -1
- data/lib/ukiryu/models/version_compatibility.rb +6 -3
- data/lib/ukiryu/models/version_detection.rb +10 -1
- data/lib/ukiryu/{registry.rb → register.rb} +54 -38
- data/lib/ukiryu/register_auto_manager.rb +268 -0
- data/lib/ukiryu/schema_validator.rb +31 -10
- data/lib/ukiryu/shell/base.rb +18 -0
- data/lib/ukiryu/shell/bash.rb +19 -1
- data/lib/ukiryu/shell/cmd.rb +11 -1
- data/lib/ukiryu/shell/powershell.rb +11 -1
- data/lib/ukiryu/shell.rb +1 -1
- data/lib/ukiryu/tool.rb +107 -95
- data/lib/ukiryu/tool_index.rb +22 -22
- data/lib/ukiryu/tools/base.rb +12 -25
- data/lib/ukiryu/tools/generator.rb +7 -7
- data/lib/ukiryu/tools.rb +3 -3
- data/lib/ukiryu/type.rb +20 -5
- data/lib/ukiryu/version.rb +1 -1
- data/lib/ukiryu/version_detector.rb +21 -2
- data/lib/ukiryu.rb +6 -3
- data/ukiryu-proposal.md +41 -41
- data/ukiryu.gemspec +1 -0
- metadata +64 -8
- data/.gitmodules +0 -3
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Platform Support
|
|
4
|
+
parent: Features
|
|
5
|
+
nav_order: 3
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
== Platform Support
|
|
9
|
+
|
|
10
|
+
Ukiryu provides seamless cross-platform support for macOS, Linux, and Windows with automatic platform detection and adaptation.
|
|
11
|
+
|
|
12
|
+
// Purpose
|
|
13
|
+
== Purpose
|
|
14
|
+
|
|
15
|
+
This page documents Ukiryu's platform support, including automatic detection, shell adaptation, and platform-specific behaviors.
|
|
16
|
+
|
|
17
|
+
// References
|
|
18
|
+
== References
|
|
19
|
+
|
|
20
|
+
* link:/understanding/platform-detection[Platform Detection Internals]
|
|
21
|
+
* link:/understanding/shell-adaptation[Shell Adaptation Internals]
|
|
22
|
+
* link:/advanced/writing-profiles[Writing Platform-Specific Profiles]
|
|
23
|
+
|
|
24
|
+
// Concepts
|
|
25
|
+
== Concepts
|
|
26
|
+
|
|
27
|
+
* **Platform detection**: Automatic identification of macOS, Linux, or Windows
|
|
28
|
+
* **Shell detection**: Automatic identification of bash, zsh, fish, PowerShell, or cmd
|
|
29
|
+
* **Path formatting**: Platform-specific path separators and styles
|
|
30
|
+
* **Executable discovery**: Searching platform-specific locations for tools
|
|
31
|
+
|
|
32
|
+
// Supported Platforms
|
|
33
|
+
== Supported Platforms
|
|
34
|
+
|
|
35
|
+
=== macOS
|
|
36
|
+
|
|
37
|
+
[source]
|
|
38
|
+
----
|
|
39
|
+
Platform: macOS
|
|
40
|
+
Detection: RbConfig::CONFIG['host_os'] =~ /darwin/
|
|
41
|
+
Shells: bash, zsh, fish, sh
|
|
42
|
+
Package Managers: Homebrew, MacPorts, AppImage
|
|
43
|
+
Display: Quartz (native), X11
|
|
44
|
+
----
|
|
45
|
+
|
|
46
|
+
Features:
|
|
47
|
+
* **Homebrew support**: `/opt/homebrew/bin/*`
|
|
48
|
+
* **MacPorts support**: `/opt/local/bin/*`
|
|
49
|
+
* **Application bundles**: `/Applications/*.app/Contents/MacOS/*`
|
|
50
|
+
* **Headless mode**: Removes DISPLAY, sets GUI prevention variables
|
|
51
|
+
|
|
52
|
+
=== Linux
|
|
53
|
+
|
|
54
|
+
[source]
|
|
55
|
+
----
|
|
56
|
+
Platform: Linux
|
|
57
|
+
Detection: RbConfig::CONFIG['host_os'] =~ /linux/
|
|
58
|
+
Shells: bash, zsh, fish, sh
|
|
59
|
+
Package Managers: apt, yum, dnf, zypper, pacman, snap, flatpak
|
|
60
|
+
Display: X11
|
|
61
|
+
----
|
|
62
|
+
|
|
63
|
+
Features:
|
|
64
|
+
* **System paths**: `/usr/bin/*`, `/usr/local/bin/*`
|
|
65
|
+
* **Snap packages**: `/snap/bin/*`
|
|
66
|
+
* **Flatpak**: `/var/lib/flatpak/exports/bin/*`
|
|
67
|
+
* **AppImages**: `/opt/*AppImage`
|
|
68
|
+
|
|
69
|
+
=== Windows
|
|
70
|
+
|
|
71
|
+
[source]
|
|
72
|
+
----
|
|
73
|
+
Platform: Windows
|
|
74
|
+
Detection: RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
|
75
|
+
Shells: PowerShell, cmd
|
|
76
|
+
Package Managers: Scoop, Chocolatey
|
|
77
|
+
Display: Windows GUI
|
|
78
|
+
----
|
|
79
|
+
|
|
80
|
+
Features:
|
|
81
|
+
* **Program Files**: `C:/Program Files/*/` and `C:/Program Files (x86)/*/`
|
|
82
|
+
* **User profiles**: `%USERPROFILE%`, `%LOCALAPPDATA%`
|
|
83
|
+
* **Scoop packages**: `%USERPROFILE%/scoop/apps/*/`
|
|
84
|
+
* **Chocolatey**: `C:/ProgramData/chocolatey/lib/*/`
|
|
85
|
+
|
|
86
|
+
// Path Handling
|
|
87
|
+
== Path Handling
|
|
88
|
+
|
|
89
|
+
Ukiryu automatically handles path differences between platforms.
|
|
90
|
+
|
|
91
|
+
=== Path Separators
|
|
92
|
+
|
|
93
|
+
[source,ruby]
|
|
94
|
+
----
|
|
95
|
+
# Define paths using Unix-style (forward slashes)
|
|
96
|
+
result = tool.execute(:export, {
|
|
97
|
+
inputs: ['/path/to/drawing.svg'],
|
|
98
|
+
output: '/path/to/drawing.png'
|
|
99
|
+
})
|
|
100
|
+
----
|
|
101
|
+
|
|
102
|
+
**On macOS/Linux**:
|
|
103
|
+
[source]
|
|
104
|
+
----
|
|
105
|
+
/path/to/drawing.svg
|
|
106
|
+
----
|
|
107
|
+
|
|
108
|
+
**On Windows** (automatically converted):
|
|
109
|
+
[source]
|
|
110
|
+
----
|
|
111
|
+
C:\path\to\drawing.svg
|
|
112
|
+
----
|
|
113
|
+
|
|
114
|
+
=== Home Directory
|
|
115
|
+
|
|
116
|
+
[source,ruby]
|
|
117
|
+
----
|
|
118
|
+
# Tilde expansion works on all platforms
|
|
119
|
+
result = tool.execute(:export, {
|
|
120
|
+
inputs: ['~/drawing.svg'],
|
|
121
|
+
output: '~/drawing.png'
|
|
122
|
+
})
|
|
123
|
+
----
|
|
124
|
+
|
|
125
|
+
**On macOS/Linux**:
|
|
126
|
+
[source]
|
|
127
|
+
----
|
|
128
|
+
/home/user/drawing.svg
|
|
129
|
+
----
|
|
130
|
+
|
|
131
|
+
**On Windows**:
|
|
132
|
+
[source]
|
|
133
|
+
----
|
|
134
|
+
C:\Users\user\drawing.svg
|
|
135
|
+
----
|
|
136
|
+
|
|
137
|
+
=== Environment Variables
|
|
138
|
+
|
|
139
|
+
[source,ruby]
|
|
140
|
+
----
|
|
141
|
+
# Environment variables are expanded on all platforms
|
|
142
|
+
ENV['MY_PATH'] = '/path/to/files'
|
|
143
|
+
|
|
144
|
+
result = tool.execute(:export, {
|
|
145
|
+
inputs: ['${MY_PATH}/drawing.svg']
|
|
146
|
+
})
|
|
147
|
+
----
|
|
148
|
+
|
|
149
|
+
// Shell Adaptation
|
|
150
|
+
== Shell Adaptation
|
|
151
|
+
|
|
152
|
+
Ukiryu automatically adapts to your shell for proper quoting and escaping.
|
|
153
|
+
|
|
154
|
+
=== Supported Shells
|
|
155
|
+
|
|
156
|
+
[cols="1,1,2"]
|
|
157
|
+
|===
|
|
158
|
+
|Shell |Platform |Quoting Style
|
|
159
|
+
|
|
160
|
+
|bash
|
|
161
|
+
|macOS, Linux
|
|
162
|
+
|Single quotes: `'file name.svg'`
|
|
163
|
+
|
|
164
|
+
|zsh
|
|
165
|
+
|macOS, Linux
|
|
166
|
+
|Single quotes: `'file name.svg'`
|
|
167
|
+
|
|
168
|
+
|fish
|
|
169
|
+
|macOS, Linux
|
|
170
|
+
|Single quotes: `'file name.svg'`
|
|
171
|
+
|
|
172
|
+
|PowerShell
|
|
173
|
+
|Windows
|
|
174
|
+
|Single quotes: `'file name.svg'`
|
|
175
|
+
|
|
176
|
+
|cmd
|
|
177
|
+
|Windows
|
|
178
|
+
|Double quotes: `"file name.svg"`
|
|
179
|
+
|===
|
|
180
|
+
|
|
181
|
+
=== Quoting Examples
|
|
182
|
+
|
|
183
|
+
[source,ruby]
|
|
184
|
+
----
|
|
185
|
+
# Same code works on all shells
|
|
186
|
+
result = tool.execute(:export, {
|
|
187
|
+
inputs: ['My Document.svg'], # Space in name
|
|
188
|
+
output: 'output.png'
|
|
189
|
+
})
|
|
190
|
+
----
|
|
191
|
+
|
|
192
|
+
**Generated commands**:
|
|
193
|
+
|
|
194
|
+
* bash/zsh/fish: `inkscape 'My Document.svg' --export-filename=output.png`
|
|
195
|
+
* PowerShell: `inkscape 'My Document.svg' --export-filename=output.png`
|
|
196
|
+
* cmd: `inkscape "My Document.svg" --export-filename=output.png`
|
|
197
|
+
|
|
198
|
+
// Tool Discovery
|
|
199
|
+
== Tool Discovery
|
|
200
|
+
|
|
201
|
+
Ukiryu searches for tools in platform-specific locations.
|
|
202
|
+
|
|
203
|
+
=== Search Path Priority
|
|
204
|
+
|
|
205
|
+
[source]
|
|
206
|
+
----
|
|
207
|
+
1. Custom search paths (from profile)
|
|
208
|
+
2. Platform-specific default paths
|
|
209
|
+
3. System PATH environment variable
|
|
210
|
+
4. Common installation directories
|
|
211
|
+
----
|
|
212
|
+
|
|
213
|
+
=== Example: Inkscape Search Paths
|
|
214
|
+
|
|
215
|
+
**macOS**:
|
|
216
|
+
[source,yaml]
|
|
217
|
+
----
|
|
218
|
+
search_paths:
|
|
219
|
+
macos:
|
|
220
|
+
- '/Applications/Inkscape.app/Contents/MacOS/inkscape'
|
|
221
|
+
- '/opt/homebrew/bin/inscape'
|
|
222
|
+
- '/usr/local/bin/inkscape'
|
|
223
|
+
- '/opt/local/bin/inkscape'
|
|
224
|
+
- '/usr/local/opt/inkscape/bin/inkscape'
|
|
225
|
+
----
|
|
226
|
+
|
|
227
|
+
**Linux**:
|
|
228
|
+
[source,yaml]
|
|
229
|
+
----
|
|
230
|
+
search_paths:
|
|
231
|
+
linux:
|
|
232
|
+
- '/usr/bin/inkscape'
|
|
233
|
+
- '/usr/local/bin/inkscape'
|
|
234
|
+
- '/snap/bin/inkscape'
|
|
235
|
+
- '/var/lib/flatpak/exports/bin/org.inkscape.Inkscape'
|
|
236
|
+
- '/usr/bin/flatpak-spawn'
|
|
237
|
+
- '/opt/inkscape.AppImage'
|
|
238
|
+
- '/usr/local/bin/inkscape.AppImage'
|
|
239
|
+
- '/opt/bin/inkscape'
|
|
240
|
+
----
|
|
241
|
+
|
|
242
|
+
**Windows**:
|
|
243
|
+
[source,yaml]
|
|
244
|
+
----
|
|
245
|
+
search_paths:
|
|
246
|
+
windows:
|
|
247
|
+
- 'C:/Program Files/Inkscape/bin/inkscape.exe'
|
|
248
|
+
- 'C:/Program Files/Inkscape/inkscape.exe'
|
|
249
|
+
- 'C:/Program Files (x86)/Inkscape/bin/inkscape.exe'
|
|
250
|
+
- '%USERPROFILE%/scoop/apps/inkscape/current/inkscape.exe'
|
|
251
|
+
- '~/scoop/apps/inkscape/current/inkscape.exe'
|
|
252
|
+
- 'C:/ProgramData/chocolatey/lib/inkscape/tools/inkscape*/bin/inkscape.exe'
|
|
253
|
+
- '%LOCALAPPDATA%/Inkscape/bin/inkscape.exe'
|
|
254
|
+
- '~/AppData/Local/Inkscape/bin/inkscape.exe'
|
|
255
|
+
----
|
|
256
|
+
|
|
257
|
+
// Platform-Specific Features
|
|
258
|
+
== Platform-Specific Features
|
|
259
|
+
|
|
260
|
+
=== macOS Features
|
|
261
|
+
|
|
262
|
+
**Application Bundles**:
|
|
263
|
+
[source,yaml]
|
|
264
|
+
----
|
|
265
|
+
search_paths:
|
|
266
|
+
macos:
|
|
267
|
+
- '/Applications/Inkscape.app/Contents/MacOS/inkscape'
|
|
268
|
+
- '/Applications/ImageMagick/ImageMagick'
|
|
269
|
+
----
|
|
270
|
+
|
|
271
|
+
**Homebrew**:
|
|
272
|
+
[source,yaml]
|
|
273
|
+
----
|
|
274
|
+
search_paths:
|
|
275
|
+
macos:
|
|
276
|
+
- '/opt/homebrew/bin/*' # Apple Silicon
|
|
277
|
+
- '/usr/local/bin/*' # Intel
|
|
278
|
+
----
|
|
279
|
+
|
|
280
|
+
**Headless Mode**:
|
|
281
|
+
* Removes `DISPLAY` environment variable
|
|
282
|
+
* Sets `NSAppleEventsSuppressStartupAlert=true`
|
|
283
|
+
* Sets `NSUIElement=1` (background agent)
|
|
284
|
+
* Sets `GDK_BACKEND=x11` for X11-based tools
|
|
285
|
+
|
|
286
|
+
=== Linux Features
|
|
287
|
+
|
|
288
|
+
**Snap Packages**:
|
|
289
|
+
[source,yaml]
|
|
290
|
+
----
|
|
291
|
+
search_paths:
|
|
292
|
+
linux:
|
|
293
|
+
- '/snap/bin/*'
|
|
294
|
+
----
|
|
295
|
+
|
|
296
|
+
**Flatpak**:
|
|
297
|
+
[source,yaml]
|
|
298
|
+
----
|
|
299
|
+
search_paths:
|
|
300
|
+
linux:
|
|
301
|
+
- '/var/lib/flatpak/exports/bin/*'
|
|
302
|
+
----
|
|
303
|
+
|
|
304
|
+
**AppImages**:
|
|
305
|
+
[source,yaml]
|
|
306
|
+
----
|
|
307
|
+
search_paths:
|
|
308
|
+
linux:
|
|
309
|
+
- '/opt/*.AppImage'
|
|
310
|
+
- '/usr/local/bin/*.AppImage'
|
|
311
|
+
----
|
|
312
|
+
|
|
313
|
+
=== Windows Features
|
|
314
|
+
|
|
315
|
+
**PowerShell Modules**:
|
|
316
|
+
[source,yaml]
|
|
317
|
+
----
|
|
318
|
+
search_paths:
|
|
319
|
+
windows:
|
|
320
|
+
- '~/AppData/Local/Programs/*' # User-scoped installs
|
|
321
|
+
----
|
|
322
|
+
|
|
323
|
+
**Scoop**:
|
|
324
|
+
[source,yaml]
|
|
325
|
+
----
|
|
326
|
+
search_paths:
|
|
327
|
+
windows:
|
|
328
|
+
- '%USERPROFILE%/scoop/apps/*'
|
|
329
|
+
- '~/scoop/apps/*'
|
|
330
|
+
----
|
|
331
|
+
|
|
332
|
+
**Chocolatey**:
|
|
333
|
+
[source,yaml]
|
|
334
|
+
----
|
|
335
|
+
search_paths:
|
|
336
|
+
windows:
|
|
337
|
+
- 'C:/ProgramData/chocolatey/lib/*/tools/*'
|
|
338
|
+
----
|
|
339
|
+
|
|
340
|
+
**PATH Extensions**:
|
|
341
|
+
[source,ruby]
|
|
342
|
+
----
|
|
343
|
+
# PATHEXT is automatically checked
|
|
344
|
+
# Searches for: inkscape.exe, inkscape.bat, inkscape.cmd, etc.
|
|
345
|
+
----
|
|
346
|
+
|
|
347
|
+
// Cross-Platform Best Practices
|
|
348
|
+
== Cross-Platform Best Practices
|
|
349
|
+
|
|
350
|
+
=== Use Forward Slashes in Paths
|
|
351
|
+
|
|
352
|
+
[source,ruby]
|
|
353
|
+
----
|
|
354
|
+
# Good - Works on all platforms
|
|
355
|
+
result = tool.execute(:export, {
|
|
356
|
+
inputs: ['~/projects/drawings/design.svg'],
|
|
357
|
+
output: '~/projects/exports/design.png'
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
# Avoid - Platform-specific
|
|
361
|
+
result = tool.execute(:export, {
|
|
362
|
+
inputs: ['C:\\projects\\drawings\\design.svg'], # Windows only
|
|
363
|
+
output: '~/projects/exports/design.png' # Better
|
|
364
|
+
})
|
|
365
|
+
----
|
|
366
|
+
|
|
367
|
+
=== Avoid Platform-Specific Code
|
|
368
|
+
|
|
369
|
+
[source,ruby]
|
|
370
|
+
----
|
|
371
|
+
# Good - Platform-agnostic
|
|
372
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
373
|
+
result = tool.execute(:export, params)
|
|
374
|
+
|
|
375
|
+
# Avoid - Platform-specific
|
|
376
|
+
if RUBY_PLATFORM =~ /darwin/
|
|
377
|
+
executable = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
|
|
378
|
+
elsif RUBY_PLATFORM =~ /linux/
|
|
379
|
+
executable = '/usr/bin/inkscape'
|
|
380
|
+
elsif RUBY_PLATFORM =~ /mswin/
|
|
381
|
+
executable = 'C:/Program Files/Inkscape/inkscape.exe'
|
|
382
|
+
end
|
|
383
|
+
# Let Ukiryu handle this!
|
|
384
|
+
----
|
|
385
|
+
|
|
386
|
+
=== Test on Multiple Platforms
|
|
387
|
+
|
|
388
|
+
[source,ruby]
|
|
389
|
+
----
|
|
390
|
+
# Use environment-agnostic paths
|
|
391
|
+
input = File.expand_path('~/drawing.svg')
|
|
392
|
+
output = File.expand_path('~/drawing.png')
|
|
393
|
+
|
|
394
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
395
|
+
result = tool.execute(:export, {
|
|
396
|
+
inputs: [input],
|
|
397
|
+
output: output
|
|
398
|
+
})
|
|
399
|
+
----
|
|
400
|
+
|
|
401
|
+
=== Handle Platform Differences Gracefully
|
|
402
|
+
|
|
403
|
+
[source,ruby]
|
|
404
|
+
----
|
|
405
|
+
begin
|
|
406
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
407
|
+
result = tool.execute(:export, params)
|
|
408
|
+
|
|
409
|
+
# Check for platform-specific warnings
|
|
410
|
+
if result.stderr.include?('display')
|
|
411
|
+
warn("Display warning - may need headless mode")
|
|
412
|
+
end
|
|
413
|
+
rescue Ukiryu::ToolNotFoundError
|
|
414
|
+
# Platform-specific installation instructions
|
|
415
|
+
case RbConfig::CONFIG['host_os']
|
|
416
|
+
when /darwin/
|
|
417
|
+
puts "Install with: brew install --cask inkscape"
|
|
418
|
+
when /linux/
|
|
419
|
+
puts "Install with: sudo apt-get install inkscape"
|
|
420
|
+
when /mswin|mingw/
|
|
421
|
+
puts "Download from: https://inkscape.org/release/"
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
----
|
|
425
|
+
|
|
426
|
+
// Examples
|
|
427
|
+
== Examples
|
|
428
|
+
|
|
429
|
+
=== Cross-Platform Script
|
|
430
|
+
|
|
431
|
+
[source,ruby]
|
|
432
|
+
----
|
|
433
|
+
#!/usr/bin/env ruby
|
|
434
|
+
# convert.rb - Works on macOS, Linux, Windows
|
|
435
|
+
|
|
436
|
+
require 'ukiryu'
|
|
437
|
+
|
|
438
|
+
input = ARGV[0] || 'drawing.svg'
|
|
439
|
+
output = ARGV[1] || 'drawing.png'
|
|
440
|
+
|
|
441
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
442
|
+
result = tool.execute(:export, {
|
|
443
|
+
inputs: [input],
|
|
444
|
+
output: output,
|
|
445
|
+
format: :png
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
if result.success?
|
|
449
|
+
puts "✓ Converted #{input} -> #{output}"
|
|
450
|
+
puts " Duration: #{result.metadata.formatted_duration}"
|
|
451
|
+
else
|
|
452
|
+
puts "✗ Conversion failed"
|
|
453
|
+
puts " Error: #{result.stderr}"
|
|
454
|
+
exit 1
|
|
455
|
+
end
|
|
456
|
+
----
|
|
457
|
+
|
|
458
|
+
=== Platform-Specific Search Paths
|
|
459
|
+
|
|
460
|
+
[source,yaml]
|
|
461
|
+
----
|
|
462
|
+
# tools/mytool/1.0.yaml
|
|
463
|
+
name: mytool
|
|
464
|
+
version: '1.0'
|
|
465
|
+
|
|
466
|
+
search_paths:
|
|
467
|
+
macos:
|
|
468
|
+
- '/Applications/MyTool.app/Contents/MacOS/mytool'
|
|
469
|
+
- '/opt/homebrew/bin/mytool'
|
|
470
|
+
- '~/Library/Application Support/MyTool/bin/mytool'
|
|
471
|
+
|
|
472
|
+
linux:
|
|
473
|
+
- '/usr/bin/mytool'
|
|
474
|
+
- '/usr/local/bin/mytool'
|
|
475
|
+
- '/opt/mytool/bin/mytool'
|
|
476
|
+
|
|
477
|
+
windows:
|
|
478
|
+
- 'C:/Program Files/MyTool/bin/mytool.exe'
|
|
479
|
+
- '~/AppData/Local/Programs/MyTool/bin/mytool.exe'
|
|
480
|
+
- '%LOCALAPPDATA%/MyTool/bin/mytool.exe'
|
|
481
|
+
----
|
|
482
|
+
|
|
483
|
+
// See Also
|
|
484
|
+
== See Also
|
|
485
|
+
|
|
486
|
+
* link:/understanding/platform-detection[Platform Detection Internals]
|
|
487
|
+
* link:/understanding/shell-adaptation[Shell Adaptation Internals]
|
|
488
|
+
* link:/advanced/writing-profiles[Writing Platform-Specific Profiles]
|