Class: Ukiryu::Models::ImplementationVersion
- Inherits:
-
Object
- Object
- Ukiryu::Models::ImplementationVersion
- Defined in:
- lib/ukiryu/models/implementation_version.rb
Overview
ImplementationVersion model for a specific version of a tool implementation.
An ImplementationVersion contains the actual command definitions for a specific version of an implementation (e.g., GNU gzip 1.12).
Instance Attribute Summary collapse
-
#aliases ⇒ Array<String>
Aliases for this implementation.
-
#display_name ⇒ String
Human-readable name.
-
#execution_profiles ⇒ Array<ExecutionProfile>
Platform/shell profiles.
-
#implements ⇒ String
Interface this implements (e.g., “gzip/1.0”).
-
#version ⇒ String
Version string.
-
#version_detection ⇒ VersionDetection
Version detection configuration.
Class Method Summary collapse
-
.from_hash(data) ⇒ ImplementationVersion
Create ImplementationVersion from hash.
-
.from_yaml(path) ⇒ ImplementationVersion
Load ImplementationVersion from YAML file.
Instance Method Summary collapse
-
#compatible_profile(platform:, shell:) ⇒ Hash?
Get compatible profile for platform and shell.
-
#initialize(implements:, version:, execution_profiles:, display_name: nil, aliases: [], version_detection: nil) ⇒ ImplementationVersion
constructor
A new instance of ImplementationVersion.
-
#inspect ⇒ String
Inspect representation.
-
#profile(profile_name) ⇒ Hash?
Get profile by name.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(implements:, version:, execution_profiles:, display_name: nil, aliases: [], version_detection: nil) ⇒ ImplementationVersion
Returns a new instance of ImplementationVersion.
27 28 29 30 31 32 33 34 35 |
# File 'lib/ukiryu/models/implementation_version.rb', line 27 def initialize(implements:, version:, execution_profiles:, display_name: nil, aliases: [], version_detection: nil) @implements = implements @version = version @display_name = display_name || "#{implements} #{version}" @aliases = Array(aliases).map(&:to_s) @execution_profiles = execution_profiles @version_detection = version_detection freeze end |
Instance Attribute Details
#aliases ⇒ Array<String>
Aliases for this implementation
18 19 20 |
# File 'lib/ukiryu/models/implementation_version.rb', line 18 def aliases @aliases end |
#display_name ⇒ String
Human-readable name
18 19 20 |
# File 'lib/ukiryu/models/implementation_version.rb', line 18 def display_name @display_name end |
#execution_profiles ⇒ Array<ExecutionProfile>
Platform/shell profiles
18 19 20 |
# File 'lib/ukiryu/models/implementation_version.rb', line 18 def execution_profiles @execution_profiles end |
#implements ⇒ String
Interface this implements (e.g., “gzip/1.0”)
18 19 20 |
# File 'lib/ukiryu/models/implementation_version.rb', line 18 def implements @implements end |
#version ⇒ String
Version string
18 19 20 |
# File 'lib/ukiryu/models/implementation_version.rb', line 18 def version @version end |
#version_detection ⇒ VersionDetection
Version detection configuration
18 19 20 |
# File 'lib/ukiryu/models/implementation_version.rb', line 18 def version_detection @version_detection end |
Class Method Details
.from_hash(data) ⇒ ImplementationVersion
Create ImplementationVersion from hash
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/ukiryu/models/implementation_version.rb', line 114 def self.from_hash(data) # Extract version_detection if present version_detection = if data[:version_detection] || data['version_detection'] vd_data = data[:version_detection] || data['version_detection'] VersionDetection.from_hash(vd_data) end # Extract execution_profiles profiles_data = data[:execution_profiles] || data['execution_profiles'] || [] new( implements: data[:implements], version: data[:version], display_name: data[:display_name], aliases: data[:aliases] || [], execution_profiles: profiles_data, version_detection: version_detection ) end |
.from_yaml(path) ⇒ ImplementationVersion
Load ImplementationVersion from YAML file
103 104 105 106 107 108 |
# File 'lib/ukiryu/models/implementation_version.rb', line 103 def self.from_yaml(path) require 'psych' data = Psych.safe_load_file(path, permitted_classes: [Symbol, String, Integer, Array, Hash, TrueClass, FalseClass]) from_hash(data) end |
Instance Method Details
#compatible_profile(platform:, shell:) ⇒ Hash?
Get compatible profile for platform and shell
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ukiryu/models/implementation_version.rb', line 42 def compatible_profile(platform:, shell:) platform_str = platform.to_s shell_str = shell.to_s profile = @execution_profiles.find do |prof| platforms = Array(prof[:platforms] || prof[:platform]).map(&:to_s) shells = Array(prof[:shells] || prof[:shell]).map(&:to_s) platforms.include?(platform_str) && shells.include?(shell_str) end # Debug output for profile selection if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (ENV['CI'] && defined?(Ukiryu::Platform) && Ukiryu::Platform.windows?) warn "[UKIRYU DEBUG compatible_profile] platform=#{platform_str}, shell=#{shell_str}" warn "[UKIRYU DEBUG compatible_profile] Found profile: #{profile ? (profile[:name] || profile['name']) : 'nil'}" if profile warn "[UKIRYU DEBUG compatible_profile] Profile inherits: #{profile[:inherits] || profile['inherits']}" warn "[UKIRYU DEBUG compatible_profile] Profile commands nil?: #{profile[:commands].nil?}" warn "[UKIRYU DEBUG compatible_profile] Profile commands empty?: #{(profile[:commands] || []).empty?}" end end return nil unless profile # Resolve profile inheritance at hash level # If profile has 'inherits', copy commands from parent profile inherits = profile[:inherits] || profile['inherits'] if inherits parent_profile = @execution_profiles.find do |prof| prof_name = prof[:name] || prof['name'] prof_name.to_s == inherits.to_s end if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (ENV['CI'] && defined?(Ukiryu::Platform) && Ukiryu::Platform.windows?) warn "[UKIRYU DEBUG compatible_profile] Looking for parent '#{inherits}': #{parent_profile ? 'found' : 'not found'}" end if parent_profile && (profile[:commands].nil? || profile[:commands].empty?) # Copy parent's commands to child profile (without modifying original) parent_commands = parent_profile[:commands] || parent_profile['commands'] # Return a new hash with inherited commands profile = profile.dup.merge(commands: parent_commands) warn "[UKIRYU DEBUG compatible_profile] Inherited #{parent_commands&.size || 0} commands from parent" if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (ENV['CI'] && defined?(Ukiryu::Platform) && Ukiryu::Platform.windows?) end end profile end |
#inspect ⇒ String
Inspect representation
144 145 146 |
# File 'lib/ukiryu/models/implementation_version.rb', line 144 def inspect "#<Ukiryu::Models::ImplementationVersion #{self} profiles=#{@execution_profiles.length}>" end |
#profile(profile_name) ⇒ Hash?
Get profile by name
95 96 97 |
# File 'lib/ukiryu/models/implementation_version.rb', line 95 def profile(profile_name) @execution_profiles.find { |p| p[:name] == profile_name } end |
#to_s ⇒ String
String representation
137 138 139 |
# File 'lib/ukiryu/models/implementation_version.rb', line 137 def to_s "#{@implements} #{@version}" end |