Class: SkillBench::Services::VariantParser

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

Overview

Parses variant specifications for skill comparison.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ VariantParser

Returns a new instance of VariantParser.

Parameters:

  • spec (String)

    Variant spec (e.g., “pack:rails” or “/path/to/skill”)



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

def initialize(spec)
  @spec = spec
end

Class Method Details

.call(spec) ⇒ Hash

Parses a variant specification string.

Parameters:

  • spec (String)

    Variant spec (e.g., “pack:rails” or “/path/to/skill”)

Returns:

  • (Hash)

    Parsed variant with :type (:pack or :path) and corresponding key



11
12
13
# File 'lib/skill_bench/services/variant_parser.rb', line 11

def self.call(spec)
  new(spec).call
end

Instance Method Details

#callHash

Parses the variant specification.

Returns:

  • (Hash)

    Parsed variant with :type (:pack or :path) and corresponding key



23
24
25
26
27
28
29
# File 'lib/skill_bench/services/variant_parser.rb', line 23

def call
  if @spec.start_with?('pack:')
    { type: :pack, name: @spec.sub('pack:', '') }
  else
    { type: :path, path: @spec }
  end
end