Class: SkillBench::Services::SkillResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/services/skill_resolver.rb

Overview

Resolves a skill identifier to a Skill model instance. Supports both direct paths (containing ‘/’) and skill names (searched recursively).

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, base_path = 'skills/') ⇒ SkillResolver

Returns a new instance of SkillResolver.

Parameters:

  • identifier (String)

    Skill path or name

  • base_path (String) (defaults to: 'skills/')

    Base directory for skill discovery



22
23
24
25
# File 'lib/skill_bench/services/skill_resolver.rb', line 22

def initialize(identifier, base_path = 'skills/')
  @identifier = identifier
  @base_path = base_path
end

Class Method Details

.call(identifier, base_path = 'skills/') ⇒ SkillBench::Models::Skill

Resolves a skill identifier to a Skill instance.

Parameters:

  • identifier (String)

    Skill path or name

  • base_path (String) (defaults to: 'skills/')

    Base directory for skill discovery (default: ‘skills/’)

Returns:

Raises:

  • (ArgumentError)

    if skill not found



16
17
18
# File 'lib/skill_bench/services/skill_resolver.rb', line 16

def self.call(identifier, base_path = 'skills/')
  new(identifier, base_path).call
end

Instance Method Details

#callSkillBench::Models::Skill

Resolves the skill identifier.

Returns:

Raises:

  • (ArgumentError)

    if skill not found



31
32
33
34
35
# File 'lib/skill_bench/services/skill_resolver.rb', line 31

def call
  return resolve_by_path if identifier.include?('/')

  resolve_by_name
end