Class: Bundler::Codegraph::Backfill

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/codegraph/backfill.rb

Overview

Indexes a whole set of gem specs, one at a time: the queue after_install_all drains at the end of bundle install, or the whole resolved bundle for bundle codegraph-index.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(specs, reporter: nil, **indexer_options) ⇒ Backfill

Returns a new instance of Backfill.

Parameters:

  • specs (Enumerable) —

    objects responding to name and full_gem_path

  • reporter (#call, nil) (defaults to: nil) —

    called after each gem with its name, its status and Indexer#log_hint

  • indexer_options (Hash) —

    handed to every Indexer as is (config:, force:, sync:, skip_failed:), with a single Config for them all



18
19
20
21
22
# File 'lib/bundler/codegraph/backfill.rb', line 18

def initialize(specs, reporter: nil, **indexer_options)
  @specs           = specs
  @reporter        = reporter
  @indexer_options = { config: Config.new }.merge(indexer_options)
end

Instance Attribute Details

#indexer_options ⇒ Object (readonly)

Returns the value of attribute indexer_options.



11
12
13
# File 'lib/bundler/codegraph/backfill.rb', line 11

def indexer_options
  @indexer_options
end

#reporter ⇒ Object (readonly)

Returns the value of attribute reporter.



11
12
13
# File 'lib/bundler/codegraph/backfill.rb', line 11

def reporter
  @reporter
end

#specs ⇒ Object (readonly)

Returns the value of attribute specs.



11
12
13
# File 'lib/bundler/codegraph/backfill.rb', line 11

def specs
  @specs
end

Instance Method Details

#call ⇒ Hash{Symbol => Integer}

Returns number of gems per resulting status.

Returns:

  • (Hash{Symbol => Integer}) —

    number of gems per resulting status



25
26
27
28
29
30
31
# File 'lib/bundler/codegraph/backfill.rb', line 25

def call
  specs.each_with_object(Hash.new(0)) do |spec, results|
    name, status, log_hint = index(spec)
    results[status] += 1
    reporter&.call(name, status, log_hint)
  end
end