Class: BundlerSkills::Linker
- Inherits:
-
Object
- Object
- BundlerSkills::Linker
- Defined in:
- lib/bundler_skills/linker.rb
Overview
Creates idempotent absolute symlinks for discovered skills into a single output directory, and prunes stale ones we previously created.
Pure filesystem operations — no Bundler dependency, so it is fully unit testable against a tmpdir. One Linker instance == one output directory (e.g. .claude/skills or .agents/skills).
Defined Under Namespace
Classes: Result
Constant Summary collapse
- STALE_GLOB =
"#{DiscoveredSkill::LINK_PREFIX}*#{DiscoveredSkill::BOUNDARY}*"
Instance Method Summary collapse
-
#clean_all ⇒ Array<String>
Remove every gem-– symlink we own (for ‘bundle skills clean`).
-
#initialize(skills_dir:, config: Config.new(Config::DEFAULTS), logger: nil) ⇒ Linker
constructor
A new instance of Linker.
- #link(skills) ⇒ Result
Constructor Details
#initialize(skills_dir:, config: Config.new(Config::DEFAULTS), logger: nil) ⇒ Linker
Returns a new instance of Linker.
27 28 29 30 31 |
# File 'lib/bundler_skills/linker.rb', line 27 def initialize(skills_dir:, config: Config.new(Config::DEFAULTS), logger: nil) @skills_dir = skills_dir @config = config @logger = logger end |
Instance Method Details
#clean_all ⇒ Array<String>
Remove every gem-– symlink we own (for ‘bundle skills clean`).
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bundler_skills/linker.rb', line 47 def clean_all removed = [] Dir.glob(File.join(@skills_dir, STALE_GLOB)).each do |path| next unless File.symlink?(path) remove(path) removed << File.basename(path) end removed end |