Class: TheLocal::Builder
- Inherits:
-
Object
- Object
- TheLocal::Builder
- Defined in:
- lib/the_local/builder.rb
Overview
Renders each registered agent’s markdown to its committed source_path, so a provider gem can commit the files and the host installer later copies them verbatim (rather than rendering at install time). Plain Ruby — driven by the the_local:build rake task a provider runs. Agents that declared no agents_dir (and so have no source_path) are skipped: there is nowhere to write them.
Constant Summary collapse
- PLACEHOLDER =
A real placeholder is a line-leading “TODO:”; an inline mention of the marker (a guide documenting the convention) is left alone.
/^\s*TODO:/- REQUIRED_SECTIONS =
The canonical sections every guide must carry, so a consuming agent meets the same shape in every gem’s local. Matched as header prefixes.
["### Interface", "### Recipe", "### Install", "### Conventions"].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(registry:, validate: false) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(registry:, validate: false) ⇒ Builder
Returns a new instance of Builder.
20 21 22 23 |
# File 'lib/the_local/builder.rb', line 20 def initialize(registry:, validate: false) @registry = registry @validate = validate end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/the_local/builder.rb', line 25 def call validate! if @validate buildable_agents.map do |agent| FileUtils.mkdir_p(File.dirname(agent.source_path)) File.write(agent.source_path, agent.to_markdown) agent.source_path end end |