Class: Diogenes::Targets::Base
- Inherits:
-
Object
- Object
- Diogenes::Targets::Base
- Defined in:
- lib/diogenes/targets/base.rb,
sig/generated/diogenes/targets/base.rbs
Direct Known Subclasses
Instance Method Summary collapse
-
#build(sources:) ⇒ Array[String]
: (sources: untyped) -> Array.
-
#generated_banner(target_name) ⇒ String
: (String) -> String.
-
#initialize(cwd:, out:) ⇒ Base
constructor
: (cwd: String, out: IO) -> void.
-
#skill_file_content(skill) ⇒ String
: (DSL::Skill) -> String.
-
#write(relative_path, content) ⇒ String
: (String, String) -> String.
- #write_skill_files(skills, skills_dir:) ⇒ Array[String]
Constructor Details
#initialize(cwd:, out:) ⇒ Base
: (cwd: String, out: IO) -> void
10 11 12 13 |
# File 'lib/diogenes/targets/base.rb', line 10 def initialize(cwd:, out:) @cwd = cwd #: String @out = out #: IO end |
Instance Method Details
#build(sources:) ⇒ Array[String]
: (sources: untyped) -> Array
16 17 18 |
# File 'lib/diogenes/targets/base.rb', line 16 def build(sources:) raise NotImplementedError, "#{self.class}#build must be implemented" end |
#generated_banner(target_name) ⇒ String
: (String) -> String
31 32 33 34 |
# File 'lib/diogenes/targets/base.rb', line 31 def (target_name) "Generated by `diogenes build --target #{target_name}`. " \ "Edit sources in `.diogenes/` and rebuild. Do not edit directly." end |
#skill_file_content(skill) ⇒ String
: (DSL::Skill) -> String
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/diogenes/targets/base.rb', line 45 def skill_file_content(skill) <<~MD.strip # #{skill.command} #{skill.description} ## Prompt #{skill.prompt} MD end |
#write(relative_path, content) ⇒ String
: (String, String) -> String
23 24 25 26 27 28 |
# File 'lib/diogenes/targets/base.rb', line 23 def write(relative_path, content) full = File.join(@cwd, relative_path) FileUtils.mkdir_p(File.dirname(full)) File.write(full, content) relative_path end |
#write_skill_files(skills, skills_dir:) ⇒ Array[String]
37 38 39 40 41 42 |
# File 'lib/diogenes/targets/base.rb', line 37 def write_skill_files(skills, skills_dir:) skills.map do |skill| slug = skill.command.to_s.sub(/\A\//, "") write(File.join(skills_dir, slug, "SKILL.md"), skill_file_content(skill)) end end |