Class: Clacky::ChannelSetup::LarkSkillsImporter
- Inherits:
-
Object
- Object
- Clacky::ChannelSetup::LarkSkillsImporter
- Defined in:
- lib/clacky/default_skills/channel-setup/import_lark_skills.rb
Constant Summary collapse
- DEFAULT_SOURCE_DIR =
File.join(Dir.home, '.agents', 'skills')
- DEFAULT_TARGET_DIR =
File.join(Dir.home, '.clacky', 'skills', 'lark-imports')
- SKILL_PREFIX =
'lark-'
Instance Method Summary collapse
-
#initialize(source_dir: DEFAULT_SOURCE_DIR, target_dir: DEFAULT_TARGET_DIR) ⇒ LarkSkillsImporter
constructor
A new instance of LarkSkillsImporter.
-
#run ⇒ Hash
Run the import.
Constructor Details
#initialize(source_dir: DEFAULT_SOURCE_DIR, target_dir: DEFAULT_TARGET_DIR) ⇒ LarkSkillsImporter
Returns a new instance of LarkSkillsImporter.
36 37 38 39 |
# File 'lib/clacky/default_skills/channel-setup/import_lark_skills.rb', line 36 def initialize(source_dir: DEFAULT_SOURCE_DIR, target_dir: DEFAULT_TARGET_DIR) @source_dir = Pathname.new(source_dir). @target_dir = Pathname.new(target_dir). end |
Instance Method Details
#run ⇒ Hash
Run the import. Returns a result hash; never raises on per-skill errors.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/clacky/default_skills/channel-setup/import_lark_skills.rb', line 43 def run return { copied: 0, skipped: 0, errors: ["source not found: #{@source_dir}"] } unless @source_dir.directory? skill_dirs = discover_lark_skills return { copied: 0, skipped: 0, errors: [] } if skill_dirs.empty? FileUtils.mkdir_p(@target_dir) copied = 0 errors = [] skill_dirs.each do |src| begin copy_skill(src) copied += 1 rescue StandardError => e errors << "#{src.basename}: #{e.}" end end { copied: copied, skipped: 0, errors: errors } end |