Class: PromptObjects::Env::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/prompt_objects/environment/exporter.rb

Overview

Exports an environment as a git bundle (.dump file — Declarative Unified Memory Package). The bundle contains all commits, objects, primitives, and manifest. Sessions are NOT included (private data).

Instance Method Summary collapse

Constructor Details

#initialize(env_path) ⇒ Exporter

Returns a new instance of Exporter.

Parameters:

  • env_path (String)

    Path to the environment directory



11
12
13
14
# File 'lib/prompt_objects/environment/exporter.rb', line 11

def initialize(env_path)
  @env_path = env_path
  @name = File.basename(env_path)
end

Instance Method Details

#export(output_path, commit_message: nil) ⇒ Hash

Export the environment to a git bundle.

Parameters:

  • output_path (String)

    Path for the output .dump file

  • commit_message (String, nil) (defaults to: nil)

    Message for any uncommitted changes

Returns:

  • (Hash)

    Export result with :success, :path, :stats



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/prompt_objects/environment/exporter.rb', line 20

def export(output_path, commit_message: nil)
  validate_environment!

  # Ensure we have a clean state
  commit_changes(commit_message) if Git.dirty?(@env_path)

  # Create the bundle
  output_path = normalize_output_path(output_path)
  success = Git.bundle(@env_path, output_path)

  unless success
    return { success: false, error: "Failed to create git bundle" }
  end

  {
    success: true,
    path: output_path,
    stats: gather_stats
  }
end