Class: Yorishiro::SkillLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/yorishiro/skill_loader.rb

Overview

Auto-loads custom skills (slash commands) from skill directories such as ~/.yorishiro/skills and ./.yorishiro/skills. A skill file just defines Yorishiro::Skill subclasses — no registration call needed. New classes are detected by diffing the Skill class tree around the load and registered through Configuration#replace_skill, so the usual validation applies and later directories override same-name skills.

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ SkillLoader

Returns a new instance of SkillLoader.



11
12
13
# File 'lib/yorishiro/skill_loader.rb', line 11

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#load_dir(dir) ⇒ Object



15
16
17
18
19
# File 'lib/yorishiro/skill_loader.rb', line 15

def load_dir(dir)
  return unless Dir.exist?(dir)

  Dir.glob(File.join(dir, "*.rb")).each { |path| load_file(path) }
end