ukiryu 0.2.3 → 0.2.4

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ukiryu/logger.rb +1 -1
  3. data/lib/ukiryu/models/implementation_version.rb +2 -3
  4. data/lib/ukiryu/register.rb +1 -10
  5. data/lib/ukiryu/schemas/v1/tool.schema.yaml +3 -3
  6. data/lib/ukiryu/tool/loader.rb +57 -1
  7. data/lib/ukiryu/tool_index.rb +17 -30
  8. data/lib/ukiryu/version.rb +1 -1
  9. data/spec/fixtures/register/tools/bzip2/default/1.0.yaml +1 -1
  10. data/spec/fixtures/register/tools/bzip2_busybox/default/1.0.yaml +1 -1
  11. data/spec/fixtures/register/tools/bzip2_gnu/default/1.0.yaml +1 -1
  12. data/spec/fixtures/register/tools/exiftool/default/1.0.yaml +1 -1
  13. data/spec/fixtures/register/tools/ffmpeg/default/1.0.yaml +1 -1
  14. data/spec/fixtures/register/tools/ghostscript/default/10.0.yaml +1 -1
  15. data/spec/fixtures/register/tools/gzip/default/1.0.yaml +1 -1
  16. data/spec/fixtures/register/tools/gzip_busybox/default/1.0.yaml +1 -1
  17. data/spec/fixtures/register/tools/gzip_gnu/default/1.0.yaml +1 -1
  18. data/spec/fixtures/register/tools/imagemagick/default/6.0.yaml +1 -1
  19. data/spec/fixtures/register/tools/imagemagick/default/6.9.yaml +1 -1
  20. data/spec/fixtures/register/tools/imagemagick/default/7.1.yaml +1 -1
  21. data/spec/fixtures/register/tools/inkscape/default/0.92.yaml +1 -1
  22. data/spec/fixtures/register/tools/inkscape/default/1.0.yaml +1 -1
  23. data/spec/fixtures/register/tools/jq/default/1.0.yaml +1 -1
  24. data/spec/fixtures/register/tools/pdf2ps/default/1.0.yaml +1 -1
  25. data/spec/fixtures/register/tools/ping/bsd/1.0.yaml +1 -1
  26. data/spec/fixtures/register/tools/ping/gnu/2024.01.17.yaml +1 -1
  27. data/spec/fixtures/register/tools/ping/windows/1.0.yaml +1 -1
  28. data/spec/fixtures/register/tools/ping_bsd/default/1.0.yaml +1 -1
  29. data/spec/fixtures/register/tools/ping_gnu/default/1.0.yaml +1 -1
  30. data/spec/fixtures/register/tools/ping_windows/default/1.0.yaml +1 -1
  31. data/spec/fixtures/register/tools/sort/default/1.0.yaml +1 -1
  32. data/spec/fixtures/register/tools/tar/default/1.0.yaml +1 -1
  33. data/spec/fixtures/register/tools/unzip/default/1.0.yaml +1 -1
  34. data/spec/fixtures/register/tools/unzip/default/6.0.yaml +1 -1
  35. data/spec/fixtures/register/tools/yq/default/1.0.yaml +1 -1
  36. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab84f9616d2eab1f0aa2cdf37c640ffd34d50d5007a149f1a180a2e63ab1abba
4
- data.tar.gz: f1f49206a651397aff45f75fdbb9f3981eebed58ca22440cb912504d886e45ca
3
+ metadata.gz: 26e9a5bf049e08e07b4c435f8269327599cb5d6928c8d27c238ddb6f8ea81b1e
4
+ data.tar.gz: 4db1b1c05432cab64d36c0749b83e6d5d910a941c15eda604811111db748b543
5
5
  SHA512:
6
- metadata.gz: a1963c9496d9183755741ff5c54a04b1c639bf1dfd951115e07eb5e428b384c51c609e4af3ffbe8011685af444d0fc041ed0e72b309f316d71ff64b02a825178
7
- data.tar.gz: 7b865d4cbfce1bf8ab5c834265bebd01ea4bf9b9b49dcbeddf9954879cdc8484b323de7c82f462129cc84136478a2123ccd2668f188e9f5bb1f408cb91473587
6
+ metadata.gz: 9a5b3624a369f3aa3005ff91b8b502e49ed8b0c9392709dd556e39b4cfaff45a22e3f0a9fd1bda3802aa9e5633e64d20297a7792321dae9becfa22d085146aa0
7
+ data.tar.gz: 8160cd1815a565be6596b077e509ec0e49edb8b6e28e6d47b1baa6db22be02549887c635cbe300c833a00895874b65f2d830a44a803d8f04cdbd35d0ab5e93d2
data/lib/ukiryu/logger.rb CHANGED
@@ -55,7 +55,7 @@ module Ukiryu
55
55
  def debug_enabled?(category = nil)
56
56
  case category
57
57
  when :executable
58
- ENV[DEBUG_EXECUTABLE_ENV_VAR] || (Platform.windows? && ENV['CI'])
58
+ ENV[DEBUG_EXECUTABLE_ENV_VAR]
59
59
  else
60
60
  ENV[DEBUG_ENV_VAR]
61
61
  end
@@ -118,9 +118,8 @@ module Ukiryu
118
118
  VersionDetection.from_hash(vd_data)
119
119
  end
120
120
 
121
- # Support both profiles (legacy) and execution_profiles (new)
122
- profiles_data = data[:execution_profiles] || data['execution_profiles'] ||
123
- data[:profiles] || data['profiles'] || []
121
+ # Extract execution_profiles
122
+ profiles_data = data[:execution_profiles] || data['execution_profiles'] || []
124
123
 
125
124
  new(
126
125
  implements: data[:implements],
@@ -417,7 +417,7 @@ module Ukiryu
417
417
 
418
418
  # Get versions from index
419
419
  versions = list_versions(name_str)
420
- return load_legacy_tool_yaml(name_str) if versions.empty?
420
+ return nil if versions.empty?
421
421
 
422
422
  # Return specific version or latest
423
423
  if version
@@ -486,15 +486,6 @@ module Ukiryu
486
486
 
487
487
  private
488
488
 
489
- # Load legacy single-file tool YAML
490
- #
491
- # @param name [String] the tool name
492
- # @return [String, nil] the YAML content or nil
493
- def load_legacy_tool_yaml(name)
494
- file = File.join(path, 'tools', "#{name}.yaml")
495
- File.read(file) if File.exist?(file)
496
- end
497
-
498
489
  # Get git information for this register
499
490
  #
500
491
  # @return [Hash, nil] git info or nil
@@ -14,7 +14,7 @@ required:
14
14
  - ukiryu_schema
15
15
  - name
16
16
  - version
17
- - profiles
17
+ - execution_profiles
18
18
  additionalProperties: false
19
19
 
20
20
  properties:
@@ -154,9 +154,9 @@ properties:
154
154
  description: Default execution timeout in seconds
155
155
  example: 300
156
156
 
157
- # === Profiles ===
157
+ # === Execution Profiles ===
158
158
 
159
- profiles:
159
+ execution_profiles:
160
160
  type: array
161
161
  minItems: 1
162
162
  description: Platform/shell-specific configurations
@@ -65,7 +65,16 @@ module Ukiryu
65
65
  # @param options [Hash] options including platform and shell
66
66
  # @return [Hash, nil] hash with :implementation_name, :version, :file or nil
67
67
  def detect_implementation_and_version(index, tool_name, options = {})
68
- # Try each implementation in order
68
+ target_platform = options[:platform]
69
+ current_platform = Platform.detect
70
+
71
+ # If platform is overridden to a different platform, skip detection
72
+ # and find an implementation that supports the target platform
73
+ if target_platform && target_platform.to_sym != current_platform
74
+ return find_implementation_for_platform(index, tool_name, target_platform, options)
75
+ end
76
+
77
+ # Normal detection: try each implementation in order
69
78
  index.implementations.each do |impl|
70
79
  result = try_implementation(impl, tool_name, options)
71
80
  return result if result
@@ -75,6 +84,53 @@ module Ukiryu
75
84
  fallback_to_default(index)
76
85
  end
77
86
 
87
+ # Find an implementation that supports the target platform
88
+ #
89
+ # @param index [Models::ImplementationIndex] the implementation index
90
+ # @param tool_name [String] the tool name
91
+ # @param target_platform [Symbol] the target platform
92
+ # @param options [Hash] options including shell
93
+ # @return [Hash, nil] implementation spec or nil
94
+ def find_implementation_for_platform(index, tool_name, target_platform, options = {})
95
+ target_platform = target_platform.to_sym if target_platform.is_a?(String)
96
+ target_shell = (options[:shell] || Shell.detect).to_sym
97
+
98
+ # Try each implementation and check if it has a profile for the target platform
99
+ index.implementations.each do |impl|
100
+ impl_name = impl[:name] || impl['name']
101
+ versions = impl[:versions] || impl['versions']
102
+
103
+ # Check each version file for platform compatibility
104
+ versions.each do |version_spec|
105
+ file = version_spec[:file] || version_spec['file']
106
+ next unless file
107
+
108
+ # Load the implementation version to check profiles
109
+ impl_version = Register.load_implementation_version(
110
+ tool_name,
111
+ impl_name,
112
+ file,
113
+ options
114
+ )
115
+ next unless impl_version
116
+
117
+ # Check if any execution profile supports the target platform/shell
118
+ profile = impl_version.compatible_profile(platform: target_platform, shell: target_shell)
119
+ if profile
120
+ # Found a compatible implementation
121
+ return {
122
+ implementation_name: impl_name,
123
+ version: impl_version.version,
124
+ file: file
125
+ }
126
+ end
127
+ end
128
+ end
129
+
130
+ # No implementation supports the target platform
131
+ nil
132
+ end
133
+
78
134
  private
79
135
 
80
136
  # Try to detect version from a single implementation
@@ -272,28 +272,19 @@ module Ukiryu
272
272
  @alias_to_tool.clear
273
273
 
274
274
  # Scan all tool directories for metadata
275
- # New structure: tools/{tool-name}/{variant}/{version}.yaml
276
- # Fallback: tools/{tool-name}/{version}.yaml (legacy structure)
275
+ # Structure: tools/{tool-name}/{implementation}/{version}.yaml
277
276
  tool_dirs = Dir.glob(File.join(tools_dir, '*')).select { |d| File.directory?(d) }.sort
278
277
 
279
278
  tool_dirs.each do |tool_dir|
280
279
  tool_name = File.basename(tool_dir)
281
280
  tool_sym = tool_name.to_sym
282
281
 
283
- # Find YAML files in the tool directory (check both structures)
282
+ # Find YAML files in implementation subdirectories
284
283
  yaml_files = []
285
284
 
286
- # Check for variant subdirectories (new structure: tools/ping_bsd/default/1.0.yaml)
287
- variant_dirs = Dir.glob(File.join(tool_dir, '*')).select { |d| File.directory?(d) }
288
- variant_dirs.each do |variant_dir|
289
- Dir.glob(File.join(variant_dir, '*.yaml')).sort.each do |file|
290
- yaml_files << file
291
- end
292
- end
293
-
294
- # Fallback: direct YAML files in tool directory (legacy structure)
295
- if yaml_files.empty?
296
- Dir.glob(File.join(tool_dir, '*.yaml')).sort.each do |file|
285
+ impl_dirs = Dir.glob(File.join(tool_dir, '*')).select { |d| File.directory?(d) }
286
+ impl_dirs.each do |impl_dir|
287
+ Dir.glob(File.join(impl_dir, '*.yaml')).sort.each do |file|
297
288
  yaml_files << file
298
289
  end
299
290
  end
@@ -305,7 +296,7 @@ module Ukiryu
305
296
  next unless hash
306
297
 
307
298
  # Index by interface (multiple tools can implement one interface)
308
- # v2: implements is an array, v1: implements is a string
299
+ # implements is an array of interface names
309
300
  implements_value = hash['implements']
310
301
  if implements_value
311
302
  interfaces = if implements_value.is_a?(Array)
@@ -371,28 +362,24 @@ module Ukiryu
371
362
  tool_dir = File.join(current_path, 'tools', tool_name.to_s)
372
363
  return nil unless Dir.exist?(tool_dir)
373
364
 
374
- # Search for version files in both structures:
375
- # New: tools/{tool-name}/{variant}/{version}.yaml
376
- # Legacy: tools/{tool-name}/{version}.yaml
365
+ # Structure: tools/{tool-name}/{implementation}/{version}.yaml
366
+ impl_dirs = Dir.glob(File.join(tool_dir, '*')).select { |d| File.directory?(d) }
377
367
 
378
- # First check for variant subdirectories (new structure)
379
- variant_dirs = Dir.glob(File.join(tool_dir, '*')).select { |d| File.directory?(d) }
368
+ # Prefer 'default' implementation if present
369
+ impl_dirs.each do |impl_dir|
370
+ next unless File.basename(impl_dir) == 'default'
380
371
 
381
- variant_dirs.each do |variant_dir|
382
- # Prefer 'default' variant if present
383
- next unless File.basename(variant_dir) == 'default'
384
-
385
- files = Dir.glob(File.join(variant_dir, '*.yaml'))
372
+ files = Dir.glob(File.join(impl_dir, '*.yaml'))
386
373
  return select_latest_version_by_content(files) if files.any?
374
+ end
387
375
 
388
- # Fall back to any variant directory
389
- files = Dir.glob(File.join(variant_dir, '*.yaml'))
376
+ # Fall back to any implementation directory
377
+ impl_dirs.each do |impl_dir|
378
+ files = Dir.glob(File.join(impl_dir, '*.yaml'))
390
379
  return select_latest_version_by_content(files) if files.any?
391
380
  end
392
381
 
393
- # Fallback: direct YAML files in tool directory (legacy structure)
394
- files = Dir.glob(File.join(tool_dir, '*.yaml'))
395
- files.any? ? select_latest_version_by_content(files) : nil
382
+ nil
396
383
  rescue StandardError
397
384
  nil
398
385
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ukiryu
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
@@ -14,7 +14,7 @@ search_paths:
14
14
  linux:
15
15
  - "/usr/bin/bzip2"
16
16
  implements: bzip2/1.0
17
- profiles:
17
+ execution_profiles:
18
18
  - name: default
19
19
  platforms:
20
20
  - macos
@@ -11,7 +11,7 @@ search_paths:
11
11
  - "/bin/bzip2"
12
12
  - "/usr/bin/bzip2"
13
13
  implements: bzip2_busybox/1.0
14
- profiles:
14
+ execution_profiles:
15
15
  - name: default
16
16
  platforms:
17
17
  - linux
@@ -14,7 +14,7 @@ search_paths:
14
14
  linux:
15
15
  - "/usr/bin/bzip2"
16
16
  implements: bzip2_gnu/1.0
17
- profiles:
17
+ execution_profiles:
18
18
  - name: default
19
19
  platforms:
20
20
  - macos
@@ -14,7 +14,7 @@ search_paths:
14
14
  linux:
15
15
  - "/usr/bin/exiftool"
16
16
  implements: exiftool/1.0
17
- profiles:
17
+ execution_profiles:
18
18
  - name: default
19
19
  platforms:
20
20
  - macos
@@ -19,7 +19,7 @@ search_paths:
19
19
  linux:
20
20
  - "/usr/bin/ffmpeg"
21
21
  implements: ffmpeg/1.0
22
- profiles:
22
+ execution_profiles:
23
23
  - name: default
24
24
  platforms:
25
25
  - macos
@@ -16,7 +16,7 @@ search_paths:
16
16
  - "C:/Program Files/gs/gs*/bin/gswin64c.exe"
17
17
  - "C:/Program Files/gs/gs*/bin/gswin32c.exe"
18
18
  implements: ghostscript/1.0
19
- profiles:
19
+ execution_profiles:
20
20
  - name: unix
21
21
  platforms:
22
22
  - macos
@@ -15,7 +15,7 @@ search_paths:
15
15
  - "/usr/bin/gzip"
16
16
  - "/bin/gzip"
17
17
  implements: gzip/1.0
18
- profiles:
18
+ execution_profiles:
19
19
  - name: default
20
20
  platforms:
21
21
  - macos
@@ -11,7 +11,7 @@ search_paths:
11
11
  - "/bin/gzip"
12
12
  - "/usr/bin/gzip"
13
13
  implements: gzip_busybox/1.0
14
- profiles:
14
+ execution_profiles:
15
15
  - name: default
16
16
  platforms:
17
17
  - linux
@@ -15,7 +15,7 @@ search_paths:
15
15
  - "/usr/bin/gzip"
16
16
  - "/bin/gzip"
17
17
  implements: gzip_gnu/1.0
18
- profiles:
18
+ execution_profiles:
19
19
  - name: default
20
20
  platforms:
21
21
  - macos
@@ -18,7 +18,7 @@ search_paths:
18
18
  windows:
19
19
  - C:/Program Files/ImageMagick*/convert.exe
20
20
  implements: imagemagick/1.0
21
- profiles:
21
+ execution_profiles:
22
22
  - name: default
23
23
  platforms:
24
24
  - macos
@@ -33,7 +33,7 @@ search_paths:
33
33
  - C:/Program Files/ImageMagick-*/identify.exe
34
34
  - C:/Program Files/ImageMagick-*/mogrify.exe
35
35
  implements: imagemagick/1.0
36
- profiles:
36
+ execution_profiles:
37
37
  - name: unix
38
38
  platforms:
39
39
  - macos
@@ -34,7 +34,7 @@ search_paths:
34
34
  - "%LOCALAPPDATA%/Programs/ImageMagick-*/magick.exe"
35
35
  - "~/AppData/Local/Programs/ImageMagick-*/magick.exe"
36
36
  implements: imagemagick/1.0
37
- profiles:
37
+ execution_profiles:
38
38
  - name: modern_unix
39
39
  platforms:
40
40
  - macos
@@ -35,7 +35,7 @@ search_paths:
35
35
  - "%LOCALAPPDATA%/Inkscape/bin/inkscape.exe"
36
36
  - "~/AppData/Local/Inkscape/bin/inkscape.exe"
37
37
  implements: inkscape/1.0
38
- profiles:
38
+ execution_profiles:
39
39
  - name: legacy_unix
40
40
  platforms:
41
41
  - macos
@@ -38,7 +38,7 @@ search_paths:
38
38
  - "%LOCALAPPDATA%/Inkscape/bin/inkscape.exe"
39
39
  - "~/AppData/Local/Inkscape/bin/inkscape.exe"
40
40
  implements: inkscape/1.0
41
- profiles:
41
+ execution_profiles:
42
42
  - name: modern_unix
43
43
  platforms:
44
44
  - macos
@@ -15,7 +15,7 @@ search_paths:
15
15
  linux:
16
16
  - "/usr/bin/jq"
17
17
  implements: jq/1.0
18
- profiles:
18
+ execution_profiles:
19
19
  - name: default
20
20
  platforms:
21
21
  - macos
@@ -19,7 +19,7 @@ search_paths:
19
19
  - C:/Program Files (x86)/gs/gs*/bin/pdf2ps.bat
20
20
  - C:/Program Files (x86)/gs/gs*/bin/pdf2ps.cmd
21
21
  implements: pdf2ps/1.0
22
- profiles:
22
+ execution_profiles:
23
23
  - name: default
24
24
  platforms:
25
25
  - macos
@@ -31,7 +31,7 @@ search_paths:
31
31
  - "/sbin/ping"
32
32
  - "/usr/sbin/ping"
33
33
  implements: ping
34
- profiles:
34
+ execution_profiles:
35
35
  - name: default
36
36
  platforms:
37
37
  - macos
@@ -16,7 +16,7 @@ search_paths:
16
16
  - "/sbin/ping"
17
17
  - "/usr/sbin/ping"
18
18
  implements: ping
19
- profiles:
19
+ execution_profiles:
20
20
  - name: default
21
21
  platforms:
22
22
  - linux
@@ -18,7 +18,7 @@ search_paths:
18
18
  - "C:/Windows/System32/ping.exe"
19
19
  - "C:/Windows/SysWOW64/ping.exe"
20
20
  implements: ping
21
- profiles:
21
+ execution_profiles:
22
22
  - name: windows
23
23
  platforms:
24
24
  - windows
@@ -9,7 +9,7 @@ aliases:
9
9
  version_detection:
10
10
  search_paths:
11
11
  implements: ping_bsd/1.0
12
- profiles:
12
+ execution_profiles:
13
13
  - name: default
14
14
  platforms:
15
15
  - macos
@@ -9,7 +9,7 @@ aliases:
9
9
  version_detection:
10
10
  search_paths:
11
11
  implements: ping_gnu/1.0
12
- profiles:
12
+ execution_profiles:
13
13
  - name: default
14
14
  platforms:
15
15
  - linux
@@ -15,7 +15,7 @@ version_detection:
15
15
  modern_threshold: '1.0'
16
16
  search_paths:
17
17
  implements: ping_windows/1.0
18
- profiles:
18
+ execution_profiles:
19
19
  - name: windows
20
20
  platforms:
21
21
  - windows
@@ -15,7 +15,7 @@ search_paths:
15
15
  - "/usr/bin/sort"
16
16
  - "/bin/sort"
17
17
  implements: sort/1.0
18
- profiles:
18
+ execution_profiles:
19
19
  - name: default
20
20
  platforms:
21
21
  - macos
@@ -15,7 +15,7 @@ search_paths:
15
15
  - "/usr/bin/tar"
16
16
  - "/bin/tar"
17
17
  implements: tar/1.0
18
- profiles:
18
+ execution_profiles:
19
19
  - name: default
20
20
  platforms:
21
21
  - macos
@@ -14,7 +14,7 @@ search_paths:
14
14
  linux:
15
15
  - "/usr/bin/unzip"
16
16
  implements: unzip/1.0
17
- profiles:
17
+ execution_profiles:
18
18
  - name: default
19
19
  platforms:
20
20
  - macos
@@ -22,7 +22,7 @@ search_paths:
22
22
  - C:/Program Files/Git/usr/bin/unzip.exe
23
23
  - C:/msys64/usr/bin/unzip.exe
24
24
  implements: unzip/1.0
25
- profiles:
25
+ execution_profiles:
26
26
  - name: unix
27
27
  platforms:
28
28
  - macos
@@ -14,7 +14,7 @@ search_paths:
14
14
  linux:
15
15
  - "/usr/bin/yq"
16
16
  implements: yq/1.0
17
- profiles:
17
+ execution_profiles:
18
18
  - name: default
19
19
  platforms:
20
20
  - macos
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ukiryu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.