Class: TheLocal::Builder

Inherits:
Object
  • Object
show all
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.

Instance Method Summary collapse

Constructor Details

#initialize(registry:) ⇒ Builder

Returns a new instance of Builder.



12
13
14
# File 'lib/the_local/builder.rb', line 12

def initialize(registry:)
  @registry = registry
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
# File 'lib/the_local/builder.rb', line 16

def call
  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