Sha256: df63ffcd0fc83993b3e1c26eaeec05029944c7d1faec9ea151ea0322b77d4f38

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

module Codestatus
  class RepositoryResolver
    def initialize(registry:, package:)
      @registry = registry
      @package = package
    end

    attr_reader :registry, :package

    def repository
      @repository ||= resolve
    end

    private

    def resolve
      result = nil
      resolvers.each do |resolver|
        result = resolver.resolve(registry: registry, package: package)
        break if result
      end
      result
    end

    def resolvers
      @resolvers ||= resolver_classes.map(&:new)
    end

    def resolver_classes
      @resolver_classes ||= [
        # RubygemsResolver, NpmResolver, ...
        RepositoryResolver::RubygemsResolver,
        RepositoryResolver::UserDefinedResolver,
      ]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codestatus-0.1.0 lib/codestatus/repository_resolver.rb