Class: Ace::Demo::Molecules::DemoSandboxBuilder
- Inherits:
-
Object
- Object
- Ace::Demo::Molecules::DemoSandboxBuilder
- Defined in:
- lib/ace/demo/molecules/demo_sandbox_builder.rb
Constant Summary collapse
- VALID_SETUP_DIRECTIVES =
["sandbox", "git-init", "copy-fixtures", "run:"].freeze
Instance Method Summary collapse
- #build(source_tape_path:, setup_steps:) ⇒ Object
-
#initialize(sandbox_dir: , cwd: Dir.pwd) ⇒ DemoSandboxBuilder
constructor
A new instance of DemoSandboxBuilder.
Constructor Details
#initialize(sandbox_dir: , cwd: Dir.pwd) ⇒ DemoSandboxBuilder
Returns a new instance of DemoSandboxBuilder.
13 14 15 16 |
# File 'lib/ace/demo/molecules/demo_sandbox_builder.rb', line 13 def initialize(sandbox_dir: Demo.config["sandbox_dir"], cwd: Dir.pwd) @cwd = cwd @sandbox_dir = File.(sandbox_dir || ".ace-local/demo/sandbox", @cwd) end |
Instance Method Details
#build(source_tape_path:, setup_steps:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ace/demo/molecules/demo_sandbox_builder.rb', line 18 def build(source_tape_path:, setup_steps:) sandbox_id = Ace::B36ts.now sandbox_path = File.join(@sandbox_dir, sandbox_id) FileUtils.mkdir_p(sandbox_path) warnings = [] setup_steps.each do |step| execute_setup_step( step, sandbox_path: sandbox_path, source_tape_path: source_tape_path, warnings: warnings ) end {id: sandbox_id, path: sandbox_path, warnings: warnings} rescue ArgumentError cleanup_failed_sandbox(sandbox_path) raise rescue => e cleanup_failed_sandbox(sandbox_path) raise "Sandbox setup failed for #{sandbox_path}: #{e.}" end |