Sha256: 429d722477aa09d90ecd53e8de0ae7f5d283f7fac001f5a550a0be51bddf3992

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 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 ||= [
        RepositoryResolver::RubygemsResolver,
        RepositoryResolver::NpmResolver,
        RepositoryResolver::UserDefinedResolver,
      ]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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