Class: Gemkeeper::GemRepoResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/gemkeeper/gem_repo_resolver.rb

Overview

Resolves gem candidates (from lockfile sources) to git repo URLs. GIT-sourced gems are added automatically; private gem registry entries are inferred where possible (GitHub Packages) or prompted interactively.

Instance Method Summary collapse

Constructor Details

#initialize(candidates:, manifest:, input: $stdin, output: $stdout) ⇒ GemRepoResolver

Returns a new instance of GemRepoResolver.



8
9
10
11
12
13
# File 'lib/gemkeeper/gem_repo_resolver.rb', line 8

def initialize(candidates:, manifest:, input: $stdin, output: $stdout)
  @candidates = candidates
  @manifest = manifest
  @input = input
  @output = output
end

Instance Method Details

#resolve!Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gemkeeper/gem_repo_resolver.rb', line 15

def resolve!
  unresolvable = []

  @candidates.each do |candidate|
    name = candidate[:name]
    next if @manifest.repo_for(name)

    if candidate[:source_type] == :git
      @manifest.add_mapping(name:, repo: candidate[:repo])
    else
      repo = resolve_private_gem(candidate)
      if repo
        @manifest.add_mapping(name:, repo:)
      else
        unresolvable << candidate
      end
    end
  end

  raise_unresolvable(unresolvable) if unresolvable.any?
  @manifest
end