Class: Ukiryu::Models::ExecutionProfile

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/models/implementation_version.rb

Overview

ExecutionProfile model for platform/shell-specific command configuration.

An ExecutionProfile defines how commands are formatted and executed for a specific platform and shell combination.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, platforms:, shells:, option_style:, executable_name:, actions: {}) ⇒ ExecutionProfile

Returns a new instance of ExecutionProfile.

Parameters:

  • name (Symbol)

    Profile identifier

  • platforms (Array<Symbol>)

    Supported platforms

  • shells (Array<Symbol>)

    Supported shells

  • option_style (Symbol)

    Option formatting style

  • executable_name (String)

    Executable name

  • actions (Hash) (defaults to: {})

    Command definitions



169
170
171
172
173
174
175
176
177
# File 'lib/ukiryu/models/implementation_version.rb', line 169

def initialize(name:, platforms:, shells:, option_style:, executable_name:, actions: {})
  @name = name
  @platforms = Array(platforms).map(&:to_sym)
  @shells = Array(shells).map(&:to_sym)
  @option_style = option_style.to_sym
  @executable_name = executable_name
  @actions = actions.transform_keys(&:to_sym)
  freeze
end

Instance Attribute Details

#actionsHash

Command definitions

Returns:

  • (Hash)

    the current value of actions



160
161
162
# File 'lib/ukiryu/models/implementation_version.rb', line 160

def actions
  @actions
end

#executable_nameString

Base executable name

Returns:

  • (String)

    the current value of executable_name



160
161
162
# File 'lib/ukiryu/models/implementation_version.rb', line 160

def executable_name
  @executable_name
end

#nameSymbol

Profile identifier

Returns:

  • (Symbol)

    the current value of name



160
161
162
# File 'lib/ukiryu/models/implementation_version.rb', line 160

def name
  @name
end

#option_styleSymbol

Option formatting style

Returns:

  • (Symbol)

    the current value of option_style



160
161
162
# File 'lib/ukiryu/models/implementation_version.rb', line 160

def option_style
  @option_style
end

#platformsArray<Symbol>

Supported platforms

Returns:

  • (Array<Symbol>)

    the current value of platforms



160
161
162
# File 'lib/ukiryu/models/implementation_version.rb', line 160

def platforms
  @platforms
end

#shellsArray<Symbol>

Supported shells

Returns:

  • (Array<Symbol>)

    the current value of shells



160
161
162
# File 'lib/ukiryu/models/implementation_version.rb', line 160

def shells
  @shells
end

Instance Method Details

#command(action_name) ⇒ Hash?

Get command definition

Parameters:

  • action_name (Symbol)

    Action name

Returns:

  • (Hash, nil)

    Command definition or nil



192
193
194
# File 'lib/ukiryu/models/implementation_version.rb', line 192

def command(action_name)
  @actions[action_name]
end

#commandsHash

Get all command definitions

Returns:

  • (Hash)

    All commands (alias for actions)



199
200
201
# File 'lib/ukiryu/models/implementation_version.rb', line 199

def commands
  @actions
end

#compatible?(platform, shell) ⇒ Boolean

Check if profile is compatible with platform and shell

Parameters:

  • platform (Symbol)

    Target platform

  • shell (Symbol)

    Target shell

Returns:

  • (Boolean)

    true if compatible



184
185
186
# File 'lib/ukiryu/models/implementation_version.rb', line 184

def compatible?(platform, shell)
  @platforms.include?(platform) && @shells.include?(shell)
end

#inspectString

Inspect representation

Returns:

  • (String)


213
214
215
# File 'lib/ukiryu/models/implementation_version.rb', line 213

def inspect
  "#<Ukiryu::Models::ExecutionProfile #{@to_s}>"
end

#to_sString

String representation

Returns:

  • (String)


206
207
208
# File 'lib/ukiryu/models/implementation_version.rb', line 206

def to_s
  "#{@name} (#{@platforms.join(',')} / #{@shells.join(',')})"
end