Class: Ace::Sim::Molecules::SourceBundler
- Inherits:
-
Object
- Object
- Ace::Sim::Molecules::SourceBundler
- Defined in:
- lib/ace/sim/molecules/source_bundler.rb
Defined Under Namespace
Classes: CommandRunner
Instance Method Summary collapse
- #bundle(sources:, output_path:) ⇒ Object
-
#initialize(command_runner: nil) ⇒ SourceBundler
constructor
A new instance of SourceBundler.
Constructor Details
#initialize(command_runner: nil) ⇒ SourceBundler
Returns a new instance of SourceBundler.
22 23 24 |
# File 'lib/ace/sim/molecules/source_bundler.rb', line 22 def initialize(command_runner: nil) @command_runner = command_runner || CommandRunner.new end |
Instance Method Details
#bundle(sources:, output_path:) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ace/sim/molecules/source_bundler.rb', line 26 def bundle(sources:, output_path:) raise Ace::Sim::ValidationError, "source cannot be empty" if sources.nil? || sources.empty? run_dir = File.dirname(output_path) bundle_path = File.join(run_dir, "input.bundle.md") content_path = File.join(run_dir, "input.md") FileUtils.mkdir_p(run_dir) File.write(bundle_path, build_bundle_yaml(sources)) result = command_runner.call(["ace-bundle", bundle_path, "--output", content_path]) return content_path if result[:success] detail = result[:stderr].to_s.strip detail = result[:stdout].to_s.strip if detail.empty? detail = "command failed" if detail.empty? raise Ace::Sim::ValidationError, "ace-bundle failed: #{detail}" end |