Class: Ace::Bundle::Organisms::PrBundleLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/bundle/organisms/pr_bundle_loader.rb

Overview

Loads PR diff content into bundle

Responsible for:

  • Normalizing PR references (string, array, hash formats)

  • Fetching diffs via Ace::Git::Molecules::PrMetadataFetcher

  • Integrating results into bundle sections

  • Error handling and surfacing

Examples:

Basic usage

loader = PrBundleLoader.new(timeout: 60)
loader.process(bundle, ["123", "owner/repo#456"])

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PrBundleLoader

Returns a new instance of PrBundleLoader.

Parameters:

  • options (Hash) (defaults to: {})

    Configuration options

Options Hash (options):

  • :timeout (Integer)

    Timeout for gh commands (default from ace-git config)

  • :debug (Boolean)

    Enable debug output



24
25
26
27
# File 'lib/ace/bundle/organisms/pr_bundle_loader.rb', line 24

def initialize(options = {})
  @timeout = options[:timeout] || Ace::Git.network_timeout
  @debug = options[:debug] || false
end

Instance Method Details

#process(bundle, pr_refs) ⇒ Boolean

Process PR references and add diffs to bundle

Parameters:

  • bundle (Models::BundleData)

    Bundle to populate

  • pr_refs (Array<String>, String, Hash, nil)

    PR reference(s)

Returns:

  • (Boolean)

    true if at least one diff was successfully fetched



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ace/bundle/organisms/pr_bundle_loader.rb', line 34

def process(bundle, pr_refs)
  normalized = normalize_pr_refs(pr_refs)
  return false if normalized.empty?

  processed_diffs = fetch_all_diffs(bundle, normalized)
  successful_diffs = processed_diffs.select { |d| d[:success] }

  if successful_diffs.empty?
    surface_errors_to_content(bundle)
    return false
  end

  add_diffs_to_bundle(bundle, processed_diffs)
  true
end