Class: Ukiryu::Models::PlatformProfile

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/ukiryu/models/platform_profile.rb

Overview

Platform-specific profile for a tool

Examples:

profile = PlatformProfile.new(
  name: 'default',
  platforms: [:macos, :linux],
  executable_name: 'ping',
  commands: [CommandDefinition.new(...)]
)

Instance Method Summary collapse

Instance Method Details

#clear_commands_index!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Clear the commands index

Call this if commands are modified after initial loading (e.g., during inheritance resolution)



121
122
123
124
# File 'lib/ukiryu/models/platform_profile.rb', line 121

def clear_commands_index!
  @commands_index = nil
  @commands_index_built = false
end

#command(name) ⇒ CommandDefinition?

Get a command by name using indexed O(1) lookup

Parameters:

  • name (String, Symbol)

    the command name

Returns:



90
91
92
93
94
95
# File 'lib/ukiryu/models/platform_profile.rb', line 90

def command(name)
  return nil unless commands

  build_commands_index unless @commands_index_built
  @commands_index[name.to_s]
end

#command_namesArray<String>

Get all command names

Returns:

  • (Array<String>)

    command names



100
101
102
103
104
105
# File 'lib/ukiryu/models/platform_profile.rb', line 100

def command_names
  return [] unless commands

  build_commands_index unless @commands_index_built
  @commands_index.keys
end

#compatible?(platform, shell) ⇒ Boolean

Check if profile is compatible with platform and shell

Parameters:

  • platform (Symbol)

    the platform

  • shell (Symbol)

    the shell

Returns:

  • (Boolean)

    true if compatible



82
83
84
# File 'lib/ukiryu/models/platform_profile.rb', line 82

def compatible?(platform, shell)
  supports_platform?(platform) && supports_shell?(shell)
end

#routingRouting

Get the routing table as a Routing model

Returns:



46
47
48
# File 'lib/ukiryu/models/platform_profile.rb', line 46

def routing
  @routing ||= Ukiryu::Models::Routing.new(@routing_data || {})
end

#routing?Boolean

Check if this profile has routing defined

Returns:

  • (Boolean)

    true if routing table is non-empty



53
54
55
# File 'lib/ukiryu/models/platform_profile.rb', line 53

def routing?
  !@routing_data.nil? && !@routing_data.empty?
end

#supports_platform?(platform) ⇒ Boolean

Check if profile supports a platform

Parameters:

  • platform (Symbol)

    the platform

Returns:

  • (Boolean)

    true if supported



61
62
63
64
65
# File 'lib/ukiryu/models/platform_profile.rb', line 61

def supports_platform?(platform)
  platform_list = cached_platforms_sym
  platform_list.nil? || platform_list.empty? ||
    platform_list.include?(platform.to_sym)
end

#supports_shell?(shell) ⇒ Boolean

Check if profile supports a shell

Parameters:

  • shell (Symbol)

    the shell

Returns:

  • (Boolean)

    true if supported



71
72
73
74
75
# File 'lib/ukiryu/models/platform_profile.rb', line 71

def supports_shell?(shell)
  shell_list = cached_shells_sym
  shell_list.nil? || shell_list.empty? ||
    shell_list.include?(shell.to_sym)
end

#universal?Boolean

Check if universal (supports all)

Returns:

  • (Boolean)

    true if universal



110
111
112
113
# File 'lib/ukiryu/models/platform_profile.rb', line 110

def universal?
  (platforms.nil? || platforms.empty?) &&
    (shells.nil? || shells.empty?)
end